]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.12.1-201311261309.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.12.1-201311261309.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 fcbb736..5508d8c 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -1031,6 +1031,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 @@ -1999,6 +2003,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 @@ -2266,6 +2274,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 eb29ec7..876409e 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 define filechk_kernel.release
403 @@ -838,6 +900,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 @@ -945,6 +1008,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 @@ -960,7 +1025,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 @@ -1026,7 +1091,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 @@ -1066,6 +1131,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 @@ -1227,6 +1293,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 @@ -1366,17 +1434,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 @@ -1386,11 +1458,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 98838a0..b304fb4 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 1ad6fb6..4e7fae5 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1832,7 +1832,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 15f2d5b..43ffa53 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 f4b46d3..abc9b2b 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -114,7 +114,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 @@ -124,10 +131,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 f94784f..41c7f61 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 +} __do_const;
1803
1804 extern struct outer_cache_fns 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 be956db..c8f25e2 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 df5e13d..97efb82 100644
2096 --- a/arch/arm/include/asm/thread_info.h
2097 +++ b/arch/arm/include/asm/thread_info.h
2098 @@ -88,9 +88,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 @@ -163,7 +163,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 @@ -176,10 +180,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 72abdc5..9eba222 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 #if __LINUX_ARM_ARCH__ < 6
2148 #include <asm-generic/uaccess-unaligned.h>
2149 @@ -70,11 +71,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 @@ -150,8 +178,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 @@ -195,8 +227,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 @@ -237,13 +273,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 @@ -319,13 +359,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 @@ -425,11 +469,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 @@ -438,6 +515,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 @@ -447,6 +527,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 bc6bd96..bd026cb 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2611 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2612 #endif
2613
2614 + /*
2615 + * do this here to avoid a performance hit of wrapping the code above
2616 + * that directly dereferences userland to parse the SWI instruction
2617 + */
2618 + pax_enter_kernel_user
2619 +
2620 adr tbl, sys_call_table @ load syscall table pointer
2621
2622 #if defined(CONFIG_OABI_COMPAT)
2623 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2624 index 39f89fb..d612bd9 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 476de57..4857a76 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 084dc88..fce4e68 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,39 @@
2752 #endif
2753
2754 #ifdef CONFIG_MMU
2755 -void *module_alloc(unsigned long size)
2756 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2757 {
2758 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2759 + return NULL;
2760 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2761 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2762 + GFP_KERNEL, prot, -1,
2763 __builtin_return_address(0));
2764 }
2765 +
2766 +void *module_alloc(unsigned long size)
2767 +{
2768 +
2769 +#ifdef CONFIG_PAX_KERNEXEC
2770 + return __module_alloc(size, PAGE_KERNEL);
2771 +#else
2772 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2773 +#endif
2774 +
2775 +}
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 +void module_free_exec(struct module *mod, void *module_region)
2779 +{
2780 + module_free(mod, module_region);
2781 +}
2782 +EXPORT_SYMBOL(module_free_exec);
2783 +
2784 +void *module_alloc_exec(unsigned long size)
2785 +{
2786 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2787 +}
2788 +EXPORT_SYMBOL(module_alloc_exec);
2789 +#endif
2790 #endif
2791
2792 int
2793 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2794 index 07314af..c46655c 100644
2795 --- a/arch/arm/kernel/patch.c
2796 +++ b/arch/arm/kernel/patch.c
2797 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2798 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2799 int size;
2800
2801 + pax_open_kernel();
2802 if (thumb2 && __opcode_is_thumb16(insn)) {
2803 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2804 size = sizeof(u16);
2805 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 *(u32 *)addr = insn;
2807 size = sizeof(u32);
2808 }
2809 + pax_close_kernel();
2810
2811 flush_icache_range((uintptr_t)(addr),
2812 (uintptr_t)(addr) + size);
2813 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2814 index 94f6b05..efd7312 100644
2815 --- a/arch/arm/kernel/process.c
2816 +++ b/arch/arm/kernel/process.c
2817 @@ -217,6 +217,7 @@ void machine_power_off(void)
2818
2819 if (pm_power_off)
2820 pm_power_off();
2821 + BUG();
2822 }
2823
2824 /*
2825 @@ -230,7 +231,7 @@ void machine_power_off(void)
2826 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2827 * to use. Implementing such co-ordination would be essentially impossible.
2828 */
2829 -void machine_restart(char *cmd)
2830 +__noreturn void machine_restart(char *cmd)
2831 {
2832 local_irq_disable();
2833 smp_send_stop();
2834 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2835
2836 show_regs_print_info(KERN_DEFAULT);
2837
2838 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2839 - print_symbol("LR is at %s\n", regs->ARM_lr);
2840 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2841 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2842 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2843 "sp : %08lx ip : %08lx fp : %08lx\n",
2844 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2845 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2846 return 0;
2847 }
2848
2849 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2850 -{
2851 - unsigned long range_end = mm->brk + 0x02000000;
2852 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2853 -}
2854 -
2855 #ifdef CONFIG_MMU
2856 #ifdef CONFIG_KUSER_HELPERS
2857 /*
2858 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2859
2860 static int __init gate_vma_init(void)
2861 {
2862 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2863 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2864 return 0;
2865 }
2866 arch_initcall(gate_vma_init);
2867 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2868
2869 const char *arch_vma_name(struct vm_area_struct *vma)
2870 {
2871 - return is_gate_vma(vma) ? "[vectors]" :
2872 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2873 - "[sigpage]" : NULL;
2874 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2875 }
2876
2877 -static struct page *signal_page;
2878 -extern struct page *get_signal_page(void);
2879 -
2880 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2881 {
2882 struct mm_struct *mm = current->mm;
2883 - unsigned long addr;
2884 - int ret;
2885 -
2886 - if (!signal_page)
2887 - signal_page = get_signal_page();
2888 - if (!signal_page)
2889 - return -ENOMEM;
2890
2891 down_write(&mm->mmap_sem);
2892 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2893 - if (IS_ERR_VALUE(addr)) {
2894 - ret = addr;
2895 - goto up_fail;
2896 - }
2897 -
2898 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2899 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2900 - &signal_page);
2901 -
2902 - if (ret == 0)
2903 - mm->context.sigpage = addr;
2904 -
2905 - up_fail:
2906 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2907 up_write(&mm->mmap_sem);
2908 - return ret;
2909 + return 0;
2910 }
2911 #endif
2912 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2913 index 4693188..4596c5e 100644
2914 --- a/arch/arm/kernel/psci.c
2915 +++ b/arch/arm/kernel/psci.c
2916 @@ -24,7 +24,7 @@
2917 #include <asm/opcodes-virt.h>
2918 #include <asm/psci.h>
2919
2920 -struct psci_operations psci_ops;
2921 +struct psci_operations psci_ops __read_only;
2922
2923 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2924
2925 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2926 index 0dd3b79..e018f64 100644
2927 --- a/arch/arm/kernel/ptrace.c
2928 +++ b/arch/arm/kernel/ptrace.c
2929 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2930 return current_thread_info()->syscall;
2931 }
2932
2933 +#ifdef CONFIG_GRKERNSEC_SETXID
2934 +extern void gr_delayed_cred_worker(void);
2935 +#endif
2936 +
2937 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2938 {
2939 current_thread_info()->syscall = scno;
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2943 + gr_delayed_cred_worker();
2944 +#endif
2945 +
2946 /* Do the secure computing check first; failures should be fast. */
2947 if (secure_computing(scno) == -1)
2948 return -1;
2949 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2950 index 0e1e2b3..c0e821d 100644
2951 --- a/arch/arm/kernel/setup.c
2952 +++ b/arch/arm/kernel/setup.c
2953 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2954 unsigned int elf_hwcap __read_mostly;
2955 EXPORT_SYMBOL(elf_hwcap);
2956
2957 +pteval_t __supported_pte_mask __read_only;
2958 +pmdval_t __supported_pmd_mask __read_only;
2959
2960 #ifdef MULTI_CPU
2961 -struct processor processor __read_mostly;
2962 +struct processor processor;
2963 #endif
2964 #ifdef MULTI_TLB
2965 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2966 +struct cpu_tlb_fns cpu_tlb __read_only;
2967 #endif
2968 #ifdef MULTI_USER
2969 -struct cpu_user_fns cpu_user __read_mostly;
2970 +struct cpu_user_fns cpu_user __read_only;
2971 #endif
2972 #ifdef MULTI_CACHE
2973 -struct cpu_cache_fns cpu_cache __read_mostly;
2974 +struct cpu_cache_fns cpu_cache __read_only;
2975 #endif
2976 #ifdef CONFIG_OUTER_CACHE
2977 -struct outer_cache_fns outer_cache __read_mostly;
2978 +struct outer_cache_fns outer_cache __read_only;
2979 EXPORT_SYMBOL(outer_cache);
2980 #endif
2981
2982 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2983 asm("mrc p15, 0, %0, c0, c1, 4"
2984 : "=r" (mmfr0));
2985 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2986 - (mmfr0 & 0x000000f0) >= 0x00000030)
2987 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2988 cpu_arch = CPU_ARCH_ARMv7;
2989 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2990 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2991 + __supported_pte_mask |= L_PTE_PXN;
2992 + __supported_pmd_mask |= PMD_PXNTABLE;
2993 + }
2994 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 (mmfr0 & 0x000000f0) == 0x00000020)
2996 cpu_arch = CPU_ARCH_ARMv6;
2997 else
2998 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2999 __cpu_architecture = __get_cpu_architecture();
3000
3001 #ifdef MULTI_CPU
3002 - processor = *list->proc;
3003 + memcpy((void *)&processor, list->proc, sizeof processor);
3004 #endif
3005 #ifdef MULTI_TLB
3006 cpu_tlb = *list->tlb;
3007 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3008 index ab33042..11248a8 100644
3009 --- a/arch/arm/kernel/signal.c
3010 +++ b/arch/arm/kernel/signal.c
3011 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3012 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3013 };
3014
3015 -static unsigned long signal_return_offset;
3016 -
3017 #ifdef CONFIG_CRUNCH
3018 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3019 {
3020 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3021 * except when the MPU has protected the vectors
3022 * page from PL0
3023 */
3024 - retcode = mm->context.sigpage + signal_return_offset +
3025 - (idx << 2) + thumb;
3026 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3027 } else
3028 #endif
3029 {
3030 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3031 } while (thread_flags & _TIF_WORK_MASK);
3032 return 0;
3033 }
3034 -
3035 -struct page *get_signal_page(void)
3036 -{
3037 - unsigned long ptr;
3038 - unsigned offset;
3039 - struct page *page;
3040 - void *addr;
3041 -
3042 - page = alloc_pages(GFP_KERNEL, 0);
3043 -
3044 - if (!page)
3045 - return NULL;
3046 -
3047 - addr = page_address(page);
3048 -
3049 - /* Give the signal return code some randomness */
3050 - offset = 0x200 + (get_random_int() & 0x7fc);
3051 - signal_return_offset = offset;
3052 -
3053 - /*
3054 - * Copy signal return handlers into the vector page, and
3055 - * set sigreturn to be a pointer to these.
3056 - */
3057 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3058 -
3059 - ptr = (unsigned long)addr + offset;
3060 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3061 -
3062 - return page;
3063 -}
3064 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3065 index 72024ea..ae302dd 100644
3066 --- a/arch/arm/kernel/smp.c
3067 +++ b/arch/arm/kernel/smp.c
3068 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3069
3070 static DECLARE_COMPLETION(cpu_running);
3071
3072 -static struct smp_operations smp_ops;
3073 +static struct smp_operations smp_ops __read_only;
3074
3075 void __init smp_set_ops(struct smp_operations *ops)
3076 {
3077 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3078 index 8fcda14..4512b9d 100644
3079 --- a/arch/arm/kernel/traps.c
3080 +++ b/arch/arm/kernel/traps.c
3081 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3082 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3083 {
3084 #ifdef CONFIG_KALLSYMS
3085 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3086 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3087 #else
3088 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3089 #endif
3090 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3091 static int die_owner = -1;
3092 static unsigned int die_nest_count;
3093
3094 +extern void gr_handle_kernel_exploit(void);
3095 +
3096 static unsigned long oops_begin(void)
3097 {
3098 int cpu;
3099 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3100 panic("Fatal exception in interrupt");
3101 if (panic_on_oops)
3102 panic("Fatal exception");
3103 +
3104 + gr_handle_kernel_exploit();
3105 +
3106 if (signr)
3107 do_exit(signr);
3108 }
3109 @@ -628,7 +633,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3110 * The user helper at 0xffff0fe0 must be used instead.
3111 * (see entry-armv.S for details)
3112 */
3113 + pax_open_kernel();
3114 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3115 + pax_close_kernel();
3116 }
3117 return 0;
3118
3119 @@ -885,7 +892,11 @@ void __init early_trap_init(void *vectors_base)
3120 kuser_init(vectors_base);
3121
3122 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3123 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3124 +
3125 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3126 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3127 +#endif
3128 +
3129 #else /* ifndef CONFIG_CPU_V7M */
3130 /*
3131 * on V7-M there is no need to copy the vector table to a dedicated
3132 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3133 index 7bcee5c..e2f3249 100644
3134 --- a/arch/arm/kernel/vmlinux.lds.S
3135 +++ b/arch/arm/kernel/vmlinux.lds.S
3136 @@ -8,7 +8,11 @@
3137 #include <asm/thread_info.h>
3138 #include <asm/memory.h>
3139 #include <asm/page.h>
3140 -
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 +#include <asm/pgtable.h>
3144 +#endif
3145 +
3146 #define PROC_INFO \
3147 . = ALIGN(4); \
3148 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3149 @@ -34,7 +38,7 @@
3150 #endif
3151
3152 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3153 - defined(CONFIG_GENERIC_BUG)
3154 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3155 #define ARM_EXIT_KEEP(x) x
3156 #define ARM_EXIT_DISCARD(x)
3157 #else
3158 @@ -90,6 +94,11 @@ SECTIONS
3159 _text = .;
3160 HEAD_TEXT
3161 }
3162 +
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166 +
3167 .text : { /* Real text segment */
3168 _stext = .; /* Text and read-only data */
3169 __exception_text_start = .;
3170 @@ -112,6 +121,8 @@ SECTIONS
3171 ARM_CPU_KEEP(PROC_INFO)
3172 }
3173
3174 + _etext = .; /* End of text section */
3175 +
3176 RO_DATA(PAGE_SIZE)
3177
3178 . = ALIGN(4);
3179 @@ -142,7 +153,9 @@ SECTIONS
3180
3181 NOTES
3182
3183 - _etext = .; /* End of text and rodata section */
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187
3188 #ifndef CONFIG_XIP_KERNEL
3189 . = ALIGN(PAGE_SIZE);
3190 @@ -220,6 +233,11 @@ SECTIONS
3191 . = PAGE_OFFSET + TEXT_OFFSET;
3192 #else
3193 __init_end = .;
3194 +
3195 +#ifdef CONFIG_PAX_KERNEXEC
3196 + . = ALIGN(1<<SECTION_SHIFT);
3197 +#endif
3198 +
3199 . = ALIGN(THREAD_SIZE);
3200 __data_loc = .;
3201 #endif
3202 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3203 index 9c697db..115237f 100644
3204 --- a/arch/arm/kvm/arm.c
3205 +++ b/arch/arm/kvm/arm.c
3206 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3207 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3208
3209 /* The VMID used in the VTTBR */
3210 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3211 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3212 static u8 kvm_next_vmid;
3213 static DEFINE_SPINLOCK(kvm_vmid_lock);
3214
3215 @@ -396,7 +396,7 @@ void force_vm_exit(const cpumask_t *mask)
3216 */
3217 static bool need_new_vmid_gen(struct kvm *kvm)
3218 {
3219 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3220 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3221 }
3222
3223 /**
3224 @@ -429,7 +429,7 @@ static void update_vttbr(struct kvm *kvm)
3225
3226 /* First user of a new VMID generation? */
3227 if (unlikely(kvm_next_vmid == 0)) {
3228 - atomic64_inc(&kvm_vmid_gen);
3229 + atomic64_inc_unchecked(&kvm_vmid_gen);
3230 kvm_next_vmid = 1;
3231
3232 /*
3233 @@ -446,7 +446,7 @@ static void update_vttbr(struct kvm *kvm)
3234 kvm_call_hyp(__kvm_flush_vm_context);
3235 }
3236
3237 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3238 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3239 kvm->arch.vmid = kvm_next_vmid;
3240 kvm_next_vmid++;
3241
3242 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3243 index 14a0d98..7771a7d 100644
3244 --- a/arch/arm/lib/clear_user.S
3245 +++ b/arch/arm/lib/clear_user.S
3246 @@ -12,14 +12,14 @@
3247
3248 .text
3249
3250 -/* Prototype: int __clear_user(void *addr, size_t sz)
3251 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3252 * Purpose : clear some user memory
3253 * Params : addr - user memory address to clear
3254 * : sz - number of bytes to clear
3255 * Returns : number of bytes NOT cleared
3256 */
3257 ENTRY(__clear_user_std)
3258 -WEAK(__clear_user)
3259 +WEAK(___clear_user)
3260 stmfd sp!, {r1, lr}
3261 mov r2, #0
3262 cmp r1, #4
3263 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3264 USER( strnebt r2, [r0])
3265 mov r0, #0
3266 ldmfd sp!, {r1, pc}
3267 -ENDPROC(__clear_user)
3268 +ENDPROC(___clear_user)
3269 ENDPROC(__clear_user_std)
3270
3271 .pushsection .fixup,"ax"
3272 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3273 index 66a477a..bee61d3 100644
3274 --- a/arch/arm/lib/copy_from_user.S
3275 +++ b/arch/arm/lib/copy_from_user.S
3276 @@ -16,7 +16,7 @@
3277 /*
3278 * Prototype:
3279 *
3280 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3281 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3282 *
3283 * Purpose:
3284 *
3285 @@ -84,11 +84,11 @@
3286
3287 .text
3288
3289 -ENTRY(__copy_from_user)
3290 +ENTRY(___copy_from_user)
3291
3292 #include "copy_template.S"
3293
3294 -ENDPROC(__copy_from_user)
3295 +ENDPROC(___copy_from_user)
3296
3297 .pushsection .fixup,"ax"
3298 .align 0
3299 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3300 index 6ee2f67..d1cce76 100644
3301 --- a/arch/arm/lib/copy_page.S
3302 +++ b/arch/arm/lib/copy_page.S
3303 @@ -10,6 +10,7 @@
3304 * ASM optimised string functions
3305 */
3306 #include <linux/linkage.h>
3307 +#include <linux/const.h>
3308 #include <asm/assembler.h>
3309 #include <asm/asm-offsets.h>
3310 #include <asm/cache.h>
3311 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3312 index d066df6..df28194 100644
3313 --- a/arch/arm/lib/copy_to_user.S
3314 +++ b/arch/arm/lib/copy_to_user.S
3315 @@ -16,7 +16,7 @@
3316 /*
3317 * Prototype:
3318 *
3319 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3320 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3321 *
3322 * Purpose:
3323 *
3324 @@ -88,11 +88,11 @@
3325 .text
3326
3327 ENTRY(__copy_to_user_std)
3328 -WEAK(__copy_to_user)
3329 +WEAK(___copy_to_user)
3330
3331 #include "copy_template.S"
3332
3333 -ENDPROC(__copy_to_user)
3334 +ENDPROC(___copy_to_user)
3335 ENDPROC(__copy_to_user_std)
3336
3337 .pushsection .fixup,"ax"
3338 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3339 index 7d08b43..f7ca7ea 100644
3340 --- a/arch/arm/lib/csumpartialcopyuser.S
3341 +++ b/arch/arm/lib/csumpartialcopyuser.S
3342 @@ -57,8 +57,8 @@
3343 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3344 */
3345
3346 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3347 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3348 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3349 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3350
3351 #include "csumpartialcopygeneric.S"
3352
3353 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3354 index 5306de3..aed6d03 100644
3355 --- a/arch/arm/lib/delay.c
3356 +++ b/arch/arm/lib/delay.c
3357 @@ -28,7 +28,7 @@
3358 /*
3359 * Default to the loop-based delay implementation.
3360 */
3361 -struct arm_delay_ops arm_delay_ops = {
3362 +struct arm_delay_ops arm_delay_ops __read_only = {
3363 .delay = __loop_delay,
3364 .const_udelay = __loop_const_udelay,
3365 .udelay = __loop_udelay,
3366 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3367 index 025f742..a9e5b3b 100644
3368 --- a/arch/arm/lib/uaccess_with_memcpy.c
3369 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3370 @@ -104,7 +104,7 @@ out:
3371 }
3372
3373 unsigned long
3374 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3375 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3376 {
3377 /*
3378 * This test is stubbed out of the main function above to keep
3379 @@ -155,7 +155,7 @@ out:
3380 return n;
3381 }
3382
3383 -unsigned long __clear_user(void __user *addr, unsigned long n)
3384 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3385 {
3386 /* See rational for this in __copy_to_user() above. */
3387 if (n < 64)
3388 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3389 index 1767611..d2e7e24 100644
3390 --- a/arch/arm/mach-kirkwood/common.c
3391 +++ b/arch/arm/mach-kirkwood/common.c
3392 @@ -156,7 +156,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3393 clk_gate_ops.disable(hw);
3394 }
3395
3396 -static struct clk_ops clk_gate_fn_ops;
3397 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3398 +{
3399 + return clk_gate_ops.is_enabled(hw);
3400 +}
3401 +
3402 +static struct clk_ops clk_gate_fn_ops = {
3403 + .enable = clk_gate_fn_enable,
3404 + .disable = clk_gate_fn_disable,
3405 + .is_enabled = clk_gate_fn_is_enabled,
3406 +};
3407
3408 static struct clk __init *clk_register_gate_fn(struct device *dev,
3409 const char *name,
3410 @@ -190,14 +199,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3411 gate_fn->fn_en = fn_en;
3412 gate_fn->fn_dis = fn_dis;
3413
3414 - /* ops is the gate ops, but with our enable/disable functions */
3415 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3416 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3417 - clk_gate_fn_ops = clk_gate_ops;
3418 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3419 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3420 - }
3421 -
3422 clk = clk_register(dev, &gate_fn->gate.hw);
3423
3424 if (IS_ERR(clk))
3425 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3426 index 827d1500..2885dc6 100644
3427 --- a/arch/arm/mach-omap2/board-n8x0.c
3428 +++ b/arch/arm/mach-omap2/board-n8x0.c
3429 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3430 }
3431 #endif
3432
3433 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3434 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3435 .late_init = n8x0_menelaus_late_init,
3436 };
3437
3438 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3439 index 579697a..1d5a3b2 100644
3440 --- a/arch/arm/mach-omap2/gpmc.c
3441 +++ b/arch/arm/mach-omap2/gpmc.c
3442 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3443 };
3444
3445 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3446 -static struct irq_chip gpmc_irq_chip;
3447 static int gpmc_irq_start;
3448
3449 static struct resource gpmc_mem_root;
3450 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3451
3452 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3453
3454 +static struct irq_chip gpmc_irq_chip = {
3455 + .name = "gpmc",
3456 + .irq_startup = gpmc_irq_noop_ret,
3457 + .irq_enable = gpmc_irq_enable,
3458 + .irq_disable = gpmc_irq_disable,
3459 + .irq_shutdown = gpmc_irq_noop,
3460 + .irq_ack = gpmc_irq_noop,
3461 + .irq_mask = gpmc_irq_noop,
3462 + .irq_unmask = gpmc_irq_noop,
3463 +
3464 +};
3465 +
3466 static int gpmc_setup_irq(void)
3467 {
3468 int i;
3469 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3470 return gpmc_irq_start;
3471 }
3472
3473 - gpmc_irq_chip.name = "gpmc";
3474 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3475 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3476 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3477 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3478 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3479 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3480 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3481 -
3482 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3483 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3484
3485 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3486 index f991016..145ebeb 100644
3487 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3488 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3489 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3490 int (*finish_suspend)(unsigned long cpu_state);
3491 void (*resume)(void);
3492 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3493 -};
3494 +} __no_const;
3495
3496 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3497 static struct powerdomain *mpuss_pd;
3498 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3499 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3500 {}
3501
3502 -struct cpu_pm_ops omap_pm_ops = {
3503 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3504 .finish_suspend = default_finish_suspend,
3505 .resume = dummy_cpu_resume,
3506 .scu_prepare = dummy_scu_prepare,
3507 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3508 index 813c615..ce467c6 100644
3509 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3510 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3512 return NOTIFY_OK;
3513 }
3514
3515 -static struct notifier_block __refdata irq_hotplug_notifier = {
3516 +static struct notifier_block irq_hotplug_notifier = {
3517 .notifier_call = irq_cpu_hotplug_notify,
3518 };
3519
3520 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3521 index b69dd9a..70e5409 100644
3522 --- a/arch/arm/mach-omap2/omap_device.c
3523 +++ b/arch/arm/mach-omap2/omap_device.c
3524 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3525 struct platform_device __init *omap_device_build(const char *pdev_name,
3526 int pdev_id,
3527 struct omap_hwmod *oh,
3528 - void *pdata, int pdata_len)
3529 + const void *pdata, int pdata_len)
3530 {
3531 struct omap_hwmod *ohs[] = { oh };
3532
3533 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3534 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3535 int pdev_id,
3536 struct omap_hwmod **ohs,
3537 - int oh_cnt, void *pdata,
3538 + int oh_cnt, const void *pdata,
3539 int pdata_len)
3540 {
3541 int ret = -ENOMEM;
3542 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3543 index 17ca1ae..beba869 100644
3544 --- a/arch/arm/mach-omap2/omap_device.h
3545 +++ b/arch/arm/mach-omap2/omap_device.h
3546 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3547 /* Core code interface */
3548
3549 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3550 - struct omap_hwmod *oh, void *pdata,
3551 + struct omap_hwmod *oh, const void *pdata,
3552 int pdata_len);
3553
3554 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3555 struct omap_hwmod **oh, int oh_cnt,
3556 - void *pdata, int pdata_len);
3557 + const void *pdata, int pdata_len);
3558
3559 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3560 struct omap_hwmod **ohs, int oh_cnt);
3561 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3562 index d9ee0ff..24f224a 100644
3563 --- a/arch/arm/mach-omap2/omap_hwmod.c
3564 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3565 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3566 int (*init_clkdm)(struct omap_hwmod *oh);
3567 void (*update_context_lost)(struct omap_hwmod *oh);
3568 int (*get_context_lost)(struct omap_hwmod *oh);
3569 -};
3570 +} __no_const;
3571
3572 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3573 -static struct omap_hwmod_soc_ops soc_ops;
3574 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3575
3576 /* omap_hwmod_list contains all registered struct omap_hwmods */
3577 static LIST_HEAD(omap_hwmod_list);
3578 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3579 index d15c7bb..b2d1f0c 100644
3580 --- a/arch/arm/mach-omap2/wd_timer.c
3581 +++ b/arch/arm/mach-omap2/wd_timer.c
3582 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3583 struct omap_hwmod *oh;
3584 char *oh_name = "wd_timer2";
3585 char *dev_name = "omap_wdt";
3586 - struct omap_wd_timer_platform_data pdata;
3587 + static struct omap_wd_timer_platform_data pdata = {
3588 + .read_reset_sources = prm_read_reset_sources
3589 + };
3590
3591 if (!cpu_class_is_omap2() || of_have_populated_dt())
3592 return 0;
3593 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3594 return -EINVAL;
3595 }
3596
3597 - pdata.read_reset_sources = prm_read_reset_sources;
3598 -
3599 pdev = omap_device_build(dev_name, id, oh, &pdata,
3600 sizeof(struct omap_wd_timer_platform_data));
3601 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3602 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3603 index b82dcae..44ee5b6 100644
3604 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3605 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3607 bool entered_lp2 = false;
3608
3609 if (tegra_pending_sgi())
3610 - ACCESS_ONCE(abort_flag) = true;
3611 + ACCESS_ONCE_RW(abort_flag) = true;
3612
3613 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3614
3615 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3616 index 656324a..0beba28 100644
3617 --- a/arch/arm/mach-ux500/setup.h
3618 +++ b/arch/arm/mach-ux500/setup.h
3619 @@ -40,13 +40,6 @@ extern void ux500_timer_init(void);
3620 .type = MT_DEVICE, \
3621 }
3622
3623 -#define __MEM_DEV_DESC(x, sz) { \
3624 - .virtual = IO_ADDRESS(x), \
3625 - .pfn = __phys_to_pfn(x), \
3626 - .length = sz, \
3627 - .type = MT_MEMORY, \
3628 -}
3629 -
3630 extern struct smp_operations ux500_smp_ops;
3631 extern void ux500_cpu_die(unsigned int cpu);
3632
3633 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3634 index cd2c88e..4dd9b67 100644
3635 --- a/arch/arm/mm/Kconfig
3636 +++ b/arch/arm/mm/Kconfig
3637 @@ -446,7 +446,7 @@ config CPU_32v5
3638
3639 config CPU_32v6
3640 bool
3641 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3642 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3643 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3644
3645 config CPU_32v6K
3646 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3647
3648 config CPU_USE_DOMAINS
3649 bool
3650 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 help
3652 This option enables or disables the use of domain switching
3653 via the set_fs() function.
3654 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3655 config KUSER_HELPERS
3656 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3657 default y
3658 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3659 help
3660 Warning: disabling this option may break user programs.
3661
3662 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3663 See Documentation/arm/kernel_user_helpers.txt for details.
3664
3665 However, the fixed address nature of these helpers can be used
3666 - by ROP (return orientated programming) authors when creating
3667 + by ROP (Return Oriented Programming) authors when creating
3668 exploits.
3669
3670 If all of the binaries and libraries which run on your platform
3671 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3672 index 6f4585b..7b6f52b 100644
3673 --- a/arch/arm/mm/alignment.c
3674 +++ b/arch/arm/mm/alignment.c
3675 @@ -211,10 +211,12 @@ union offset_union {
3676 #define __get16_unaligned_check(ins,val,addr) \
3677 do { \
3678 unsigned int err = 0, v, a = addr; \
3679 + pax_open_userland(); \
3680 __get8_unaligned_check(ins,v,a,err); \
3681 val = v << ((BE) ? 8 : 0); \
3682 __get8_unaligned_check(ins,v,a,err); \
3683 val |= v << ((BE) ? 0 : 8); \
3684 + pax_close_userland(); \
3685 if (err) \
3686 goto fault; \
3687 } while (0)
3688 @@ -228,6 +230,7 @@ union offset_union {
3689 #define __get32_unaligned_check(ins,val,addr) \
3690 do { \
3691 unsigned int err = 0, v, a = addr; \
3692 + pax_open_userland(); \
3693 __get8_unaligned_check(ins,v,a,err); \
3694 val = v << ((BE) ? 24 : 0); \
3695 __get8_unaligned_check(ins,v,a,err); \
3696 @@ -236,6 +239,7 @@ union offset_union {
3697 val |= v << ((BE) ? 8 : 16); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val |= v << ((BE) ? 0 : 24); \
3700 + pax_close_userland(); \
3701 if (err) \
3702 goto fault; \
3703 } while (0)
3704 @@ -249,6 +253,7 @@ union offset_union {
3705 #define __put16_unaligned_check(ins,val,addr) \
3706 do { \
3707 unsigned int err = 0, v = val, a = addr; \
3708 + pax_open_userland(); \
3709 __asm__( FIRST_BYTE_16 \
3710 ARM( "1: "ins" %1, [%2], #1\n" ) \
3711 THUMB( "1: "ins" %1, [%2]\n" ) \
3712 @@ -268,6 +273,7 @@ union offset_union {
3713 " .popsection\n" \
3714 : "=r" (err), "=&r" (v), "=&r" (a) \
3715 : "0" (err), "1" (v), "2" (a)); \
3716 + pax_close_userland(); \
3717 if (err) \
3718 goto fault; \
3719 } while (0)
3720 @@ -281,6 +287,7 @@ union offset_union {
3721 #define __put32_unaligned_check(ins,val,addr) \
3722 do { \
3723 unsigned int err = 0, v = val, a = addr; \
3724 + pax_open_userland(); \
3725 __asm__( FIRST_BYTE_32 \
3726 ARM( "1: "ins" %1, [%2], #1\n" ) \
3727 THUMB( "1: "ins" %1, [%2]\n" ) \
3728 @@ -310,6 +317,7 @@ union offset_union {
3729 " .popsection\n" \
3730 : "=r" (err), "=&r" (v), "=&r" (a) \
3731 : "0" (err), "1" (v), "2" (a)); \
3732 + pax_close_userland(); \
3733 if (err) \
3734 goto fault; \
3735 } while (0)
3736 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3737 index 84e6f77..0b52f31 100644
3738 --- a/arch/arm/mm/context.c
3739 +++ b/arch/arm/mm/context.c
3740 @@ -43,7 +43,7 @@
3741 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3742
3743 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3744 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3745 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3746 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3747
3748 static DEFINE_PER_CPU(atomic64_t, active_asids);
3749 @@ -180,7 +180,7 @@ static int is_reserved_asid(u64 asid)
3750 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3751 {
3752 u64 asid = atomic64_read(&mm->context.id);
3753 - u64 generation = atomic64_read(&asid_generation);
3754 + u64 generation = atomic64_read_unchecked(&asid_generation);
3755
3756 if (asid != 0 && is_reserved_asid(asid)) {
3757 /*
3758 @@ -198,7 +198,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3759 */
3760 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3761 if (asid == NUM_USER_ASIDS) {
3762 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3763 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3764 &asid_generation);
3765 flush_context(cpu);
3766 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3767 @@ -227,14 +227,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3768 cpu_set_reserved_ttbr0();
3769
3770 asid = atomic64_read(&mm->context.id);
3771 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3772 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3773 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3774 goto switch_mm_fastpath;
3775
3776 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3777 /* Check that our ASID belongs to the current generation. */
3778 asid = atomic64_read(&mm->context.id);
3779 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3780 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3781 asid = new_context(mm, cpu);
3782 atomic64_set(&mm->context.id, asid);
3783 }
3784 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3785 index eb8830a..5360ce7 100644
3786 --- a/arch/arm/mm/fault.c
3787 +++ b/arch/arm/mm/fault.c
3788 @@ -25,6 +25,7 @@
3789 #include <asm/system_misc.h>
3790 #include <asm/system_info.h>
3791 #include <asm/tlbflush.h>
3792 +#include <asm/sections.h>
3793
3794 #include "fault.h"
3795
3796 @@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3797 if (fixup_exception(regs))
3798 return;
3799
3800 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3801 + if (addr < TASK_SIZE) {
3802 + if (current->signal->curr_ip)
3803 + 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),
3804 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3805 + else
3806 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3808 + }
3809 +#endif
3810 +
3811 +#ifdef CONFIG_PAX_KERNEXEC
3812 + if ((fsr & FSR_WRITE) &&
3813 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3814 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3815 + {
3816 + if (current->signal->curr_ip)
3817 + 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),
3818 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3819 + else
3820 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3821 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3822 + }
3823 +#endif
3824 +
3825 /*
3826 * No handler, we'll have to terminate things with extreme prejudice.
3827 */
3828 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3829 }
3830 #endif
3831
3832 +#ifdef CONFIG_PAX_PAGEEXEC
3833 + if (fsr & FSR_LNX_PF) {
3834 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3835 + do_group_exit(SIGKILL);
3836 + }
3837 +#endif
3838 +
3839 tsk->thread.address = addr;
3840 tsk->thread.error_code = fsr;
3841 tsk->thread.trap_no = 14;
3842 @@ -401,6 +434,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3843 }
3844 #endif /* CONFIG_MMU */
3845
3846 +#ifdef CONFIG_PAX_PAGEEXEC
3847 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3848 +{
3849 + long i;
3850 +
3851 + printk(KERN_ERR "PAX: bytes at PC: ");
3852 + for (i = 0; i < 20; i++) {
3853 + unsigned char c;
3854 + if (get_user(c, (__force unsigned char __user *)pc+i))
3855 + printk(KERN_CONT "?? ");
3856 + else
3857 + printk(KERN_CONT "%02x ", c);
3858 + }
3859 + printk("\n");
3860 +
3861 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3862 + for (i = -1; i < 20; i++) {
3863 + unsigned long c;
3864 + if (get_user(c, (__force unsigned long __user *)sp+i))
3865 + printk(KERN_CONT "???????? ");
3866 + else
3867 + printk(KERN_CONT "%08lx ", c);
3868 + }
3869 + printk("\n");
3870 +}
3871 +#endif
3872 +
3873 /*
3874 * First Level Translation Fault Handler
3875 *
3876 @@ -548,9 +608,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3877 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3878 struct siginfo info;
3879
3880 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3881 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3882 + if (current->signal->curr_ip)
3883 + 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),
3884 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3885 + else
3886 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3887 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3888 + goto die;
3889 + }
3890 +#endif
3891 +
3892 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3893 return;
3894
3895 +die:
3896 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3897 inf->name, fsr, addr);
3898
3899 @@ -574,15 +647,98 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3900 ifsr_info[nr].name = name;
3901 }
3902
3903 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3904 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3905 +
3906 asmlinkage void __exception
3907 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3908 {
3909 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3910 struct siginfo info;
3911 + unsigned long pc = instruction_pointer(regs);
3912 +
3913 + if (user_mode(regs)) {
3914 + unsigned long sigpage = current->mm->context.sigpage;
3915 +
3916 + if (sigpage <= pc && pc < sigpage + 7*4) {
3917 + if (pc < sigpage + 3*4)
3918 + sys_sigreturn(regs);
3919 + else
3920 + sys_rt_sigreturn(regs);
3921 + return;
3922 + }
3923 + if (pc == 0xffff0f60UL) {
3924 + /*
3925 + * PaX: __kuser_cmpxchg64 emulation
3926 + */
3927 + // TODO
3928 + //regs->ARM_pc = regs->ARM_lr;
3929 + //return;
3930 + }
3931 + if (pc == 0xffff0fa0UL) {
3932 + /*
3933 + * PaX: __kuser_memory_barrier emulation
3934 + */
3935 + // dmb(); implied by the exception
3936 + regs->ARM_pc = regs->ARM_lr;
3937 + return;
3938 + }
3939 + if (pc == 0xffff0fc0UL) {
3940 + /*
3941 + * PaX: __kuser_cmpxchg emulation
3942 + */
3943 + // TODO
3944 + //long new;
3945 + //int op;
3946 +
3947 + //op = FUTEX_OP_SET << 28;
3948 + //new = futex_atomic_op_inuser(op, regs->ARM_r2);
3949 + //regs->ARM_r0 = old != new;
3950 + //regs->ARM_pc = regs->ARM_lr;
3951 + //return;
3952 + }
3953 + if (pc == 0xffff0fe0UL) {
3954 + /*
3955 + * PaX: __kuser_get_tls emulation
3956 + */
3957 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3958 + regs->ARM_pc = regs->ARM_lr;
3959 + return;
3960 + }
3961 + }
3962 +
3963 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3964 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3965 + if (current->signal->curr_ip)
3966 + 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),
3967 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3968 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3969 + else
3970 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3971 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3972 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3973 + goto die;
3974 + }
3975 +#endif
3976 +
3977 +#ifdef CONFIG_PAX_REFCOUNT
3978 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3979 + unsigned int bkpt;
3980 +
3981 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3982 + current->thread.error_code = ifsr;
3983 + current->thread.trap_no = 0;
3984 + pax_report_refcount_overflow(regs);
3985 + fixup_exception(regs);
3986 + return;
3987 + }
3988 + }
3989 +#endif
3990
3991 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3992 return;
3993
3994 +die:
3995 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3996 inf->name, ifsr, addr);
3997
3998 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3999 index cf08bdf..772656c 100644
4000 --- a/arch/arm/mm/fault.h
4001 +++ b/arch/arm/mm/fault.h
4002 @@ -3,6 +3,7 @@
4003
4004 /*
4005 * Fault status register encodings. We steal bit 31 for our own purposes.
4006 + * Set when the FSR value is from an instruction fault.
4007 */
4008 #define FSR_LNX_PF (1 << 31)
4009 #define FSR_WRITE (1 << 11)
4010 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4011 }
4012 #endif
4013
4014 +/* valid for LPAE and !LPAE */
4015 +static inline int is_xn_fault(unsigned int fsr)
4016 +{
4017 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4018 +}
4019 +
4020 +static inline int is_domain_fault(unsigned int fsr)
4021 +{
4022 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4023 +}
4024 +
4025 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4026 unsigned long search_exception_table(unsigned long addr);
4027
4028 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4029 index 18ec4c5..479bb6a 100644
4030 --- a/arch/arm/mm/init.c
4031 +++ b/arch/arm/mm/init.c
4032 @@ -30,6 +30,8 @@
4033 #include <asm/setup.h>
4034 #include <asm/tlb.h>
4035 #include <asm/fixmap.h>
4036 +#include <asm/system_info.h>
4037 +#include <asm/cp15.h>
4038
4039 #include <asm/mach/arch.h>
4040 #include <asm/mach/map.h>
4041 @@ -684,7 +686,46 @@ void free_initmem(void)
4042 {
4043 #ifdef CONFIG_HAVE_TCM
4044 extern char __tcm_start, __tcm_end;
4045 +#endif
4046
4047 +#ifdef CONFIG_PAX_KERNEXEC
4048 + unsigned long addr;
4049 + pgd_t *pgd;
4050 + pud_t *pud;
4051 + pmd_t *pmd;
4052 + int cpu_arch = cpu_architecture();
4053 + unsigned int cr = get_cr();
4054 +
4055 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4056 + /* make pages tables, etc before .text NX */
4057 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4058 + pgd = pgd_offset_k(addr);
4059 + pud = pud_offset(pgd, addr);
4060 + pmd = pmd_offset(pud, addr);
4061 + __section_update(pmd, addr, PMD_SECT_XN);
4062 + }
4063 + /* make init NX */
4064 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4065 + pgd = pgd_offset_k(addr);
4066 + pud = pud_offset(pgd, addr);
4067 + pmd = pmd_offset(pud, addr);
4068 + __section_update(pmd, addr, PMD_SECT_XN);
4069 + }
4070 + /* make kernel code/rodata RX */
4071 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4072 + pgd = pgd_offset_k(addr);
4073 + pud = pud_offset(pgd, addr);
4074 + pmd = pmd_offset(pud, addr);
4075 +#ifdef CONFIG_ARM_LPAE
4076 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4077 +#else
4078 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4079 +#endif
4080 + }
4081 + }
4082 +#endif
4083 +
4084 +#ifdef CONFIG_HAVE_TCM
4085 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4086 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4087 #endif
4088 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4089 index f123d6e..04bf569 100644
4090 --- a/arch/arm/mm/ioremap.c
4091 +++ b/arch/arm/mm/ioremap.c
4092 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4093 unsigned int mtype;
4094
4095 if (cached)
4096 - mtype = MT_MEMORY;
4097 + mtype = MT_MEMORY_RX;
4098 else
4099 - mtype = MT_MEMORY_NONCACHED;
4100 + mtype = MT_MEMORY_NONCACHED_RX;
4101
4102 return __arm_ioremap_caller(phys_addr, size, mtype,
4103 __builtin_return_address(0));
4104 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4105 index 0c63562..7128a90 100644
4106 --- a/arch/arm/mm/mmap.c
4107 +++ b/arch/arm/mm/mmap.c
4108 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4109 struct vm_area_struct *vma;
4110 int do_align = 0;
4111 int aliasing = cache_is_vipt_aliasing();
4112 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4113 struct vm_unmapped_area_info info;
4114
4115 /*
4116 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4117 if (len > TASK_SIZE)
4118 return -ENOMEM;
4119
4120 +#ifdef CONFIG_PAX_RANDMMAP
4121 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4122 +#endif
4123 +
4124 if (addr) {
4125 if (do_align)
4126 addr = COLOUR_ALIGN(addr, pgoff);
4127 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4128 addr = PAGE_ALIGN(addr);
4129
4130 vma = find_vma(mm, addr);
4131 - if (TASK_SIZE - len >= addr &&
4132 - (!vma || addr + len <= vma->vm_start))
4133 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4134 return addr;
4135 }
4136
4137 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 info.high_limit = TASK_SIZE;
4139 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4140 info.align_offset = pgoff << PAGE_SHIFT;
4141 + info.threadstack_offset = offset;
4142 return vm_unmapped_area(&info);
4143 }
4144
4145 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4146 unsigned long addr = addr0;
4147 int do_align = 0;
4148 int aliasing = cache_is_vipt_aliasing();
4149 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4150 struct vm_unmapped_area_info info;
4151
4152 /*
4153 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4154 return addr;
4155 }
4156
4157 +#ifdef CONFIG_PAX_RANDMMAP
4158 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4159 +#endif
4160 +
4161 /* requesting a specific address */
4162 if (addr) {
4163 if (do_align)
4164 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4165 else
4166 addr = PAGE_ALIGN(addr);
4167 vma = find_vma(mm, addr);
4168 - if (TASK_SIZE - len >= addr &&
4169 - (!vma || addr + len <= vma->vm_start))
4170 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4171 return addr;
4172 }
4173
4174 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4175 info.high_limit = mm->mmap_base;
4176 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4177 info.align_offset = pgoff << PAGE_SHIFT;
4178 + info.threadstack_offset = offset;
4179 addr = vm_unmapped_area(&info);
4180
4181 /*
4182 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4183 {
4184 unsigned long random_factor = 0UL;
4185
4186 +#ifdef CONFIG_PAX_RANDMMAP
4187 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4188 +#endif
4189 +
4190 /* 8 bits of randomness in 20 address space bits */
4191 if ((current->flags & PF_RANDOMIZE) &&
4192 !(current->personality & ADDR_NO_RANDOMIZE))
4193 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4194
4195 if (mmap_is_legacy()) {
4196 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4197 +
4198 +#ifdef CONFIG_PAX_RANDMMAP
4199 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4200 + mm->mmap_base += mm->delta_mmap;
4201 +#endif
4202 +
4203 mm->get_unmapped_area = arch_get_unmapped_area;
4204 } else {
4205 mm->mmap_base = mmap_base(random_factor);
4206 +
4207 +#ifdef CONFIG_PAX_RANDMMAP
4208 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4209 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4210 +#endif
4211 +
4212 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4213 }
4214 }
4215 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4216 index b1d17ee..7a6f4d3 100644
4217 --- a/arch/arm/mm/mmu.c
4218 +++ b/arch/arm/mm/mmu.c
4219 @@ -36,6 +36,22 @@
4220 #include "mm.h"
4221 #include "tcm.h"
4222
4223 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4224 +void modify_domain(unsigned int dom, unsigned int type)
4225 +{
4226 + struct thread_info *thread = current_thread_info();
4227 + unsigned int domain = thread->cpu_domain;
4228 + /*
4229 + * DOMAIN_MANAGER might be defined to some other value,
4230 + * use the arch-defined constant
4231 + */
4232 + domain &= ~domain_val(dom, 3);
4233 + thread->cpu_domain = domain | domain_val(dom, type);
4234 + set_domain(thread->cpu_domain);
4235 +}
4236 +EXPORT_SYMBOL(modify_domain);
4237 +#endif
4238 +
4239 /*
4240 * empty_zero_page is a special page that is used for
4241 * zero-initialized data and COW.
4242 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4243
4244 #endif /* ifdef CONFIG_CPU_CP15 / else */
4245
4246 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4247 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4248 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4249
4250 -static struct mem_type mem_types[] = {
4251 +#ifdef CONFIG_PAX_KERNEXEC
4252 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4253 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4254 +#else
4255 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4256 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4257 +#endif
4258 +
4259 +static struct mem_type mem_types[] __read_only = {
4260 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4261 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4262 L_PTE_SHARED,
4263 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4264 [MT_UNCACHED] = {
4265 .prot_pte = PROT_PTE_DEVICE,
4266 .prot_l1 = PMD_TYPE_TABLE,
4267 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4268 + .prot_sect = PROT_SECT_DEVICE,
4269 .domain = DOMAIN_IO,
4270 },
4271 [MT_CACHECLEAN] = {
4272 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4273 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4274 .domain = DOMAIN_KERNEL,
4275 },
4276 #ifndef CONFIG_ARM_LPAE
4277 [MT_MINICLEAN] = {
4278 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4279 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4280 .domain = DOMAIN_KERNEL,
4281 },
4282 #endif
4283 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4284 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4285 L_PTE_RDONLY,
4286 .prot_l1 = PMD_TYPE_TABLE,
4287 - .domain = DOMAIN_USER,
4288 + .domain = DOMAIN_VECTORS,
4289 },
4290 [MT_HIGH_VECTORS] = {
4291 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4292 L_PTE_USER | L_PTE_RDONLY,
4293 .prot_l1 = PMD_TYPE_TABLE,
4294 - .domain = DOMAIN_USER,
4295 + .domain = DOMAIN_VECTORS,
4296 },
4297 - [MT_MEMORY] = {
4298 + [MT_MEMORY_RWX] = {
4299 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4300 .prot_l1 = PMD_TYPE_TABLE,
4301 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4302 .domain = DOMAIN_KERNEL,
4303 },
4304 + [MT_MEMORY_RW] = {
4305 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4306 + .prot_l1 = PMD_TYPE_TABLE,
4307 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4308 + .domain = DOMAIN_KERNEL,
4309 + },
4310 + [MT_MEMORY_RX] = {
4311 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4312 + .prot_l1 = PMD_TYPE_TABLE,
4313 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4314 + .domain = DOMAIN_KERNEL,
4315 + },
4316 [MT_ROM] = {
4317 - .prot_sect = PMD_TYPE_SECT,
4318 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4319 .domain = DOMAIN_KERNEL,
4320 },
4321 - [MT_MEMORY_NONCACHED] = {
4322 + [MT_MEMORY_NONCACHED_RW] = {
4323 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4324 L_PTE_MT_BUFFERABLE,
4325 .prot_l1 = PMD_TYPE_TABLE,
4326 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4327 .domain = DOMAIN_KERNEL,
4328 },
4329 + [MT_MEMORY_NONCACHED_RX] = {
4330 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4331 + L_PTE_MT_BUFFERABLE,
4332 + .prot_l1 = PMD_TYPE_TABLE,
4333 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4334 + .domain = DOMAIN_KERNEL,
4335 + },
4336 [MT_MEMORY_DTCM] = {
4337 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4338 - L_PTE_XN,
4339 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4340 .prot_l1 = PMD_TYPE_TABLE,
4341 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4342 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4343 .domain = DOMAIN_KERNEL,
4344 },
4345 [MT_MEMORY_ITCM] = {
4346 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4347 },
4348 [MT_MEMORY_SO] = {
4349 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4350 - L_PTE_MT_UNCACHED | L_PTE_XN,
4351 + L_PTE_MT_UNCACHED,
4352 .prot_l1 = PMD_TYPE_TABLE,
4353 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4354 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4355 + PMD_SECT_UNCACHED,
4356 .domain = DOMAIN_KERNEL,
4357 },
4358 [MT_MEMORY_DMA_READY] = {
4359 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4360 * to prevent speculative instruction fetches.
4361 */
4362 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4363 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4364 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4365 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4366 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4367 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4368 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4369 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4370 +
4371 + /* Mark other regions on ARMv6+ as execute-never */
4372 +
4373 +#ifdef CONFIG_PAX_KERNEXEC
4374 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4375 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4376 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4377 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4378 +#ifndef CONFIG_ARM_LPAE
4379 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4380 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4381 +#endif
4382 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4383 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4384 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4385 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4386 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4388 +#endif
4389 +
4390 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4391 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4392 }
4393 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4394 /*
4395 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4396 * from SVC mode and no access from userspace.
4397 */
4398 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4399 +#ifdef CONFIG_PAX_KERNEXEC
4400 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4401 +#endif
4402 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4403 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4404 #endif
4405 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4406 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4407 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4408 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4409 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4410 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4411 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4412 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4413 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4414 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4415 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4416 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4417 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4418 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4419 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4420 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4421 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4422 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4423 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4424 }
4425 }
4426
4427 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4428 if (cpu_arch >= CPU_ARCH_ARMv6) {
4429 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4430 /* Non-cacheable Normal is XCB = 001 */
4431 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4432 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4433 + PMD_SECT_BUFFERED;
4434 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4435 PMD_SECT_BUFFERED;
4436 } else {
4437 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4438 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4439 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4440 + PMD_SECT_TEX(1);
4441 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4442 PMD_SECT_TEX(1);
4443 }
4444 } else {
4445 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4446 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4447 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4448 }
4449
4450 #ifdef CONFIG_ARM_LPAE
4451 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4452 vecs_pgprot |= PTE_EXT_AF;
4453 #endif
4454
4455 + user_pgprot |= __supported_pte_mask;
4456 +
4457 for (i = 0; i < 16; i++) {
4458 pteval_t v = pgprot_val(protection_map[i]);
4459 protection_map[i] = __pgprot(v | user_pgprot);
4460 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4461
4462 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4463 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4464 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4465 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4466 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4467 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4468 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4469 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4470 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4471 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4472 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4473 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4474 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4475 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4476 mem_types[MT_ROM].prot_sect |= cp->pmd;
4477
4478 switch (cp->pmd) {
4479 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4480 * called function. This means you can't use any function or debugging
4481 * method which may touch any device, otherwise the kernel _will_ crash.
4482 */
4483 +
4484 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4485 +
4486 static void __init devicemaps_init(const struct machine_desc *mdesc)
4487 {
4488 struct map_desc map;
4489 unsigned long addr;
4490 - void *vectors;
4491
4492 - /*
4493 - * Allocate the vector page early.
4494 - */
4495 - vectors = early_alloc(PAGE_SIZE * 2);
4496 -
4497 - early_trap_init(vectors);
4498 + early_trap_init(&vectors);
4499
4500 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4501 pmd_clear(pmd_off_k(addr));
4502 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4503 * location (0xffff0000). If we aren't using high-vectors, also
4504 * create a mapping at the low-vectors virtual address.
4505 */
4506 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4507 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4508 map.virtual = 0xffff0000;
4509 map.length = PAGE_SIZE;
4510 #ifdef CONFIG_KUSER_HELPERS
4511 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4512 map.pfn = __phys_to_pfn(start);
4513 map.virtual = __phys_to_virt(start);
4514 map.length = end - start;
4515 - map.type = MT_MEMORY;
4516
4517 +#ifdef CONFIG_PAX_KERNEXEC
4518 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4519 + struct map_desc kernel;
4520 + struct map_desc initmap;
4521 +
4522 + /* when freeing initmem we will make this RW */
4523 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4524 + initmap.virtual = (unsigned long)__init_begin;
4525 + initmap.length = _sdata - __init_begin;
4526 + initmap.type = MT_MEMORY_RWX;
4527 + create_mapping(&initmap);
4528 +
4529 + /* when freeing initmem we will make this RX */
4530 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4531 + kernel.virtual = (unsigned long)_stext;
4532 + kernel.length = __init_begin - _stext;
4533 + kernel.type = MT_MEMORY_RWX;
4534 + create_mapping(&kernel);
4535 +
4536 + if (map.virtual < (unsigned long)_stext) {
4537 + map.length = (unsigned long)_stext - map.virtual;
4538 + map.type = MT_MEMORY_RWX;
4539 + create_mapping(&map);
4540 + }
4541 +
4542 + map.pfn = __phys_to_pfn(__pa(_sdata));
4543 + map.virtual = (unsigned long)_sdata;
4544 + map.length = end - __pa(_sdata);
4545 + }
4546 +#endif
4547 +
4548 + map.type = MT_MEMORY_RW;
4549 create_mapping(&map);
4550 }
4551 }
4552 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4553 index a5bc92d..0bb4730 100644
4554 --- a/arch/arm/plat-omap/sram.c
4555 +++ b/arch/arm/plat-omap/sram.c
4556 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4557 * Looks like we need to preserve some bootloader code at the
4558 * beginning of SRAM for jumping to flash for reboot to work...
4559 */
4560 + pax_open_kernel();
4561 memset_io(omap_sram_base + omap_sram_skip, 0,
4562 omap_sram_size - omap_sram_skip);
4563 + pax_close_kernel();
4564 }
4565 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4566 index ce6d763..cfea917 100644
4567 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4568 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4569 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4570 int (*started)(unsigned ch);
4571 int (*flush)(unsigned ch);
4572 int (*stop)(unsigned ch);
4573 -};
4574 +} __no_const;
4575
4576 extern void *samsung_dmadev_get_ops(void);
4577 extern void *s3c_dma_get_ops(void);
4578 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4579 index c3a58a1..78fbf54 100644
4580 --- a/arch/avr32/include/asm/cache.h
4581 +++ b/arch/avr32/include/asm/cache.h
4582 @@ -1,8 +1,10 @@
4583 #ifndef __ASM_AVR32_CACHE_H
4584 #define __ASM_AVR32_CACHE_H
4585
4586 +#include <linux/const.h>
4587 +
4588 #define L1_CACHE_SHIFT 5
4589 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4590 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4591
4592 /*
4593 * Memory returned by kmalloc() may be used for DMA, so we must make
4594 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4595 index d232888..87c8df1 100644
4596 --- a/arch/avr32/include/asm/elf.h
4597 +++ b/arch/avr32/include/asm/elf.h
4598 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4599 the loader. We need to make sure that it is out of the way of the program
4600 that it will "exec", and that there is sufficient room for the brk. */
4601
4602 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4603 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4604
4605 +#ifdef CONFIG_PAX_ASLR
4606 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4607 +
4608 +#define PAX_DELTA_MMAP_LEN 15
4609 +#define PAX_DELTA_STACK_LEN 15
4610 +#endif
4611
4612 /* This yields a mask that user programs can use to figure out what
4613 instruction set this CPU supports. This could be done in user space,
4614 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4615 index 479330b..53717a8 100644
4616 --- a/arch/avr32/include/asm/kmap_types.h
4617 +++ b/arch/avr32/include/asm/kmap_types.h
4618 @@ -2,9 +2,9 @@
4619 #define __ASM_AVR32_KMAP_TYPES_H
4620
4621 #ifdef CONFIG_DEBUG_HIGHMEM
4622 -# define KM_TYPE_NR 29
4623 +# define KM_TYPE_NR 30
4624 #else
4625 -# define KM_TYPE_NR 14
4626 +# define KM_TYPE_NR 15
4627 #endif
4628
4629 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4630 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4631 index 0eca933..eb78c7b 100644
4632 --- a/arch/avr32/mm/fault.c
4633 +++ b/arch/avr32/mm/fault.c
4634 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4635
4636 int exception_trace = 1;
4637
4638 +#ifdef CONFIG_PAX_PAGEEXEC
4639 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4640 +{
4641 + unsigned long i;
4642 +
4643 + printk(KERN_ERR "PAX: bytes at PC: ");
4644 + for (i = 0; i < 20; i++) {
4645 + unsigned char c;
4646 + if (get_user(c, (unsigned char *)pc+i))
4647 + printk(KERN_CONT "???????? ");
4648 + else
4649 + printk(KERN_CONT "%02x ", c);
4650 + }
4651 + printk("\n");
4652 +}
4653 +#endif
4654 +
4655 /*
4656 * This routine handles page faults. It determines the address and the
4657 * problem, and then passes it off to one of the appropriate routines.
4658 @@ -176,6 +193,16 @@ bad_area:
4659 up_read(&mm->mmap_sem);
4660
4661 if (user_mode(regs)) {
4662 +
4663 +#ifdef CONFIG_PAX_PAGEEXEC
4664 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4665 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4666 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4667 + do_group_exit(SIGKILL);
4668 + }
4669 + }
4670 +#endif
4671 +
4672 if (exception_trace && printk_ratelimit())
4673 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4674 "sp %08lx ecr %lu\n",
4675 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4676 index 568885a..f8008df 100644
4677 --- a/arch/blackfin/include/asm/cache.h
4678 +++ b/arch/blackfin/include/asm/cache.h
4679 @@ -7,6 +7,7 @@
4680 #ifndef __ARCH_BLACKFIN_CACHE_H
4681 #define __ARCH_BLACKFIN_CACHE_H
4682
4683 +#include <linux/const.h>
4684 #include <linux/linkage.h> /* for asmlinkage */
4685
4686 /*
4687 @@ -14,7 +15,7 @@
4688 * Blackfin loads 32 bytes for cache
4689 */
4690 #define L1_CACHE_SHIFT 5
4691 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4692 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4693 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4694
4695 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4696 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4697 index aea2718..3639a60 100644
4698 --- a/arch/cris/include/arch-v10/arch/cache.h
4699 +++ b/arch/cris/include/arch-v10/arch/cache.h
4700 @@ -1,8 +1,9 @@
4701 #ifndef _ASM_ARCH_CACHE_H
4702 #define _ASM_ARCH_CACHE_H
4703
4704 +#include <linux/const.h>
4705 /* Etrax 100LX have 32-byte cache-lines. */
4706 -#define L1_CACHE_BYTES 32
4707 #define L1_CACHE_SHIFT 5
4708 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4709
4710 #endif /* _ASM_ARCH_CACHE_H */
4711 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4712 index 7caf25d..ee65ac5 100644
4713 --- a/arch/cris/include/arch-v32/arch/cache.h
4714 +++ b/arch/cris/include/arch-v32/arch/cache.h
4715 @@ -1,11 +1,12 @@
4716 #ifndef _ASM_CRIS_ARCH_CACHE_H
4717 #define _ASM_CRIS_ARCH_CACHE_H
4718
4719 +#include <linux/const.h>
4720 #include <arch/hwregs/dma.h>
4721
4722 /* A cache-line is 32 bytes. */
4723 -#define L1_CACHE_BYTES 32
4724 #define L1_CACHE_SHIFT 5
4725 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4726
4727 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4728
4729 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4730 index b86329d..6709906 100644
4731 --- a/arch/frv/include/asm/atomic.h
4732 +++ b/arch/frv/include/asm/atomic.h
4733 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4734 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4735 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4736
4737 +#define atomic64_read_unchecked(v) atomic64_read(v)
4738 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4739 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4740 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4741 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4742 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4743 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4744 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4745 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4746 +
4747 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4748 {
4749 int c, old;
4750 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4751 index 2797163..c2a401d 100644
4752 --- a/arch/frv/include/asm/cache.h
4753 +++ b/arch/frv/include/asm/cache.h
4754 @@ -12,10 +12,11 @@
4755 #ifndef __ASM_CACHE_H
4756 #define __ASM_CACHE_H
4757
4758 +#include <linux/const.h>
4759
4760 /* bytes per L1 cache line */
4761 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4762 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4763 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4764
4765 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4766 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4767 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4768 index 43901f2..0d8b865 100644
4769 --- a/arch/frv/include/asm/kmap_types.h
4770 +++ b/arch/frv/include/asm/kmap_types.h
4771 @@ -2,6 +2,6 @@
4772 #ifndef _ASM_KMAP_TYPES_H
4773 #define _ASM_KMAP_TYPES_H
4774
4775 -#define KM_TYPE_NR 17
4776 +#define KM_TYPE_NR 18
4777
4778 #endif
4779 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4780 index 836f147..4cf23f5 100644
4781 --- a/arch/frv/mm/elf-fdpic.c
4782 +++ b/arch/frv/mm/elf-fdpic.c
4783 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4784 {
4785 struct vm_area_struct *vma;
4786 struct vm_unmapped_area_info info;
4787 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4788
4789 if (len > TASK_SIZE)
4790 return -ENOMEM;
4791 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4792 if (addr) {
4793 addr = PAGE_ALIGN(addr);
4794 vma = find_vma(current->mm, addr);
4795 - if (TASK_SIZE - len >= addr &&
4796 - (!vma || addr + len <= vma->vm_start))
4797 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4798 goto success;
4799 }
4800
4801 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4802 info.high_limit = (current->mm->start_stack - 0x00200000);
4803 info.align_mask = 0;
4804 info.align_offset = 0;
4805 + info.threadstack_offset = offset;
4806 addr = vm_unmapped_area(&info);
4807 if (!(addr & ~PAGE_MASK))
4808 goto success;
4809 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4810 index f4ca594..adc72fd6 100644
4811 --- a/arch/hexagon/include/asm/cache.h
4812 +++ b/arch/hexagon/include/asm/cache.h
4813 @@ -21,9 +21,11 @@
4814 #ifndef __ASM_CACHE_H
4815 #define __ASM_CACHE_H
4816
4817 +#include <linux/const.h>
4818 +
4819 /* Bytes per L1 cache line */
4820 -#define L1_CACHE_SHIFT (5)
4821 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4822 +#define L1_CACHE_SHIFT 5
4823 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4824
4825 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4826 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4827 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4828 index 6e6fe18..a6ae668 100644
4829 --- a/arch/ia64/include/asm/atomic.h
4830 +++ b/arch/ia64/include/asm/atomic.h
4831 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4832 #define atomic64_inc(v) atomic64_add(1, (v))
4833 #define atomic64_dec(v) atomic64_sub(1, (v))
4834
4835 +#define atomic64_read_unchecked(v) atomic64_read(v)
4836 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4837 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4838 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4839 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4840 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4841 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4842 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4843 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4844 +
4845 /* Atomic operations are already serializing */
4846 #define smp_mb__before_atomic_dec() barrier()
4847 #define smp_mb__after_atomic_dec() barrier()
4848 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4849 index 988254a..e1ee885 100644
4850 --- a/arch/ia64/include/asm/cache.h
4851 +++ b/arch/ia64/include/asm/cache.h
4852 @@ -1,6 +1,7 @@
4853 #ifndef _ASM_IA64_CACHE_H
4854 #define _ASM_IA64_CACHE_H
4855
4856 +#include <linux/const.h>
4857
4858 /*
4859 * Copyright (C) 1998-2000 Hewlett-Packard Co
4860 @@ -9,7 +10,7 @@
4861
4862 /* Bytes per L1 (data) cache line. */
4863 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4864 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4865 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4866
4867 #ifdef CONFIG_SMP
4868 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4869 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4870 index 5a83c5c..4d7f553 100644
4871 --- a/arch/ia64/include/asm/elf.h
4872 +++ b/arch/ia64/include/asm/elf.h
4873 @@ -42,6 +42,13 @@
4874 */
4875 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4876
4877 +#ifdef CONFIG_PAX_ASLR
4878 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4879 +
4880 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4881 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4882 +#endif
4883 +
4884 #define PT_IA_64_UNWIND 0x70000001
4885
4886 /* IA-64 relocations: */
4887 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4888 index 96a8d92..617a1cf 100644
4889 --- a/arch/ia64/include/asm/pgalloc.h
4890 +++ b/arch/ia64/include/asm/pgalloc.h
4891 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4892 pgd_val(*pgd_entry) = __pa(pud);
4893 }
4894
4895 +static inline void
4896 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4897 +{
4898 + pgd_populate(mm, pgd_entry, pud);
4899 +}
4900 +
4901 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4902 {
4903 return quicklist_alloc(0, GFP_KERNEL, NULL);
4904 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4905 pud_val(*pud_entry) = __pa(pmd);
4906 }
4907
4908 +static inline void
4909 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4910 +{
4911 + pud_populate(mm, pud_entry, pmd);
4912 +}
4913 +
4914 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4915 {
4916 return quicklist_alloc(0, GFP_KERNEL, NULL);
4917 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4918 index 7935115..c0eca6a 100644
4919 --- a/arch/ia64/include/asm/pgtable.h
4920 +++ b/arch/ia64/include/asm/pgtable.h
4921 @@ -12,7 +12,7 @@
4922 * David Mosberger-Tang <davidm@hpl.hp.com>
4923 */
4924
4925 -
4926 +#include <linux/const.h>
4927 #include <asm/mman.h>
4928 #include <asm/page.h>
4929 #include <asm/processor.h>
4930 @@ -142,6 +142,17 @@
4931 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4932 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4933 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4934 +
4935 +#ifdef CONFIG_PAX_PAGEEXEC
4936 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4937 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4938 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4939 +#else
4940 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4941 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4942 +# define PAGE_COPY_NOEXEC PAGE_COPY
4943 +#endif
4944 +
4945 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4946 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4947 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4948 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4949 index 45698cd..e8e2dbc 100644
4950 --- a/arch/ia64/include/asm/spinlock.h
4951 +++ b/arch/ia64/include/asm/spinlock.h
4952 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4953 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4954
4955 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4956 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4957 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4958 }
4959
4960 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4961 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4962 index 449c8c0..18965fb 100644
4963 --- a/arch/ia64/include/asm/uaccess.h
4964 +++ b/arch/ia64/include/asm/uaccess.h
4965 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4966 static inline unsigned long
4967 __copy_to_user (void __user *to, const void *from, unsigned long count)
4968 {
4969 + if (count > INT_MAX)
4970 + return count;
4971 +
4972 + if (!__builtin_constant_p(count))
4973 + check_object_size(from, count, true);
4974 +
4975 return __copy_user(to, (__force void __user *) from, count);
4976 }
4977
4978 static inline unsigned long
4979 __copy_from_user (void *to, const void __user *from, unsigned long count)
4980 {
4981 + if (count > INT_MAX)
4982 + return count;
4983 +
4984 + if (!__builtin_constant_p(count))
4985 + check_object_size(to, count, false);
4986 +
4987 return __copy_user((__force void __user *) to, from, count);
4988 }
4989
4990 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4991 ({ \
4992 void __user *__cu_to = (to); \
4993 const void *__cu_from = (from); \
4994 - long __cu_len = (n); \
4995 + unsigned long __cu_len = (n); \
4996 \
4997 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4998 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4999 + if (!__builtin_constant_p(n)) \
5000 + check_object_size(__cu_from, __cu_len, true); \
5001 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5002 + } \
5003 __cu_len; \
5004 })
5005
5006 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5007 ({ \
5008 void *__cu_to = (to); \
5009 const void __user *__cu_from = (from); \
5010 - long __cu_len = (n); \
5011 + unsigned long __cu_len = (n); \
5012 \
5013 __chk_user_ptr(__cu_from); \
5014 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5015 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5016 + if (!__builtin_constant_p(n)) \
5017 + check_object_size(__cu_to, __cu_len, false); \
5018 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5019 + } \
5020 __cu_len; \
5021 })
5022
5023 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5024 index 24603be..948052d 100644
5025 --- a/arch/ia64/kernel/module.c
5026 +++ b/arch/ia64/kernel/module.c
5027 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5028 void
5029 module_free (struct module *mod, void *module_region)
5030 {
5031 - if (mod && mod->arch.init_unw_table &&
5032 - module_region == mod->module_init) {
5033 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5034 unw_remove_unwind_table(mod->arch.init_unw_table);
5035 mod->arch.init_unw_table = NULL;
5036 }
5037 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5038 }
5039
5040 static inline int
5041 +in_init_rx (const struct module *mod, uint64_t addr)
5042 +{
5043 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5044 +}
5045 +
5046 +static inline int
5047 +in_init_rw (const struct module *mod, uint64_t addr)
5048 +{
5049 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5050 +}
5051 +
5052 +static inline int
5053 in_init (const struct module *mod, uint64_t addr)
5054 {
5055 - return addr - (uint64_t) mod->module_init < mod->init_size;
5056 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5057 +}
5058 +
5059 +static inline int
5060 +in_core_rx (const struct module *mod, uint64_t addr)
5061 +{
5062 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5063 +}
5064 +
5065 +static inline int
5066 +in_core_rw (const struct module *mod, uint64_t addr)
5067 +{
5068 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5069 }
5070
5071 static inline int
5072 in_core (const struct module *mod, uint64_t addr)
5073 {
5074 - return addr - (uint64_t) mod->module_core < mod->core_size;
5075 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5076 }
5077
5078 static inline int
5079 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5080 break;
5081
5082 case RV_BDREL:
5083 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5084 + if (in_init_rx(mod, val))
5085 + val -= (uint64_t) mod->module_init_rx;
5086 + else if (in_init_rw(mod, val))
5087 + val -= (uint64_t) mod->module_init_rw;
5088 + else if (in_core_rx(mod, val))
5089 + val -= (uint64_t) mod->module_core_rx;
5090 + else if (in_core_rw(mod, val))
5091 + val -= (uint64_t) mod->module_core_rw;
5092 break;
5093
5094 case RV_LTV:
5095 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5096 * addresses have been selected...
5097 */
5098 uint64_t gp;
5099 - if (mod->core_size > MAX_LTOFF)
5100 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5101 /*
5102 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5103 * at the end of the module.
5104 */
5105 - gp = mod->core_size - MAX_LTOFF / 2;
5106 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5107 else
5108 - gp = mod->core_size / 2;
5109 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5110 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5111 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5112 mod->arch.gp = gp;
5113 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5114 }
5115 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5116 index ab33328..f39506c 100644
5117 --- a/arch/ia64/kernel/palinfo.c
5118 +++ b/arch/ia64/kernel/palinfo.c
5119 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5120 return NOTIFY_OK;
5121 }
5122
5123 -static struct notifier_block __refdata palinfo_cpu_notifier =
5124 +static struct notifier_block palinfo_cpu_notifier =
5125 {
5126 .notifier_call = palinfo_cpu_callback,
5127 .priority = 0,
5128 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5129 index 41e33f8..65180b2 100644
5130 --- a/arch/ia64/kernel/sys_ia64.c
5131 +++ b/arch/ia64/kernel/sys_ia64.c
5132 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5133 unsigned long align_mask = 0;
5134 struct mm_struct *mm = current->mm;
5135 struct vm_unmapped_area_info info;
5136 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5137
5138 if (len > RGN_MAP_LIMIT)
5139 return -ENOMEM;
5140 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5141 if (REGION_NUMBER(addr) == RGN_HPAGE)
5142 addr = 0;
5143 #endif
5144 +
5145 +#ifdef CONFIG_PAX_RANDMMAP
5146 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5147 + addr = mm->free_area_cache;
5148 + else
5149 +#endif
5150 +
5151 if (!addr)
5152 addr = TASK_UNMAPPED_BASE;
5153
5154 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5155 info.high_limit = TASK_SIZE;
5156 info.align_mask = align_mask;
5157 info.align_offset = 0;
5158 + info.threadstack_offset = offset;
5159 return vm_unmapped_area(&info);
5160 }
5161
5162 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5163 index 0ccb28f..8992469 100644
5164 --- a/arch/ia64/kernel/vmlinux.lds.S
5165 +++ b/arch/ia64/kernel/vmlinux.lds.S
5166 @@ -198,7 +198,7 @@ SECTIONS {
5167 /* Per-cpu data: */
5168 . = ALIGN(PERCPU_PAGE_SIZE);
5169 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5170 - __phys_per_cpu_start = __per_cpu_load;
5171 + __phys_per_cpu_start = per_cpu_load;
5172 /*
5173 * ensure percpu data fits
5174 * into percpu page size
5175 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5176 index 7225dad..2a7c8256 100644
5177 --- a/arch/ia64/mm/fault.c
5178 +++ b/arch/ia64/mm/fault.c
5179 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5180 return pte_present(pte);
5181 }
5182
5183 +#ifdef CONFIG_PAX_PAGEEXEC
5184 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5185 +{
5186 + unsigned long i;
5187 +
5188 + printk(KERN_ERR "PAX: bytes at PC: ");
5189 + for (i = 0; i < 8; i++) {
5190 + unsigned int c;
5191 + if (get_user(c, (unsigned int *)pc+i))
5192 + printk(KERN_CONT "???????? ");
5193 + else
5194 + printk(KERN_CONT "%08x ", c);
5195 + }
5196 + printk("\n");
5197 +}
5198 +#endif
5199 +
5200 # define VM_READ_BIT 0
5201 # define VM_WRITE_BIT 1
5202 # define VM_EXEC_BIT 2
5203 @@ -151,8 +168,21 @@ retry:
5204 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5205 goto bad_area;
5206
5207 - if ((vma->vm_flags & mask) != mask)
5208 + if ((vma->vm_flags & mask) != mask) {
5209 +
5210 +#ifdef CONFIG_PAX_PAGEEXEC
5211 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5212 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5213 + goto bad_area;
5214 +
5215 + up_read(&mm->mmap_sem);
5216 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5217 + do_group_exit(SIGKILL);
5218 + }
5219 +#endif
5220 +
5221 goto bad_area;
5222 + }
5223
5224 /*
5225 * If for any reason at all we couldn't handle the fault, make
5226 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5227 index 68232db..6ca80af 100644
5228 --- a/arch/ia64/mm/hugetlbpage.c
5229 +++ b/arch/ia64/mm/hugetlbpage.c
5230 @@ -154,6 +154,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5231 unsigned long pgoff, unsigned long flags)
5232 {
5233 struct vm_unmapped_area_info info;
5234 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5235
5236 if (len > RGN_MAP_LIMIT)
5237 return -ENOMEM;
5238 @@ -177,6 +178,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5239 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5240 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5241 info.align_offset = 0;
5242 + info.threadstack_offset = offset;
5243 return vm_unmapped_area(&info);
5244 }
5245
5246 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5247 index b6f7f43..c04320d 100644
5248 --- a/arch/ia64/mm/init.c
5249 +++ b/arch/ia64/mm/init.c
5250 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5251 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5252 vma->vm_end = vma->vm_start + PAGE_SIZE;
5253 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5254 +
5255 +#ifdef CONFIG_PAX_PAGEEXEC
5256 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5257 + vma->vm_flags &= ~VM_EXEC;
5258 +
5259 +#ifdef CONFIG_PAX_MPROTECT
5260 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5261 + vma->vm_flags &= ~VM_MAYEXEC;
5262 +#endif
5263 +
5264 + }
5265 +#endif
5266 +
5267 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5268 down_write(&current->mm->mmap_sem);
5269 if (insert_vm_struct(current->mm, vma)) {
5270 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5271 index 40b3ee9..8c2c112 100644
5272 --- a/arch/m32r/include/asm/cache.h
5273 +++ b/arch/m32r/include/asm/cache.h
5274 @@ -1,8 +1,10 @@
5275 #ifndef _ASM_M32R_CACHE_H
5276 #define _ASM_M32R_CACHE_H
5277
5278 +#include <linux/const.h>
5279 +
5280 /* L1 cache line size */
5281 #define L1_CACHE_SHIFT 4
5282 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5283 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5284
5285 #endif /* _ASM_M32R_CACHE_H */
5286 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5287 index 82abd15..d95ae5d 100644
5288 --- a/arch/m32r/lib/usercopy.c
5289 +++ b/arch/m32r/lib/usercopy.c
5290 @@ -14,6 +14,9 @@
5291 unsigned long
5292 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5293 {
5294 + if ((long)n < 0)
5295 + return n;
5296 +
5297 prefetch(from);
5298 if (access_ok(VERIFY_WRITE, to, n))
5299 __copy_user(to,from,n);
5300 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5301 unsigned long
5302 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5303 {
5304 + if ((long)n < 0)
5305 + return n;
5306 +
5307 prefetchw(to);
5308 if (access_ok(VERIFY_READ, from, n))
5309 __copy_user_zeroing(to,from,n);
5310 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5311 index 0395c51..5f26031 100644
5312 --- a/arch/m68k/include/asm/cache.h
5313 +++ b/arch/m68k/include/asm/cache.h
5314 @@ -4,9 +4,11 @@
5315 #ifndef __ARCH_M68K_CACHE_H
5316 #define __ARCH_M68K_CACHE_H
5317
5318 +#include <linux/const.h>
5319 +
5320 /* bytes per L1 cache line */
5321 #define L1_CACHE_SHIFT 4
5322 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5323 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5324
5325 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5326
5327 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5328 index 0424315..defcca9 100644
5329 --- a/arch/metag/mm/hugetlbpage.c
5330 +++ b/arch/metag/mm/hugetlbpage.c
5331 @@ -205,6 +205,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5332 info.high_limit = TASK_SIZE;
5333 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5334 info.align_offset = 0;
5335 + info.threadstack_offset = 0;
5336 return vm_unmapped_area(&info);
5337 }
5338
5339 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5340 index 4efe96a..60e8699 100644
5341 --- a/arch/microblaze/include/asm/cache.h
5342 +++ b/arch/microblaze/include/asm/cache.h
5343 @@ -13,11 +13,12 @@
5344 #ifndef _ASM_MICROBLAZE_CACHE_H
5345 #define _ASM_MICROBLAZE_CACHE_H
5346
5347 +#include <linux/const.h>
5348 #include <asm/registers.h>
5349
5350 #define L1_CACHE_SHIFT 5
5351 /* word-granular cache in microblaze */
5352 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5353 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5354
5355 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5356
5357 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5358 index 08b6079..8b554d2 100644
5359 --- a/arch/mips/include/asm/atomic.h
5360 +++ b/arch/mips/include/asm/atomic.h
5361 @@ -21,15 +21,39 @@
5362 #include <asm/cmpxchg.h>
5363 #include <asm/war.h>
5364
5365 +#ifdef CONFIG_GENERIC_ATOMIC64
5366 +#include <asm-generic/atomic64.h>
5367 +#endif
5368 +
5369 #define ATOMIC_INIT(i) { (i) }
5370
5371 +#ifdef CONFIG_64BIT
5372 +#define _ASM_EXTABLE(from, to) \
5373 +" .section __ex_table,\"a\"\n" \
5374 +" .dword " #from ", " #to"\n" \
5375 +" .previous\n"
5376 +#else
5377 +#define _ASM_EXTABLE(from, to) \
5378 +" .section __ex_table,\"a\"\n" \
5379 +" .word " #from ", " #to"\n" \
5380 +" .previous\n"
5381 +#endif
5382 +
5383 /*
5384 * atomic_read - read atomic variable
5385 * @v: pointer of type atomic_t
5386 *
5387 * Atomically reads the value of @v.
5388 */
5389 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5390 +static inline int atomic_read(const atomic_t *v)
5391 +{
5392 + return (*(volatile const int *) &v->counter);
5393 +}
5394 +
5395 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5396 +{
5397 + return (*(volatile const int *) &v->counter);
5398 +}
5399
5400 /*
5401 * atomic_set - set atomic variable
5402 @@ -38,7 +62,15 @@
5403 *
5404 * Atomically sets the value of @v to @i.
5405 */
5406 -#define atomic_set(v, i) ((v)->counter = (i))
5407 +static inline void atomic_set(atomic_t *v, int i)
5408 +{
5409 + v->counter = i;
5410 +}
5411 +
5412 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5413 +{
5414 + v->counter = i;
5415 +}
5416
5417 /*
5418 * atomic_add - add integer to atomic variable
5419 @@ -47,7 +79,67 @@
5420 *
5421 * Atomically adds @i to @v.
5422 */
5423 -static __inline__ void atomic_add(int i, atomic_t * v)
5424 +static __inline__ void atomic_add(int i, atomic_t *v)
5425 +{
5426 + int temp;
5427 +
5428 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5429 + __asm__ __volatile__(
5430 + " .set mips3 \n"
5431 + "1: ll %0, %1 # atomic_add \n"
5432 +#ifdef CONFIG_PAX_REFCOUNT
5433 + /* Exception on overflow. */
5434 + "2: add %0, %2 \n"
5435 +#else
5436 + " addu %0, %2 \n"
5437 +#endif
5438 + " sc %0, %1 \n"
5439 + " beqzl %0, 1b \n"
5440 +#ifdef CONFIG_PAX_REFCOUNT
5441 + "3: \n"
5442 + _ASM_EXTABLE(2b, 3b)
5443 +#endif
5444 + " .set mips0 \n"
5445 + : "=&r" (temp), "+m" (v->counter)
5446 + : "Ir" (i));
5447 + } else if (kernel_uses_llsc) {
5448 + __asm__ __volatile__(
5449 + " .set mips3 \n"
5450 + "1: ll %0, %1 # atomic_add \n"
5451 +#ifdef CONFIG_PAX_REFCOUNT
5452 + /* Exception on overflow. */
5453 + "2: add %0, %2 \n"
5454 +#else
5455 + " addu %0, %2 \n"
5456 +#endif
5457 + " sc %0, %1 \n"
5458 + " beqz %0, 1b \n"
5459 +#ifdef CONFIG_PAX_REFCOUNT
5460 + "3: \n"
5461 + _ASM_EXTABLE(2b, 3b)
5462 +#endif
5463 + " .set mips0 \n"
5464 + : "=&r" (temp), "+m" (v->counter)
5465 + : "Ir" (i));
5466 + } else {
5467 + unsigned long flags;
5468 +
5469 + raw_local_irq_save(flags);
5470 + __asm__ __volatile__(
5471 +#ifdef CONFIG_PAX_REFCOUNT
5472 + /* Exception on overflow. */
5473 + "1: add %0, %1 \n"
5474 + "2: \n"
5475 + _ASM_EXTABLE(1b, 2b)
5476 +#else
5477 + " addu %0, %1 \n"
5478 +#endif
5479 + : "+r" (v->counter) : "Ir" (i));
5480 + raw_local_irq_restore(flags);
5481 + }
5482 +}
5483 +
5484 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5485 {
5486 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5487 int temp;
5488 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5489 *
5490 * Atomically subtracts @i from @v.
5491 */
5492 -static __inline__ void atomic_sub(int i, atomic_t * v)
5493 +static __inline__ void atomic_sub(int i, atomic_t *v)
5494 +{
5495 + int temp;
5496 +
5497 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5498 + __asm__ __volatile__(
5499 + " .set mips3 \n"
5500 + "1: ll %0, %1 # atomic64_sub \n"
5501 +#ifdef CONFIG_PAX_REFCOUNT
5502 + /* Exception on overflow. */
5503 + "2: sub %0, %2 \n"
5504 +#else
5505 + " subu %0, %2 \n"
5506 +#endif
5507 + " sc %0, %1 \n"
5508 + " beqzl %0, 1b \n"
5509 +#ifdef CONFIG_PAX_REFCOUNT
5510 + "3: \n"
5511 + _ASM_EXTABLE(2b, 3b)
5512 +#endif
5513 + " .set mips0 \n"
5514 + : "=&r" (temp), "+m" (v->counter)
5515 + : "Ir" (i));
5516 + } else if (kernel_uses_llsc) {
5517 + __asm__ __volatile__(
5518 + " .set mips3 \n"
5519 + "1: ll %0, %1 # atomic64_sub \n"
5520 +#ifdef CONFIG_PAX_REFCOUNT
5521 + /* Exception on overflow. */
5522 + "2: sub %0, %2 \n"
5523 +#else
5524 + " subu %0, %2 \n"
5525 +#endif
5526 + " sc %0, %1 \n"
5527 + " beqz %0, 1b \n"
5528 +#ifdef CONFIG_PAX_REFCOUNT
5529 + "3: \n"
5530 + _ASM_EXTABLE(2b, 3b)
5531 +#endif
5532 + " .set mips0 \n"
5533 + : "=&r" (temp), "+m" (v->counter)
5534 + : "Ir" (i));
5535 + } else {
5536 + unsigned long flags;
5537 +
5538 + raw_local_irq_save(flags);
5539 + __asm__ __volatile__(
5540 +#ifdef CONFIG_PAX_REFCOUNT
5541 + /* Exception on overflow. */
5542 + "1: sub %0, %1 \n"
5543 + "2: \n"
5544 + _ASM_EXTABLE(1b, 2b)
5545 +#else
5546 + " subu %0, %1 \n"
5547 +#endif
5548 + : "+r" (v->counter) : "Ir" (i));
5549 + raw_local_irq_restore(flags);
5550 + }
5551 +}
5552 +
5553 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5554 {
5555 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5556 int temp;
5557 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5558 /*
5559 * Same as above, but return the result value
5560 */
5561 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5562 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5563 +{
5564 + int result;
5565 + int temp;
5566 +
5567 + smp_mb__before_llsc();
5568 +
5569 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5570 + __asm__ __volatile__(
5571 + " .set mips3 \n"
5572 + "1: ll %1, %2 # atomic_add_return \n"
5573 +#ifdef CONFIG_PAX_REFCOUNT
5574 + "2: add %0, %1, %3 \n"
5575 +#else
5576 + " addu %0, %1, %3 \n"
5577 +#endif
5578 + " sc %0, %2 \n"
5579 + " beqzl %0, 1b \n"
5580 +#ifdef CONFIG_PAX_REFCOUNT
5581 + " b 4f \n"
5582 + " .set noreorder \n"
5583 + "3: b 5f \n"
5584 + " move %0, %1 \n"
5585 + " .set reorder \n"
5586 + _ASM_EXTABLE(2b, 3b)
5587 +#endif
5588 + "4: addu %0, %1, %3 \n"
5589 +#ifdef CONFIG_PAX_REFCOUNT
5590 + "5: \n"
5591 +#endif
5592 + " .set mips0 \n"
5593 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5594 + : "Ir" (i));
5595 + } else if (kernel_uses_llsc) {
5596 + __asm__ __volatile__(
5597 + " .set mips3 \n"
5598 + "1: ll %1, %2 # atomic_add_return \n"
5599 +#ifdef CONFIG_PAX_REFCOUNT
5600 + "2: add %0, %1, %3 \n"
5601 +#else
5602 + " addu %0, %1, %3 \n"
5603 +#endif
5604 + " sc %0, %2 \n"
5605 + " bnez %0, 4f \n"
5606 + " b 1b \n"
5607 +#ifdef CONFIG_PAX_REFCOUNT
5608 + " .set noreorder \n"
5609 + "3: b 5f \n"
5610 + " move %0, %1 \n"
5611 + " .set reorder \n"
5612 + _ASM_EXTABLE(2b, 3b)
5613 +#endif
5614 + "4: addu %0, %1, %3 \n"
5615 +#ifdef CONFIG_PAX_REFCOUNT
5616 + "5: \n"
5617 +#endif
5618 + " .set mips0 \n"
5619 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5620 + : "Ir" (i));
5621 + } else {
5622 + unsigned long flags;
5623 +
5624 + raw_local_irq_save(flags);
5625 + __asm__ __volatile__(
5626 + " lw %0, %1 \n"
5627 +#ifdef CONFIG_PAX_REFCOUNT
5628 + /* Exception on overflow. */
5629 + "1: add %0, %2 \n"
5630 +#else
5631 + " addu %0, %2 \n"
5632 +#endif
5633 + " sw %0, %1 \n"
5634 +#ifdef CONFIG_PAX_REFCOUNT
5635 + /* Note: Dest reg is not modified on overflow */
5636 + "2: \n"
5637 + _ASM_EXTABLE(1b, 2b)
5638 +#endif
5639 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5640 + raw_local_irq_restore(flags);
5641 + }
5642 +
5643 + smp_llsc_mb();
5644 +
5645 + return result;
5646 +}
5647 +
5648 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5649 {
5650 int result;
5651
5652 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5653 return result;
5654 }
5655
5656 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5657 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5658 +{
5659 + int result;
5660 + int temp;
5661 +
5662 + smp_mb__before_llsc();
5663 +
5664 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5665 + __asm__ __volatile__(
5666 + " .set mips3 \n"
5667 + "1: ll %1, %2 # atomic_sub_return \n"
5668 +#ifdef CONFIG_PAX_REFCOUNT
5669 + "2: sub %0, %1, %3 \n"
5670 +#else
5671 + " subu %0, %1, %3 \n"
5672 +#endif
5673 + " sc %0, %2 \n"
5674 + " beqzl %0, 1b \n"
5675 +#ifdef CONFIG_PAX_REFCOUNT
5676 + " b 4f \n"
5677 + " .set noreorder \n"
5678 + "3: b 5f \n"
5679 + " move %0, %1 \n"
5680 + " .set reorder \n"
5681 + _ASM_EXTABLE(2b, 3b)
5682 +#endif
5683 + "4: subu %0, %1, %3 \n"
5684 +#ifdef CONFIG_PAX_REFCOUNT
5685 + "5: \n"
5686 +#endif
5687 + " .set mips0 \n"
5688 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5689 + : "Ir" (i), "m" (v->counter)
5690 + : "memory");
5691 + } else if (kernel_uses_llsc) {
5692 + __asm__ __volatile__(
5693 + " .set mips3 \n"
5694 + "1: ll %1, %2 # atomic_sub_return \n"
5695 +#ifdef CONFIG_PAX_REFCOUNT
5696 + "2: sub %0, %1, %3 \n"
5697 +#else
5698 + " subu %0, %1, %3 \n"
5699 +#endif
5700 + " sc %0, %2 \n"
5701 + " bnez %0, 4f \n"
5702 + " b 1b \n"
5703 +#ifdef CONFIG_PAX_REFCOUNT
5704 + " .set noreorder \n"
5705 + "3: b 5f \n"
5706 + " move %0, %1 \n"
5707 + " .set reorder \n"
5708 + _ASM_EXTABLE(2b, 3b)
5709 +#endif
5710 + "4: subu %0, %1, %3 \n"
5711 +#ifdef CONFIG_PAX_REFCOUNT
5712 + "5: \n"
5713 +#endif
5714 + " .set mips0 \n"
5715 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5716 + : "Ir" (i));
5717 + } else {
5718 + unsigned long flags;
5719 +
5720 + raw_local_irq_save(flags);
5721 + __asm__ __volatile__(
5722 + " lw %0, %1 \n"
5723 +#ifdef CONFIG_PAX_REFCOUNT
5724 + /* Exception on overflow. */
5725 + "1: sub %0, %2 \n"
5726 +#else
5727 + " subu %0, %2 \n"
5728 +#endif
5729 + " sw %0, %1 \n"
5730 +#ifdef CONFIG_PAX_REFCOUNT
5731 + /* Note: Dest reg is not modified on overflow */
5732 + "2: \n"
5733 + _ASM_EXTABLE(1b, 2b)
5734 +#endif
5735 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5736 + raw_local_irq_restore(flags);
5737 + }
5738 +
5739 + smp_llsc_mb();
5740 +
5741 + return result;
5742 +}
5743 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5744 {
5745 int result;
5746
5747 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5748 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5749 * The function returns the old value of @v minus @i.
5750 */
5751 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5752 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5753 {
5754 int result;
5755
5756 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5757 return result;
5758 }
5759
5760 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5761 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5762 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5763 +{
5764 + return cmpxchg(&v->counter, old, new);
5765 +}
5766 +
5767 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5768 + int new)
5769 +{
5770 + return cmpxchg(&(v->counter), old, new);
5771 +}
5772 +
5773 +static inline int atomic_xchg(atomic_t *v, int new)
5774 +{
5775 + return xchg(&v->counter, new);
5776 +}
5777 +
5778 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5779 +{
5780 + return xchg(&(v->counter), new);
5781 +}
5782
5783 /**
5784 * __atomic_add_unless - add unless the number is a given value
5785 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5786
5787 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5788 #define atomic_inc_return(v) atomic_add_return(1, (v))
5789 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5790 +{
5791 + return atomic_add_return_unchecked(1, v);
5792 +}
5793
5794 /*
5795 * atomic_sub_and_test - subtract value from variable and test result
5796 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5797 * other cases.
5798 */
5799 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5800 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5801 +{
5802 + return atomic_add_return_unchecked(1, v) == 0;
5803 +}
5804
5805 /*
5806 * atomic_dec_and_test - decrement by 1 and test
5807 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5808 * Atomically increments @v by 1.
5809 */
5810 #define atomic_inc(v) atomic_add(1, (v))
5811 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5812 +{
5813 + atomic_add_unchecked(1, v);
5814 +}
5815
5816 /*
5817 * atomic_dec - decrement and test
5818 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5819 * Atomically decrements @v by 1.
5820 */
5821 #define atomic_dec(v) atomic_sub(1, (v))
5822 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5823 +{
5824 + atomic_sub_unchecked(1, v);
5825 +}
5826
5827 /*
5828 * atomic_add_negative - add and test if negative
5829 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5830 * @v: pointer of type atomic64_t
5831 *
5832 */
5833 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5834 +static inline long atomic64_read(const atomic64_t *v)
5835 +{
5836 + return (*(volatile const long *) &v->counter);
5837 +}
5838 +
5839 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5840 +{
5841 + return (*(volatile const long *) &v->counter);
5842 +}
5843
5844 /*
5845 * atomic64_set - set atomic variable
5846 * @v: pointer of type atomic64_t
5847 * @i: required value
5848 */
5849 -#define atomic64_set(v, i) ((v)->counter = (i))
5850 +static inline void atomic64_set(atomic64_t *v, long i)
5851 +{
5852 + v->counter = i;
5853 +}
5854 +
5855 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5856 +{
5857 + v->counter = i;
5858 +}
5859
5860 /*
5861 * atomic64_add - add integer to atomic variable
5862 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5863 *
5864 * Atomically adds @i to @v.
5865 */
5866 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5867 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5868 +{
5869 + long temp;
5870 +
5871 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5872 + __asm__ __volatile__(
5873 + " .set mips3 \n"
5874 + "1: lld %0, %1 # atomic64_add \n"
5875 +#ifdef CONFIG_PAX_REFCOUNT
5876 + /* Exception on overflow. */
5877 + "2: dadd %0, %2 \n"
5878 +#else
5879 + " daddu %0, %2 \n"
5880 +#endif
5881 + " scd %0, %1 \n"
5882 + " beqzl %0, 1b \n"
5883 +#ifdef CONFIG_PAX_REFCOUNT
5884 + "3: \n"
5885 + _ASM_EXTABLE(2b, 3b)
5886 +#endif
5887 + " .set mips0 \n"
5888 + : "=&r" (temp), "+m" (v->counter)
5889 + : "Ir" (i));
5890 + } else if (kernel_uses_llsc) {
5891 + __asm__ __volatile__(
5892 + " .set mips3 \n"
5893 + "1: lld %0, %1 # atomic64_add \n"
5894 +#ifdef CONFIG_PAX_REFCOUNT
5895 + /* Exception on overflow. */
5896 + "2: dadd %0, %2 \n"
5897 +#else
5898 + " daddu %0, %2 \n"
5899 +#endif
5900 + " scd %0, %1 \n"
5901 + " beqz %0, 1b \n"
5902 +#ifdef CONFIG_PAX_REFCOUNT
5903 + "3: \n"
5904 + _ASM_EXTABLE(2b, 3b)
5905 +#endif
5906 + " .set mips0 \n"
5907 + : "=&r" (temp), "+m" (v->counter)
5908 + : "Ir" (i));
5909 + } else {
5910 + unsigned long flags;
5911 +
5912 + raw_local_irq_save(flags);
5913 + __asm__ __volatile__(
5914 +#ifdef CONFIG_PAX_REFCOUNT
5915 + /* Exception on overflow. */
5916 + "1: dadd %0, %1 \n"
5917 + "2: \n"
5918 + _ASM_EXTABLE(1b, 2b)
5919 +#else
5920 + " daddu %0, %1 \n"
5921 +#endif
5922 + : "+r" (v->counter) : "Ir" (i));
5923 + raw_local_irq_restore(flags);
5924 + }
5925 +}
5926 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5927 {
5928 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5929 long temp;
5930 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5931 *
5932 * Atomically subtracts @i from @v.
5933 */
5934 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5935 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5936 +{
5937 + long temp;
5938 +
5939 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5940 + __asm__ __volatile__(
5941 + " .set mips3 \n"
5942 + "1: lld %0, %1 # atomic64_sub \n"
5943 +#ifdef CONFIG_PAX_REFCOUNT
5944 + /* Exception on overflow. */
5945 + "2: dsub %0, %2 \n"
5946 +#else
5947 + " dsubu %0, %2 \n"
5948 +#endif
5949 + " scd %0, %1 \n"
5950 + " beqzl %0, 1b \n"
5951 +#ifdef CONFIG_PAX_REFCOUNT
5952 + "3: \n"
5953 + _ASM_EXTABLE(2b, 3b)
5954 +#endif
5955 + " .set mips0 \n"
5956 + : "=&r" (temp), "+m" (v->counter)
5957 + : "Ir" (i));
5958 + } else if (kernel_uses_llsc) {
5959 + __asm__ __volatile__(
5960 + " .set mips3 \n"
5961 + "1: lld %0, %1 # atomic64_sub \n"
5962 +#ifdef CONFIG_PAX_REFCOUNT
5963 + /* Exception on overflow. */
5964 + "2: dsub %0, %2 \n"
5965 +#else
5966 + " dsubu %0, %2 \n"
5967 +#endif
5968 + " scd %0, %1 \n"
5969 + " beqz %0, 1b \n"
5970 +#ifdef CONFIG_PAX_REFCOUNT
5971 + "3: \n"
5972 + _ASM_EXTABLE(2b, 3b)
5973 +#endif
5974 + " .set mips0 \n"
5975 + : "=&r" (temp), "+m" (v->counter)
5976 + : "Ir" (i));
5977 + } else {
5978 + unsigned long flags;
5979 +
5980 + raw_local_irq_save(flags);
5981 + __asm__ __volatile__(
5982 +#ifdef CONFIG_PAX_REFCOUNT
5983 + /* Exception on overflow. */
5984 + "1: dsub %0, %1 \n"
5985 + "2: \n"
5986 + _ASM_EXTABLE(1b, 2b)
5987 +#else
5988 + " dsubu %0, %1 \n"
5989 +#endif
5990 + : "+r" (v->counter) : "Ir" (i));
5991 + raw_local_irq_restore(flags);
5992 + }
5993 +}
5994 +
5995 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5996 {
5997 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5998 long temp;
5999 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6000 /*
6001 * Same as above, but return the result value
6002 */
6003 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6004 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6005 +{
6006 + long result;
6007 + long temp;
6008 +
6009 + smp_mb__before_llsc();
6010 +
6011 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6012 + __asm__ __volatile__(
6013 + " .set mips3 \n"
6014 + "1: lld %1, %2 # atomic64_add_return \n"
6015 +#ifdef CONFIG_PAX_REFCOUNT
6016 + "2: dadd %0, %1, %3 \n"
6017 +#else
6018 + " daddu %0, %1, %3 \n"
6019 +#endif
6020 + " scd %0, %2 \n"
6021 + " beqzl %0, 1b \n"
6022 +#ifdef CONFIG_PAX_REFCOUNT
6023 + " b 4f \n"
6024 + " .set noreorder \n"
6025 + "3: b 5f \n"
6026 + " move %0, %1 \n"
6027 + " .set reorder \n"
6028 + _ASM_EXTABLE(2b, 3b)
6029 +#endif
6030 + "4: daddu %0, %1, %3 \n"
6031 +#ifdef CONFIG_PAX_REFCOUNT
6032 + "5: \n"
6033 +#endif
6034 + " .set mips0 \n"
6035 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6036 + : "Ir" (i));
6037 + } else if (kernel_uses_llsc) {
6038 + __asm__ __volatile__(
6039 + " .set mips3 \n"
6040 + "1: lld %1, %2 # atomic64_add_return \n"
6041 +#ifdef CONFIG_PAX_REFCOUNT
6042 + "2: dadd %0, %1, %3 \n"
6043 +#else
6044 + " daddu %0, %1, %3 \n"
6045 +#endif
6046 + " scd %0, %2 \n"
6047 + " bnez %0, 4f \n"
6048 + " b 1b \n"
6049 +#ifdef CONFIG_PAX_REFCOUNT
6050 + " .set noreorder \n"
6051 + "3: b 5f \n"
6052 + " move %0, %1 \n"
6053 + " .set reorder \n"
6054 + _ASM_EXTABLE(2b, 3b)
6055 +#endif
6056 + "4: daddu %0, %1, %3 \n"
6057 +#ifdef CONFIG_PAX_REFCOUNT
6058 + "5: \n"
6059 +#endif
6060 + " .set mips0 \n"
6061 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6062 + : "Ir" (i), "m" (v->counter)
6063 + : "memory");
6064 + } else {
6065 + unsigned long flags;
6066 +
6067 + raw_local_irq_save(flags);
6068 + __asm__ __volatile__(
6069 + " ld %0, %1 \n"
6070 +#ifdef CONFIG_PAX_REFCOUNT
6071 + /* Exception on overflow. */
6072 + "1: dadd %0, %2 \n"
6073 +#else
6074 + " daddu %0, %2 \n"
6075 +#endif
6076 + " sd %0, %1 \n"
6077 +#ifdef CONFIG_PAX_REFCOUNT
6078 + /* Note: Dest reg is not modified on overflow */
6079 + "2: \n"
6080 + _ASM_EXTABLE(1b, 2b)
6081 +#endif
6082 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6083 + raw_local_irq_restore(flags);
6084 + }
6085 +
6086 + smp_llsc_mb();
6087 +
6088 + return result;
6089 +}
6090 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6091 {
6092 long result;
6093
6094 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6095 return result;
6096 }
6097
6098 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6099 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6100 +{
6101 + long result;
6102 + long temp;
6103 +
6104 + smp_mb__before_llsc();
6105 +
6106 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6107 + long temp;
6108 +
6109 + __asm__ __volatile__(
6110 + " .set mips3 \n"
6111 + "1: lld %1, %2 # atomic64_sub_return \n"
6112 +#ifdef CONFIG_PAX_REFCOUNT
6113 + "2: dsub %0, %1, %3 \n"
6114 +#else
6115 + " dsubu %0, %1, %3 \n"
6116 +#endif
6117 + " scd %0, %2 \n"
6118 + " beqzl %0, 1b \n"
6119 +#ifdef CONFIG_PAX_REFCOUNT
6120 + " b 4f \n"
6121 + " .set noreorder \n"
6122 + "3: b 5f \n"
6123 + " move %0, %1 \n"
6124 + " .set reorder \n"
6125 + _ASM_EXTABLE(2b, 3b)
6126 +#endif
6127 + "4: dsubu %0, %1, %3 \n"
6128 +#ifdef CONFIG_PAX_REFCOUNT
6129 + "5: \n"
6130 +#endif
6131 + " .set mips0 \n"
6132 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6133 + : "Ir" (i), "m" (v->counter)
6134 + : "memory");
6135 + } else if (kernel_uses_llsc) {
6136 + __asm__ __volatile__(
6137 + " .set mips3 \n"
6138 + "1: lld %1, %2 # atomic64_sub_return \n"
6139 +#ifdef CONFIG_PAX_REFCOUNT
6140 + "2: dsub %0, %1, %3 \n"
6141 +#else
6142 + " dsubu %0, %1, %3 \n"
6143 +#endif
6144 + " scd %0, %2 \n"
6145 + " bnez %0, 4f \n"
6146 + " b 1b \n"
6147 +#ifdef CONFIG_PAX_REFCOUNT
6148 + " .set noreorder \n"
6149 + "3: b 5f \n"
6150 + " move %0, %1 \n"
6151 + " .set reorder \n"
6152 + _ASM_EXTABLE(2b, 3b)
6153 +#endif
6154 + "4: dsubu %0, %1, %3 \n"
6155 +#ifdef CONFIG_PAX_REFCOUNT
6156 + "5: \n"
6157 +#endif
6158 + " .set mips0 \n"
6159 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6160 + : "Ir" (i), "m" (v->counter)
6161 + : "memory");
6162 + } else {
6163 + unsigned long flags;
6164 +
6165 + raw_local_irq_save(flags);
6166 + __asm__ __volatile__(
6167 + " ld %0, %1 \n"
6168 +#ifdef CONFIG_PAX_REFCOUNT
6169 + /* Exception on overflow. */
6170 + "1: dsub %0, %2 \n"
6171 +#else
6172 + " dsubu %0, %2 \n"
6173 +#endif
6174 + " sd %0, %1 \n"
6175 +#ifdef CONFIG_PAX_REFCOUNT
6176 + /* Note: Dest reg is not modified on overflow */
6177 + "2: \n"
6178 + _ASM_EXTABLE(1b, 2b)
6179 +#endif
6180 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6181 + raw_local_irq_restore(flags);
6182 + }
6183 +
6184 + smp_llsc_mb();
6185 +
6186 + return result;
6187 +}
6188 +
6189 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6190 {
6191 long result;
6192
6193 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6194 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6195 * The function returns the old value of @v minus @i.
6196 */
6197 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6198 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6199 {
6200 long result;
6201
6202 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6203 return result;
6204 }
6205
6206 -#define atomic64_cmpxchg(v, o, n) \
6207 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6208 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6209 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6210 +{
6211 + return cmpxchg(&v->counter, old, new);
6212 +}
6213 +
6214 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6215 + long new)
6216 +{
6217 + return cmpxchg(&(v->counter), old, new);
6218 +}
6219 +
6220 +static inline long atomic64_xchg(atomic64_t *v, long new)
6221 +{
6222 + return xchg(&v->counter, new);
6223 +}
6224 +
6225 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6226 +{
6227 + return xchg(&(v->counter), new);
6228 +}
6229
6230 /**
6231 * atomic64_add_unless - add unless the number is a given value
6232 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6233
6234 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6235 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6236 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6237
6238 /*
6239 * atomic64_sub_and_test - subtract value from variable and test result
6240 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6241 * other cases.
6242 */
6243 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6244 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6245
6246 /*
6247 * atomic64_dec_and_test - decrement by 1 and test
6248 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6249 * Atomically increments @v by 1.
6250 */
6251 #define atomic64_inc(v) atomic64_add(1, (v))
6252 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6253
6254 /*
6255 * atomic64_dec - decrement and test
6256 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6257 * Atomically decrements @v by 1.
6258 */
6259 #define atomic64_dec(v) atomic64_sub(1, (v))
6260 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6261
6262 /*
6263 * atomic64_add_negative - add and test if negative
6264 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6265 index b4db69f..8f3b093 100644
6266 --- a/arch/mips/include/asm/cache.h
6267 +++ b/arch/mips/include/asm/cache.h
6268 @@ -9,10 +9,11 @@
6269 #ifndef _ASM_CACHE_H
6270 #define _ASM_CACHE_H
6271
6272 +#include <linux/const.h>
6273 #include <kmalloc.h>
6274
6275 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6276 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6277 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6278
6279 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6280 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6281 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6282 index cf3ae24..238d22f 100644
6283 --- a/arch/mips/include/asm/elf.h
6284 +++ b/arch/mips/include/asm/elf.h
6285 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6286 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6287 #endif
6288
6289 +#ifdef CONFIG_PAX_ASLR
6290 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6291 +
6292 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6293 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6294 +#endif
6295 +
6296 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6297 struct linux_binprm;
6298 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6299 int uses_interp);
6300
6301 -struct mm_struct;
6302 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6303 -#define arch_randomize_brk arch_randomize_brk
6304 -
6305 #endif /* _ASM_ELF_H */
6306 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6307 index c1f6afa..38cc6e9 100644
6308 --- a/arch/mips/include/asm/exec.h
6309 +++ b/arch/mips/include/asm/exec.h
6310 @@ -12,6 +12,6 @@
6311 #ifndef _ASM_EXEC_H
6312 #define _ASM_EXEC_H
6313
6314 -extern unsigned long arch_align_stack(unsigned long sp);
6315 +#define arch_align_stack(x) ((x) & ~0xfUL)
6316
6317 #endif /* _ASM_EXEC_H */
6318 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6319 index d44622c..64990d2 100644
6320 --- a/arch/mips/include/asm/local.h
6321 +++ b/arch/mips/include/asm/local.h
6322 @@ -12,15 +12,25 @@ typedef struct
6323 atomic_long_t a;
6324 } local_t;
6325
6326 +typedef struct {
6327 + atomic_long_unchecked_t a;
6328 +} local_unchecked_t;
6329 +
6330 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6331
6332 #define local_read(l) atomic_long_read(&(l)->a)
6333 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6334 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6335 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6336
6337 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6338 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6339 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6340 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6341 #define local_inc(l) atomic_long_inc(&(l)->a)
6342 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6343 #define local_dec(l) atomic_long_dec(&(l)->a)
6344 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6345
6346 /*
6347 * Same as above, but return the result value
6348 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6349 return result;
6350 }
6351
6352 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6353 +{
6354 + unsigned long result;
6355 +
6356 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6357 + unsigned long temp;
6358 +
6359 + __asm__ __volatile__(
6360 + " .set mips3 \n"
6361 + "1:" __LL "%1, %2 # local_add_return \n"
6362 + " addu %0, %1, %3 \n"
6363 + __SC "%0, %2 \n"
6364 + " beqzl %0, 1b \n"
6365 + " addu %0, %1, %3 \n"
6366 + " .set mips0 \n"
6367 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6368 + : "Ir" (i), "m" (l->a.counter)
6369 + : "memory");
6370 + } else if (kernel_uses_llsc) {
6371 + unsigned long temp;
6372 +
6373 + __asm__ __volatile__(
6374 + " .set mips3 \n"
6375 + "1:" __LL "%1, %2 # local_add_return \n"
6376 + " addu %0, %1, %3 \n"
6377 + __SC "%0, %2 \n"
6378 + " beqz %0, 1b \n"
6379 + " addu %0, %1, %3 \n"
6380 + " .set mips0 \n"
6381 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6382 + : "Ir" (i), "m" (l->a.counter)
6383 + : "memory");
6384 + } else {
6385 + unsigned long flags;
6386 +
6387 + local_irq_save(flags);
6388 + result = l->a.counter;
6389 + result += i;
6390 + l->a.counter = result;
6391 + local_irq_restore(flags);
6392 + }
6393 +
6394 + return result;
6395 +}
6396 +
6397 static __inline__ long local_sub_return(long i, local_t * l)
6398 {
6399 unsigned long result;
6400 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6401
6402 #define local_cmpxchg(l, o, n) \
6403 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6404 +#define local_cmpxchg_unchecked(l, o, n) \
6405 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6406 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6407
6408 /**
6409 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6410 index f6be474..12ad554 100644
6411 --- a/arch/mips/include/asm/page.h
6412 +++ b/arch/mips/include/asm/page.h
6413 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6414 #ifdef CONFIG_CPU_MIPS32
6415 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6416 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6417 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6418 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6419 #else
6420 typedef struct { unsigned long long pte; } pte_t;
6421 #define pte_val(x) ((x).pte)
6422 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6423 index 881d18b..cea38bc 100644
6424 --- a/arch/mips/include/asm/pgalloc.h
6425 +++ b/arch/mips/include/asm/pgalloc.h
6426 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6427 {
6428 set_pud(pud, __pud((unsigned long)pmd));
6429 }
6430 +
6431 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6432 +{
6433 + pud_populate(mm, pud, pmd);
6434 +}
6435 #endif
6436
6437 /*
6438 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6439 index 25da651..ae2a259 100644
6440 --- a/arch/mips/include/asm/smtc_proc.h
6441 +++ b/arch/mips/include/asm/smtc_proc.h
6442 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6443
6444 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6445
6446 -extern atomic_t smtc_fpu_recoveries;
6447 +extern atomic_unchecked_t smtc_fpu_recoveries;
6448
6449 #endif /* __ASM_SMTC_PROC_H */
6450 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6451 index 61215a3..213ee0e 100644
6452 --- a/arch/mips/include/asm/thread_info.h
6453 +++ b/arch/mips/include/asm/thread_info.h
6454 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6455 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6456 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6457 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6458 +/* li takes a 32bit immediate */
6459 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6460 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6461
6462 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6463 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6464 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6465 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6466 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6467 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6468
6469 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6470 - _TIF_SYSCALL_AUDIT)
6471 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6472
6473 /* work to do in syscall_trace_leave() */
6474 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6475 - _TIF_SYSCALL_AUDIT)
6476 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6477
6478 /* work to do on interrupt/exception return */
6479 #define _TIF_WORK_MASK \
6480 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6481 /* work to do on any return to u-space */
6482 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6483 - _TIF_WORK_SYSCALL_EXIT)
6484 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6485
6486 #endif /* __KERNEL__ */
6487
6488 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6489 index 1188e00..41cf144 100644
6490 --- a/arch/mips/kernel/binfmt_elfn32.c
6491 +++ b/arch/mips/kernel/binfmt_elfn32.c
6492 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6493 #undef ELF_ET_DYN_BASE
6494 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6495
6496 +#ifdef CONFIG_PAX_ASLR
6497 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6498 +
6499 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6500 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6501 +#endif
6502 +
6503 #include <asm/processor.h>
6504 #include <linux/module.h>
6505 #include <linux/elfcore.h>
6506 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6507 index 202e581..689ca79 100644
6508 --- a/arch/mips/kernel/binfmt_elfo32.c
6509 +++ b/arch/mips/kernel/binfmt_elfo32.c
6510 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6511 #undef ELF_ET_DYN_BASE
6512 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6513
6514 +#ifdef CONFIG_PAX_ASLR
6515 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6516 +
6517 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6518 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6519 +#endif
6520 +
6521 #include <asm/processor.h>
6522
6523 /*
6524 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6525 index d1fea7a..45602ea 100644
6526 --- a/arch/mips/kernel/irq.c
6527 +++ b/arch/mips/kernel/irq.c
6528 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6529 printk("unexpected IRQ # %d\n", irq);
6530 }
6531
6532 -atomic_t irq_err_count;
6533 +atomic_unchecked_t irq_err_count;
6534
6535 int arch_show_interrupts(struct seq_file *p, int prec)
6536 {
6537 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6538 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6539 return 0;
6540 }
6541
6542 asmlinkage void spurious_interrupt(void)
6543 {
6544 - atomic_inc(&irq_err_count);
6545 + atomic_inc_unchecked(&irq_err_count);
6546 }
6547
6548 void __init init_IRQ(void)
6549 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6550 index ddc7610..8c58f17 100644
6551 --- a/arch/mips/kernel/process.c
6552 +++ b/arch/mips/kernel/process.c
6553 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6554 out:
6555 return pc;
6556 }
6557 -
6558 -/*
6559 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6560 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6561 - */
6562 -unsigned long arch_align_stack(unsigned long sp)
6563 -{
6564 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6565 - sp -= get_random_int() & ~PAGE_MASK;
6566 -
6567 - return sp & ALMASK;
6568 -}
6569 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6570 index 8ae1ebe..1bcbf47 100644
6571 --- a/arch/mips/kernel/ptrace.c
6572 +++ b/arch/mips/kernel/ptrace.c
6573 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6574 return arch;
6575 }
6576
6577 +#ifdef CONFIG_GRKERNSEC_SETXID
6578 +extern void gr_delayed_cred_worker(void);
6579 +#endif
6580 +
6581 /*
6582 * Notification of system call entry/exit
6583 * - triggered by current->work.syscall_trace
6584 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6585 /* do the secure computing check first */
6586 secure_computing_strict(regs->regs[2]);
6587
6588 +#ifdef CONFIG_GRKERNSEC_SETXID
6589 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6590 + gr_delayed_cred_worker();
6591 +#endif
6592 +
6593 if (!(current->ptrace & PT_PTRACED))
6594 goto out;
6595
6596 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6597 index c10aa84..9ec2e60 100644
6598 --- a/arch/mips/kernel/smtc-proc.c
6599 +++ b/arch/mips/kernel/smtc-proc.c
6600 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6601
6602 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6603
6604 -atomic_t smtc_fpu_recoveries;
6605 +atomic_unchecked_t smtc_fpu_recoveries;
6606
6607 static int smtc_proc_show(struct seq_file *m, void *v)
6608 {
6609 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6610 for(i = 0; i < NR_CPUS; i++)
6611 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6612 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6613 - atomic_read(&smtc_fpu_recoveries));
6614 + atomic_read_unchecked(&smtc_fpu_recoveries));
6615 return 0;
6616 }
6617
6618 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6619 smtc_cpu_stats[i].selfipis = 0;
6620 }
6621
6622 - atomic_set(&smtc_fpu_recoveries, 0);
6623 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6624
6625 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6626 }
6627 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6628 index dfc1b91..11a2c07 100644
6629 --- a/arch/mips/kernel/smtc.c
6630 +++ b/arch/mips/kernel/smtc.c
6631 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6632 }
6633 smtc_ipi_qdump();
6634 printk("%d Recoveries of \"stolen\" FPU\n",
6635 - atomic_read(&smtc_fpu_recoveries));
6636 + atomic_read_unchecked(&smtc_fpu_recoveries));
6637 }
6638
6639
6640 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6641 index 84536bf..79caa4d 100644
6642 --- a/arch/mips/kernel/sync-r4k.c
6643 +++ b/arch/mips/kernel/sync-r4k.c
6644 @@ -21,8 +21,8 @@
6645 #include <asm/mipsregs.h>
6646
6647 static atomic_t count_start_flag = ATOMIC_INIT(0);
6648 -static atomic_t count_count_start = ATOMIC_INIT(0);
6649 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6650 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6651 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6652 static atomic_t count_reference = ATOMIC_INIT(0);
6653
6654 #define COUNTON 100
6655 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6656
6657 for (i = 0; i < NR_LOOPS; i++) {
6658 /* slaves loop on '!= 2' */
6659 - while (atomic_read(&count_count_start) != 1)
6660 + while (atomic_read_unchecked(&count_count_start) != 1)
6661 mb();
6662 - atomic_set(&count_count_stop, 0);
6663 + atomic_set_unchecked(&count_count_stop, 0);
6664 smp_wmb();
6665
6666 /* this lets the slaves write their count register */
6667 - atomic_inc(&count_count_start);
6668 + atomic_inc_unchecked(&count_count_start);
6669
6670 /*
6671 * Everyone initialises count in the last loop:
6672 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6673 /*
6674 * Wait for all slaves to leave the synchronization point:
6675 */
6676 - while (atomic_read(&count_count_stop) != 1)
6677 + while (atomic_read_unchecked(&count_count_stop) != 1)
6678 mb();
6679 - atomic_set(&count_count_start, 0);
6680 + atomic_set_unchecked(&count_count_start, 0);
6681 smp_wmb();
6682 - atomic_inc(&count_count_stop);
6683 + atomic_inc_unchecked(&count_count_stop);
6684 }
6685 /* Arrange for an interrupt in a short while */
6686 write_c0_compare(read_c0_count() + COUNTON);
6687 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6688 initcount = atomic_read(&count_reference);
6689
6690 for (i = 0; i < NR_LOOPS; i++) {
6691 - atomic_inc(&count_count_start);
6692 - while (atomic_read(&count_count_start) != 2)
6693 + atomic_inc_unchecked(&count_count_start);
6694 + while (atomic_read_unchecked(&count_count_start) != 2)
6695 mb();
6696
6697 /*
6698 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6699 if (i == NR_LOOPS-1)
6700 write_c0_count(initcount);
6701
6702 - atomic_inc(&count_count_stop);
6703 - while (atomic_read(&count_count_stop) != 2)
6704 + atomic_inc_unchecked(&count_count_stop);
6705 + while (atomic_read_unchecked(&count_count_stop) != 2)
6706 mb();
6707 }
6708 /* Arrange for an interrupt in a short while */
6709 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6710 index 524841f..3eef41e 100644
6711 --- a/arch/mips/kernel/traps.c
6712 +++ b/arch/mips/kernel/traps.c
6713 @@ -684,7 +684,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6714 siginfo_t info;
6715
6716 prev_state = exception_enter();
6717 - die_if_kernel("Integer overflow", regs);
6718 + if (unlikely(!user_mode(regs))) {
6719 +
6720 +#ifdef CONFIG_PAX_REFCOUNT
6721 + if (fixup_exception(regs)) {
6722 + pax_report_refcount_overflow(regs);
6723 + exception_exit(prev_state);
6724 + return;
6725 + }
6726 +#endif
6727 +
6728 + die("Integer overflow", regs);
6729 + }
6730
6731 info.si_code = FPE_INTOVF;
6732 info.si_signo = SIGFPE;
6733 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6734 index becc42b..9e43d4b 100644
6735 --- a/arch/mips/mm/fault.c
6736 +++ b/arch/mips/mm/fault.c
6737 @@ -28,6 +28,23 @@
6738 #include <asm/highmem.h> /* For VMALLOC_END */
6739 #include <linux/kdebug.h>
6740
6741 +#ifdef CONFIG_PAX_PAGEEXEC
6742 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6743 +{
6744 + unsigned long i;
6745 +
6746 + printk(KERN_ERR "PAX: bytes at PC: ");
6747 + for (i = 0; i < 5; i++) {
6748 + unsigned int c;
6749 + if (get_user(c, (unsigned int *)pc+i))
6750 + printk(KERN_CONT "???????? ");
6751 + else
6752 + printk(KERN_CONT "%08x ", c);
6753 + }
6754 + printk("\n");
6755 +}
6756 +#endif
6757 +
6758 /*
6759 * This routine handles page faults. It determines the address,
6760 * and the problem, and then passes it off to one of the appropriate
6761 @@ -199,6 +216,14 @@ bad_area:
6762 bad_area_nosemaphore:
6763 /* User mode accesses just cause a SIGSEGV */
6764 if (user_mode(regs)) {
6765 +
6766 +#ifdef CONFIG_PAX_PAGEEXEC
6767 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6768 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6769 + do_group_exit(SIGKILL);
6770 + }
6771 +#endif
6772 +
6773 tsk->thread.cp0_badvaddr = address;
6774 tsk->thread.error_code = write;
6775 #if 0
6776 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6777 index f1baadd..8537544 100644
6778 --- a/arch/mips/mm/mmap.c
6779 +++ b/arch/mips/mm/mmap.c
6780 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6781 struct vm_area_struct *vma;
6782 unsigned long addr = addr0;
6783 int do_color_align;
6784 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6785 struct vm_unmapped_area_info info;
6786
6787 if (unlikely(len > TASK_SIZE))
6788 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6789 do_color_align = 1;
6790
6791 /* requesting a specific address */
6792 +
6793 +#ifdef CONFIG_PAX_RANDMMAP
6794 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6795 +#endif
6796 +
6797 if (addr) {
6798 if (do_color_align)
6799 addr = COLOUR_ALIGN(addr, pgoff);
6800 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6801 addr = PAGE_ALIGN(addr);
6802
6803 vma = find_vma(mm, addr);
6804 - if (TASK_SIZE - len >= addr &&
6805 - (!vma || addr + len <= vma->vm_start))
6806 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6807 return addr;
6808 }
6809
6810 info.length = len;
6811 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6812 info.align_offset = pgoff << PAGE_SHIFT;
6813 + info.threadstack_offset = offset;
6814
6815 if (dir == DOWN) {
6816 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6817 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6818 {
6819 unsigned long random_factor = 0UL;
6820
6821 +#ifdef CONFIG_PAX_RANDMMAP
6822 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6823 +#endif
6824 +
6825 if (current->flags & PF_RANDOMIZE) {
6826 random_factor = get_random_int();
6827 random_factor = random_factor << PAGE_SHIFT;
6828 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6829
6830 if (mmap_is_legacy()) {
6831 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6832 +
6833 +#ifdef CONFIG_PAX_RANDMMAP
6834 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6835 + mm->mmap_base += mm->delta_mmap;
6836 +#endif
6837 +
6838 mm->get_unmapped_area = arch_get_unmapped_area;
6839 } else {
6840 mm->mmap_base = mmap_base(random_factor);
6841 +
6842 +#ifdef CONFIG_PAX_RANDMMAP
6843 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6844 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6845 +#endif
6846 +
6847 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6848 }
6849 }
6850
6851 -static inline unsigned long brk_rnd(void)
6852 -{
6853 - unsigned long rnd = get_random_int();
6854 -
6855 - rnd = rnd << PAGE_SHIFT;
6856 - /* 8MB for 32bit, 256MB for 64bit */
6857 - if (TASK_IS_32BIT_ADDR)
6858 - rnd = rnd & 0x7ffffful;
6859 - else
6860 - rnd = rnd & 0xffffffful;
6861 -
6862 - return rnd;
6863 -}
6864 -
6865 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6866 -{
6867 - unsigned long base = mm->brk;
6868 - unsigned long ret;
6869 -
6870 - ret = PAGE_ALIGN(base + brk_rnd());
6871 -
6872 - if (ret < mm->brk)
6873 - return mm->brk;
6874 -
6875 - return ret;
6876 -}
6877 -
6878 int __virt_addr_valid(const volatile void *kaddr)
6879 {
6880 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6881 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6882 index a2358b4..7cead4f 100644
6883 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6884 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6885 @@ -187,9 +187,9 @@ void
6886 cont_nmi_dump(void)
6887 {
6888 #ifndef REAL_NMI_SIGNAL
6889 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6890 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6891
6892 - atomic_inc(&nmied_cpus);
6893 + atomic_inc_unchecked(&nmied_cpus);
6894 #endif
6895 /*
6896 * Only allow 1 cpu to proceed
6897 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6898 udelay(10000);
6899 }
6900 #else
6901 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6902 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6903 #endif
6904
6905 /*
6906 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6907 index 967d144..db12197 100644
6908 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6909 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6910 @@ -11,12 +11,14 @@
6911 #ifndef _ASM_PROC_CACHE_H
6912 #define _ASM_PROC_CACHE_H
6913
6914 +#include <linux/const.h>
6915 +
6916 /* L1 cache */
6917
6918 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6919 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6920 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6921 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6922 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6923 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6924
6925 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6926 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6927 index bcb5df2..84fabd2 100644
6928 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6929 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6930 @@ -16,13 +16,15 @@
6931 #ifndef _ASM_PROC_CACHE_H
6932 #define _ASM_PROC_CACHE_H
6933
6934 +#include <linux/const.h>
6935 +
6936 /*
6937 * L1 cache
6938 */
6939 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6940 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6941 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6942 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6943 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6944 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6945
6946 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6947 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6948 index 4ce7a01..449202a 100644
6949 --- a/arch/openrisc/include/asm/cache.h
6950 +++ b/arch/openrisc/include/asm/cache.h
6951 @@ -19,11 +19,13 @@
6952 #ifndef __ASM_OPENRISC_CACHE_H
6953 #define __ASM_OPENRISC_CACHE_H
6954
6955 +#include <linux/const.h>
6956 +
6957 /* FIXME: How can we replace these with values from the CPU...
6958 * they shouldn't be hard-coded!
6959 */
6960
6961 -#define L1_CACHE_BYTES 16
6962 #define L1_CACHE_SHIFT 4
6963 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6964
6965 #endif /* __ASM_OPENRISC_CACHE_H */
6966 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6967 index 472886c..00e7df9 100644
6968 --- a/arch/parisc/include/asm/atomic.h
6969 +++ b/arch/parisc/include/asm/atomic.h
6970 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6971 return dec;
6972 }
6973
6974 +#define atomic64_read_unchecked(v) atomic64_read(v)
6975 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6976 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6977 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6978 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6979 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6980 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6981 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6982 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6983 +
6984 #endif /* !CONFIG_64BIT */
6985
6986
6987 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6988 index 47f11c7..3420df2 100644
6989 --- a/arch/parisc/include/asm/cache.h
6990 +++ b/arch/parisc/include/asm/cache.h
6991 @@ -5,6 +5,7 @@
6992 #ifndef __ARCH_PARISC_CACHE_H
6993 #define __ARCH_PARISC_CACHE_H
6994
6995 +#include <linux/const.h>
6996
6997 /*
6998 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6999 @@ -15,13 +16,13 @@
7000 * just ruin performance.
7001 */
7002 #ifdef CONFIG_PA20
7003 -#define L1_CACHE_BYTES 64
7004 #define L1_CACHE_SHIFT 6
7005 #else
7006 -#define L1_CACHE_BYTES 32
7007 #define L1_CACHE_SHIFT 5
7008 #endif
7009
7010 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7011 +
7012 #ifndef __ASSEMBLY__
7013
7014 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7015 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7016 index ad2b503..bdf1651 100644
7017 --- a/arch/parisc/include/asm/elf.h
7018 +++ b/arch/parisc/include/asm/elf.h
7019 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7020
7021 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7022
7023 +#ifdef CONFIG_PAX_ASLR
7024 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7025 +
7026 +#define PAX_DELTA_MMAP_LEN 16
7027 +#define PAX_DELTA_STACK_LEN 16
7028 +#endif
7029 +
7030 /* This yields a mask that user programs can use to figure out what
7031 instruction set this CPU supports. This could be done in user space,
7032 but it's not easy, and we've already done it here. */
7033 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7034 index fc987a1..6e068ef 100644
7035 --- a/arch/parisc/include/asm/pgalloc.h
7036 +++ b/arch/parisc/include/asm/pgalloc.h
7037 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7038 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7039 }
7040
7041 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7042 +{
7043 + pgd_populate(mm, pgd, pmd);
7044 +}
7045 +
7046 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7047 {
7048 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7049 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7050 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7051 #define pmd_free(mm, x) do { } while (0)
7052 #define pgd_populate(mm, pmd, pte) BUG()
7053 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7054
7055 #endif
7056
7057 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7058 index 34899b5..02dd060 100644
7059 --- a/arch/parisc/include/asm/pgtable.h
7060 +++ b/arch/parisc/include/asm/pgtable.h
7061 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7062 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7063 #define PAGE_COPY PAGE_EXECREAD
7064 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7065 +
7066 +#ifdef CONFIG_PAX_PAGEEXEC
7067 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7068 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7069 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7070 +#else
7071 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7072 +# define PAGE_COPY_NOEXEC PAGE_COPY
7073 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7074 +#endif
7075 +
7076 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7077 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7078 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7079 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7080 index e0a8235..ce2f1e1 100644
7081 --- a/arch/parisc/include/asm/uaccess.h
7082 +++ b/arch/parisc/include/asm/uaccess.h
7083 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7084 const void __user *from,
7085 unsigned long n)
7086 {
7087 - int sz = __compiletime_object_size(to);
7088 + size_t sz = __compiletime_object_size(to);
7089 int ret = -EFAULT;
7090
7091 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7092 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7093 ret = __copy_from_user(to, from, n);
7094 else
7095 copy_from_user_overflow();
7096 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7097 index 2a625fb..9908930 100644
7098 --- a/arch/parisc/kernel/module.c
7099 +++ b/arch/parisc/kernel/module.c
7100 @@ -98,16 +98,38 @@
7101
7102 /* three functions to determine where in the module core
7103 * or init pieces the location is */
7104 +static inline int in_init_rx(struct module *me, void *loc)
7105 +{
7106 + return (loc >= me->module_init_rx &&
7107 + loc < (me->module_init_rx + me->init_size_rx));
7108 +}
7109 +
7110 +static inline int in_init_rw(struct module *me, void *loc)
7111 +{
7112 + return (loc >= me->module_init_rw &&
7113 + loc < (me->module_init_rw + me->init_size_rw));
7114 +}
7115 +
7116 static inline int in_init(struct module *me, void *loc)
7117 {
7118 - return (loc >= me->module_init &&
7119 - loc <= (me->module_init + me->init_size));
7120 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7121 +}
7122 +
7123 +static inline int in_core_rx(struct module *me, void *loc)
7124 +{
7125 + return (loc >= me->module_core_rx &&
7126 + loc < (me->module_core_rx + me->core_size_rx));
7127 +}
7128 +
7129 +static inline int in_core_rw(struct module *me, void *loc)
7130 +{
7131 + return (loc >= me->module_core_rw &&
7132 + loc < (me->module_core_rw + me->core_size_rw));
7133 }
7134
7135 static inline int in_core(struct module *me, void *loc)
7136 {
7137 - return (loc >= me->module_core &&
7138 - loc <= (me->module_core + me->core_size));
7139 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7140 }
7141
7142 static inline int in_local(struct module *me, void *loc)
7143 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7144 }
7145
7146 /* align things a bit */
7147 - me->core_size = ALIGN(me->core_size, 16);
7148 - me->arch.got_offset = me->core_size;
7149 - me->core_size += gots * sizeof(struct got_entry);
7150 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7151 + me->arch.got_offset = me->core_size_rw;
7152 + me->core_size_rw += gots * sizeof(struct got_entry);
7153
7154 - me->core_size = ALIGN(me->core_size, 16);
7155 - me->arch.fdesc_offset = me->core_size;
7156 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7157 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7158 + me->arch.fdesc_offset = me->core_size_rw;
7159 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7160
7161 me->arch.got_max = gots;
7162 me->arch.fdesc_max = fdescs;
7163 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7164
7165 BUG_ON(value == 0);
7166
7167 - got = me->module_core + me->arch.got_offset;
7168 + got = me->module_core_rw + me->arch.got_offset;
7169 for (i = 0; got[i].addr; i++)
7170 if (got[i].addr == value)
7171 goto out;
7172 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7173 #ifdef CONFIG_64BIT
7174 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7175 {
7176 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7177 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7178
7179 if (!value) {
7180 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7181 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7182
7183 /* Create new one */
7184 fdesc->addr = value;
7185 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7186 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7187 return (Elf_Addr)fdesc;
7188 }
7189 #endif /* CONFIG_64BIT */
7190 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7191
7192 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7193 end = table + sechdrs[me->arch.unwind_section].sh_size;
7194 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7195 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7196
7197 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7198 me->arch.unwind_section, table, end, gp);
7199 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7200 index 5dfd248..64914ac 100644
7201 --- a/arch/parisc/kernel/sys_parisc.c
7202 +++ b/arch/parisc/kernel/sys_parisc.c
7203 @@ -33,9 +33,11 @@
7204 #include <linux/utsname.h>
7205 #include <linux/personality.h>
7206
7207 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7208 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7209 + unsigned long flags)
7210 {
7211 struct vm_unmapped_area_info info;
7212 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7213
7214 info.flags = 0;
7215 info.length = len;
7216 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7217 info.high_limit = TASK_SIZE;
7218 info.align_mask = 0;
7219 info.align_offset = 0;
7220 + info.threadstack_offset = offset;
7221 return vm_unmapped_area(&info);
7222 }
7223
7224 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7225 return (unsigned long) mapping >> 8;
7226 }
7227
7228 -static unsigned long get_shared_area(struct address_space *mapping,
7229 - unsigned long addr, unsigned long len, unsigned long pgoff)
7230 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7231 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7232 {
7233 struct vm_unmapped_area_info info;
7234 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7235
7236 info.flags = 0;
7237 info.length = len;
7238 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7239 info.high_limit = TASK_SIZE;
7240 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7241 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7242 + info.threadstack_offset = offset;
7243 return vm_unmapped_area(&info);
7244 }
7245
7246 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7247 return -EINVAL;
7248 return addr;
7249 }
7250 - if (!addr)
7251 + if (!addr) {
7252 addr = TASK_UNMAPPED_BASE;
7253
7254 +#ifdef CONFIG_PAX_RANDMMAP
7255 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7256 + addr += current->mm->delta_mmap;
7257 +#endif
7258 +
7259 + }
7260 +
7261 if (filp) {
7262 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7263 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7264 } else if(flags & MAP_SHARED) {
7265 - addr = get_shared_area(NULL, addr, len, pgoff);
7266 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7267 } else {
7268 - addr = get_unshared_area(addr, len);
7269 + addr = get_unshared_area(filp, addr, len, flags);
7270 }
7271 return addr;
7272 }
7273 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7274 index 1cd1d0c..44ec918 100644
7275 --- a/arch/parisc/kernel/traps.c
7276 +++ b/arch/parisc/kernel/traps.c
7277 @@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7278
7279 down_read(&current->mm->mmap_sem);
7280 vma = find_vma(current->mm,regs->iaoq[0]);
7281 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7282 - && (vma->vm_flags & VM_EXEC)) {
7283 -
7284 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7285 fault_address = regs->iaoq[0];
7286 fault_space = regs->iasq[0];
7287
7288 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7289 index 0293588..3b229aa 100644
7290 --- a/arch/parisc/mm/fault.c
7291 +++ b/arch/parisc/mm/fault.c
7292 @@ -15,6 +15,7 @@
7293 #include <linux/sched.h>
7294 #include <linux/interrupt.h>
7295 #include <linux/module.h>
7296 +#include <linux/unistd.h>
7297
7298 #include <asm/uaccess.h>
7299 #include <asm/traps.h>
7300 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7301 static unsigned long
7302 parisc_acctyp(unsigned long code, unsigned int inst)
7303 {
7304 - if (code == 6 || code == 16)
7305 + if (code == 6 || code == 7 || code == 16)
7306 return VM_EXEC;
7307
7308 switch (inst & 0xf0000000) {
7309 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7310 }
7311 #endif
7312
7313 +#ifdef CONFIG_PAX_PAGEEXEC
7314 +/*
7315 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7316 + *
7317 + * returns 1 when task should be killed
7318 + * 2 when rt_sigreturn trampoline was detected
7319 + * 3 when unpatched PLT trampoline was detected
7320 + */
7321 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7322 +{
7323 +
7324 +#ifdef CONFIG_PAX_EMUPLT
7325 + int err;
7326 +
7327 + do { /* PaX: unpatched PLT emulation */
7328 + unsigned int bl, depwi;
7329 +
7330 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7331 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7332 +
7333 + if (err)
7334 + break;
7335 +
7336 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7337 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7338 +
7339 + err = get_user(ldw, (unsigned int *)addr);
7340 + err |= get_user(bv, (unsigned int *)(addr+4));
7341 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7342 +
7343 + if (err)
7344 + break;
7345 +
7346 + if (ldw == 0x0E801096U &&
7347 + bv == 0xEAC0C000U &&
7348 + ldw2 == 0x0E881095U)
7349 + {
7350 + unsigned int resolver, map;
7351 +
7352 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7353 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7354 + if (err)
7355 + break;
7356 +
7357 + regs->gr[20] = instruction_pointer(regs)+8;
7358 + regs->gr[21] = map;
7359 + regs->gr[22] = resolver;
7360 + regs->iaoq[0] = resolver | 3UL;
7361 + regs->iaoq[1] = regs->iaoq[0] + 4;
7362 + return 3;
7363 + }
7364 + }
7365 + } while (0);
7366 +#endif
7367 +
7368 +#ifdef CONFIG_PAX_EMUTRAMP
7369 +
7370 +#ifndef CONFIG_PAX_EMUSIGRT
7371 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7372 + return 1;
7373 +#endif
7374 +
7375 + do { /* PaX: rt_sigreturn emulation */
7376 + unsigned int ldi1, ldi2, bel, nop;
7377 +
7378 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7379 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7380 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7381 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7382 +
7383 + if (err)
7384 + break;
7385 +
7386 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7387 + ldi2 == 0x3414015AU &&
7388 + bel == 0xE4008200U &&
7389 + nop == 0x08000240U)
7390 + {
7391 + regs->gr[25] = (ldi1 & 2) >> 1;
7392 + regs->gr[20] = __NR_rt_sigreturn;
7393 + regs->gr[31] = regs->iaoq[1] + 16;
7394 + regs->sr[0] = regs->iasq[1];
7395 + regs->iaoq[0] = 0x100UL;
7396 + regs->iaoq[1] = regs->iaoq[0] + 4;
7397 + regs->iasq[0] = regs->sr[2];
7398 + regs->iasq[1] = regs->sr[2];
7399 + return 2;
7400 + }
7401 + } while (0);
7402 +#endif
7403 +
7404 + return 1;
7405 +}
7406 +
7407 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7408 +{
7409 + unsigned long i;
7410 +
7411 + printk(KERN_ERR "PAX: bytes at PC: ");
7412 + for (i = 0; i < 5; i++) {
7413 + unsigned int c;
7414 + if (get_user(c, (unsigned int *)pc+i))
7415 + printk(KERN_CONT "???????? ");
7416 + else
7417 + printk(KERN_CONT "%08x ", c);
7418 + }
7419 + printk("\n");
7420 +}
7421 +#endif
7422 +
7423 int fixup_exception(struct pt_regs *regs)
7424 {
7425 const struct exception_table_entry *fix;
7426 @@ -204,8 +315,33 @@ retry:
7427
7428 good_area:
7429
7430 - if ((vma->vm_flags & acc_type) != acc_type)
7431 + if ((vma->vm_flags & acc_type) != acc_type) {
7432 +
7433 +#ifdef CONFIG_PAX_PAGEEXEC
7434 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7435 + (address & ~3UL) == instruction_pointer(regs))
7436 + {
7437 + up_read(&mm->mmap_sem);
7438 + switch (pax_handle_fetch_fault(regs)) {
7439 +
7440 +#ifdef CONFIG_PAX_EMUPLT
7441 + case 3:
7442 + return;
7443 +#endif
7444 +
7445 +#ifdef CONFIG_PAX_EMUTRAMP
7446 + case 2:
7447 + return;
7448 +#endif
7449 +
7450 + }
7451 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7452 + do_group_exit(SIGKILL);
7453 + }
7454 +#endif
7455 +
7456 goto bad_area;
7457 + }
7458
7459 /*
7460 * If for any reason at all we couldn't handle the fault, make
7461 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7462 index e3b1d41..8e81edf 100644
7463 --- a/arch/powerpc/include/asm/atomic.h
7464 +++ b/arch/powerpc/include/asm/atomic.h
7465 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7466 return t1;
7467 }
7468
7469 +#define atomic64_read_unchecked(v) atomic64_read(v)
7470 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7471 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7472 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7473 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7474 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7475 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7476 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7477 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7478 +
7479 #endif /* __powerpc64__ */
7480
7481 #endif /* __KERNEL__ */
7482 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7483 index 9e495c9..b6878e5 100644
7484 --- a/arch/powerpc/include/asm/cache.h
7485 +++ b/arch/powerpc/include/asm/cache.h
7486 @@ -3,6 +3,7 @@
7487
7488 #ifdef __KERNEL__
7489
7490 +#include <linux/const.h>
7491
7492 /* bytes per L1 cache line */
7493 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7494 @@ -22,7 +23,7 @@
7495 #define L1_CACHE_SHIFT 7
7496 #endif
7497
7498 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7499 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7500
7501 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7502
7503 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7504 index cc0655a..13eac2e 100644
7505 --- a/arch/powerpc/include/asm/elf.h
7506 +++ b/arch/powerpc/include/asm/elf.h
7507 @@ -28,8 +28,19 @@
7508 the loader. We need to make sure that it is out of the way of the program
7509 that it will "exec", and that there is sufficient room for the brk. */
7510
7511 -extern unsigned long randomize_et_dyn(unsigned long base);
7512 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7513 +#define ELF_ET_DYN_BASE (0x20000000)
7514 +
7515 +#ifdef CONFIG_PAX_ASLR
7516 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7517 +
7518 +#ifdef __powerpc64__
7519 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7520 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7521 +#else
7522 +#define PAX_DELTA_MMAP_LEN 15
7523 +#define PAX_DELTA_STACK_LEN 15
7524 +#endif
7525 +#endif
7526
7527 /*
7528 * Our registers are always unsigned longs, whether we're a 32 bit
7529 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7530 (0x7ff >> (PAGE_SHIFT - 12)) : \
7531 (0x3ffff >> (PAGE_SHIFT - 12)))
7532
7533 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7534 -#define arch_randomize_brk arch_randomize_brk
7535 -
7536 -
7537 #ifdef CONFIG_SPU_BASE
7538 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7539 #define NT_SPU 1
7540 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7541 index 8196e9c..d83a9f3 100644
7542 --- a/arch/powerpc/include/asm/exec.h
7543 +++ b/arch/powerpc/include/asm/exec.h
7544 @@ -4,6 +4,6 @@
7545 #ifndef _ASM_POWERPC_EXEC_H
7546 #define _ASM_POWERPC_EXEC_H
7547
7548 -extern unsigned long arch_align_stack(unsigned long sp);
7549 +#define arch_align_stack(x) ((x) & ~0xfUL)
7550
7551 #endif /* _ASM_POWERPC_EXEC_H */
7552 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7553 index 5acabbd..7ea14fa 100644
7554 --- a/arch/powerpc/include/asm/kmap_types.h
7555 +++ b/arch/powerpc/include/asm/kmap_types.h
7556 @@ -10,7 +10,7 @@
7557 * 2 of the License, or (at your option) any later version.
7558 */
7559
7560 -#define KM_TYPE_NR 16
7561 +#define KM_TYPE_NR 17
7562
7563 #endif /* __KERNEL__ */
7564 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7565 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7566 index 8565c25..2865190 100644
7567 --- a/arch/powerpc/include/asm/mman.h
7568 +++ b/arch/powerpc/include/asm/mman.h
7569 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7570 }
7571 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7572
7573 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7574 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7575 {
7576 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7577 }
7578 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7579 index b9f4262..dcf04f7 100644
7580 --- a/arch/powerpc/include/asm/page.h
7581 +++ b/arch/powerpc/include/asm/page.h
7582 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7583 * and needs to be executable. This means the whole heap ends
7584 * up being executable.
7585 */
7586 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7587 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7588 +#define VM_DATA_DEFAULT_FLAGS32 \
7589 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7590 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7591
7592 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7593 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7594 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7595 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7596 #endif
7597
7598 +#define ktla_ktva(addr) (addr)
7599 +#define ktva_ktla(addr) (addr)
7600 +
7601 #ifndef CONFIG_PPC_BOOK3S_64
7602 /*
7603 * Use the top bit of the higher-level page table entries to indicate whether
7604 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7605 index 88693ce..ac6f9ab 100644
7606 --- a/arch/powerpc/include/asm/page_64.h
7607 +++ b/arch/powerpc/include/asm/page_64.h
7608 @@ -153,15 +153,18 @@ do { \
7609 * stack by default, so in the absence of a PT_GNU_STACK program header
7610 * we turn execute permission off.
7611 */
7612 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7613 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7614 +#define VM_STACK_DEFAULT_FLAGS32 \
7615 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7616 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7617
7618 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7619 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7620
7621 +#ifndef CONFIG_PAX_PAGEEXEC
7622 #define VM_STACK_DEFAULT_FLAGS \
7623 (is_32bit_task() ? \
7624 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7625 +#endif
7626
7627 #include <asm-generic/getorder.h>
7628
7629 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7630 index f65e27b..23ffb5b 100644
7631 --- a/arch/powerpc/include/asm/pgalloc-64.h
7632 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7633 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7634 #ifndef CONFIG_PPC_64K_PAGES
7635
7636 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7637 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7638
7639 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7640 {
7641 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7642 pud_set(pud, (unsigned long)pmd);
7643 }
7644
7645 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7646 +{
7647 + pud_populate(mm, pud, pmd);
7648 +}
7649 +
7650 #define pmd_populate(mm, pmd, pte_page) \
7651 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7652 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7653 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7654 #endif
7655
7656 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7657 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7658
7659 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7660 pte_t *pte)
7661 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7662 index 7d6eacf..14c0240 100644
7663 --- a/arch/powerpc/include/asm/pgtable.h
7664 +++ b/arch/powerpc/include/asm/pgtable.h
7665 @@ -2,6 +2,7 @@
7666 #define _ASM_POWERPC_PGTABLE_H
7667 #ifdef __KERNEL__
7668
7669 +#include <linux/const.h>
7670 #ifndef __ASSEMBLY__
7671 #include <asm/processor.h> /* For TASK_SIZE */
7672 #include <asm/mmu.h>
7673 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7674 index 4aad413..85d86bf 100644
7675 --- a/arch/powerpc/include/asm/pte-hash32.h
7676 +++ b/arch/powerpc/include/asm/pte-hash32.h
7677 @@ -21,6 +21,7 @@
7678 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7679 #define _PAGE_USER 0x004 /* usermode access allowed */
7680 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7681 +#define _PAGE_EXEC _PAGE_GUARDED
7682 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7683 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7684 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7685 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7686 index 10d1ef0..8f83abc 100644
7687 --- a/arch/powerpc/include/asm/reg.h
7688 +++ b/arch/powerpc/include/asm/reg.h
7689 @@ -234,6 +234,7 @@
7690 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7691 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7692 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7693 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7694 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7695 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7696 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7697 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7698 index 98da78e..dc68271 100644
7699 --- a/arch/powerpc/include/asm/smp.h
7700 +++ b/arch/powerpc/include/asm/smp.h
7701 @@ -50,7 +50,7 @@ struct smp_ops_t {
7702 int (*cpu_disable)(void);
7703 void (*cpu_die)(unsigned int nr);
7704 int (*cpu_bootable)(unsigned int nr);
7705 -};
7706 +} __no_const;
7707
7708 extern void smp_send_debugger_break(void);
7709 extern void start_secondary_resume(void);
7710 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7711 index ba7b197..d292e26 100644
7712 --- a/arch/powerpc/include/asm/thread_info.h
7713 +++ b/arch/powerpc/include/asm/thread_info.h
7714 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7715 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7716 TIF_NEED_RESCHED */
7717 #define TIF_32BIT 4 /* 32 bit binary */
7718 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7719 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7720 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7721 #define TIF_SINGLESTEP 8 /* singlestepping active */
7722 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7723 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7724 for stack store? */
7725 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7726 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7727 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7728 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7729
7730 /* as above, but as bit values */
7731 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7732 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7733 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7734 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7735 #define _TIF_NOHZ (1<<TIF_NOHZ)
7736 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7737 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7738 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7739 - _TIF_NOHZ)
7740 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7741
7742 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7743 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7744 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7745 index 9485b43..4718d50 100644
7746 --- a/arch/powerpc/include/asm/uaccess.h
7747 +++ b/arch/powerpc/include/asm/uaccess.h
7748 @@ -318,52 +318,6 @@ do { \
7749 extern unsigned long __copy_tofrom_user(void __user *to,
7750 const void __user *from, unsigned long size);
7751
7752 -#ifndef __powerpc64__
7753 -
7754 -static inline unsigned long copy_from_user(void *to,
7755 - const void __user *from, unsigned long n)
7756 -{
7757 - unsigned long over;
7758 -
7759 - if (access_ok(VERIFY_READ, from, n))
7760 - return __copy_tofrom_user((__force void __user *)to, from, n);
7761 - if ((unsigned long)from < TASK_SIZE) {
7762 - over = (unsigned long)from + n - TASK_SIZE;
7763 - return __copy_tofrom_user((__force void __user *)to, from,
7764 - n - over) + over;
7765 - }
7766 - return n;
7767 -}
7768 -
7769 -static inline unsigned long copy_to_user(void __user *to,
7770 - const void *from, unsigned long n)
7771 -{
7772 - unsigned long over;
7773 -
7774 - if (access_ok(VERIFY_WRITE, to, n))
7775 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7776 - if ((unsigned long)to < TASK_SIZE) {
7777 - over = (unsigned long)to + n - TASK_SIZE;
7778 - return __copy_tofrom_user(to, (__force void __user *)from,
7779 - n - over) + over;
7780 - }
7781 - return n;
7782 -}
7783 -
7784 -#else /* __powerpc64__ */
7785 -
7786 -#define __copy_in_user(to, from, size) \
7787 - __copy_tofrom_user((to), (from), (size))
7788 -
7789 -extern unsigned long copy_from_user(void *to, const void __user *from,
7790 - unsigned long n);
7791 -extern unsigned long copy_to_user(void __user *to, const void *from,
7792 - unsigned long n);
7793 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7794 - unsigned long n);
7795 -
7796 -#endif /* __powerpc64__ */
7797 -
7798 static inline unsigned long __copy_from_user_inatomic(void *to,
7799 const void __user *from, unsigned long n)
7800 {
7801 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7802 if (ret == 0)
7803 return 0;
7804 }
7805 +
7806 + if (!__builtin_constant_p(n))
7807 + check_object_size(to, n, false);
7808 +
7809 return __copy_tofrom_user((__force void __user *)to, from, n);
7810 }
7811
7812 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7813 if (ret == 0)
7814 return 0;
7815 }
7816 +
7817 + if (!__builtin_constant_p(n))
7818 + check_object_size(from, n, true);
7819 +
7820 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7821 }
7822
7823 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7824 return __copy_to_user_inatomic(to, from, size);
7825 }
7826
7827 +#ifndef __powerpc64__
7828 +
7829 +static inline unsigned long __must_check copy_from_user(void *to,
7830 + const void __user *from, unsigned long n)
7831 +{
7832 + unsigned long over;
7833 +
7834 + if ((long)n < 0)
7835 + return n;
7836 +
7837 + if (access_ok(VERIFY_READ, from, n)) {
7838 + if (!__builtin_constant_p(n))
7839 + check_object_size(to, n, false);
7840 + return __copy_tofrom_user((__force void __user *)to, from, n);
7841 + }
7842 + if ((unsigned long)from < TASK_SIZE) {
7843 + over = (unsigned long)from + n - TASK_SIZE;
7844 + if (!__builtin_constant_p(n - over))
7845 + check_object_size(to, n - over, false);
7846 + return __copy_tofrom_user((__force void __user *)to, from,
7847 + n - over) + over;
7848 + }
7849 + return n;
7850 +}
7851 +
7852 +static inline unsigned long __must_check copy_to_user(void __user *to,
7853 + const void *from, unsigned long n)
7854 +{
7855 + unsigned long over;
7856 +
7857 + if ((long)n < 0)
7858 + return n;
7859 +
7860 + if (access_ok(VERIFY_WRITE, to, n)) {
7861 + if (!__builtin_constant_p(n))
7862 + check_object_size(from, n, true);
7863 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7864 + }
7865 + if ((unsigned long)to < TASK_SIZE) {
7866 + over = (unsigned long)to + n - TASK_SIZE;
7867 + if (!__builtin_constant_p(n))
7868 + check_object_size(from, n - over, true);
7869 + return __copy_tofrom_user(to, (__force void __user *)from,
7870 + n - over) + over;
7871 + }
7872 + return n;
7873 +}
7874 +
7875 +#else /* __powerpc64__ */
7876 +
7877 +#define __copy_in_user(to, from, size) \
7878 + __copy_tofrom_user((to), (from), (size))
7879 +
7880 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7881 +{
7882 + if ((long)n < 0 || n > INT_MAX)
7883 + return n;
7884 +
7885 + if (!__builtin_constant_p(n))
7886 + check_object_size(to, n, false);
7887 +
7888 + if (likely(access_ok(VERIFY_READ, from, n)))
7889 + n = __copy_from_user(to, from, n);
7890 + else
7891 + memset(to, 0, n);
7892 + return n;
7893 +}
7894 +
7895 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7896 +{
7897 + if ((long)n < 0 || n > INT_MAX)
7898 + return n;
7899 +
7900 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7901 + if (!__builtin_constant_p(n))
7902 + check_object_size(from, n, true);
7903 + n = __copy_to_user(to, from, n);
7904 + }
7905 + return n;
7906 +}
7907 +
7908 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7909 + unsigned long n);
7910 +
7911 +#endif /* __powerpc64__ */
7912 +
7913 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7914
7915 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7916 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7917 index 2d06704..1616f1b 100644
7918 --- a/arch/powerpc/kernel/exceptions-64e.S
7919 +++ b/arch/powerpc/kernel/exceptions-64e.S
7920 @@ -757,6 +757,7 @@ storage_fault_common:
7921 std r14,_DAR(r1)
7922 std r15,_DSISR(r1)
7923 addi r3,r1,STACK_FRAME_OVERHEAD
7924 + bl .save_nvgprs
7925 mr r4,r14
7926 mr r5,r15
7927 ld r14,PACA_EXGEN+EX_R14(r13)
7928 @@ -765,8 +766,7 @@ storage_fault_common:
7929 cmpdi r3,0
7930 bne- 1f
7931 b .ret_from_except_lite
7932 -1: bl .save_nvgprs
7933 - mr r5,r3
7934 +1: mr r5,r3
7935 addi r3,r1,STACK_FRAME_OVERHEAD
7936 ld r4,_DAR(r1)
7937 bl .bad_page_fault
7938 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7939 index 3a9ed6a..b534681 100644
7940 --- a/arch/powerpc/kernel/exceptions-64s.S
7941 +++ b/arch/powerpc/kernel/exceptions-64s.S
7942 @@ -1364,10 +1364,10 @@ handle_page_fault:
7943 11: ld r4,_DAR(r1)
7944 ld r5,_DSISR(r1)
7945 addi r3,r1,STACK_FRAME_OVERHEAD
7946 + bl .save_nvgprs
7947 bl .do_page_fault
7948 cmpdi r3,0
7949 beq+ 12f
7950 - bl .save_nvgprs
7951 mr r5,r3
7952 addi r3,r1,STACK_FRAME_OVERHEAD
7953 lwz r4,_DAR(r1)
7954 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7955 index 2e3200c..72095ce 100644
7956 --- a/arch/powerpc/kernel/module_32.c
7957 +++ b/arch/powerpc/kernel/module_32.c
7958 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7959 me->arch.core_plt_section = i;
7960 }
7961 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7962 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7963 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7964 return -ENOEXEC;
7965 }
7966
7967 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7968
7969 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7970 /* Init, or core PLT? */
7971 - if (location >= mod->module_core
7972 - && location < mod->module_core + mod->core_size)
7973 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7974 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7975 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7976 - else
7977 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7978 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7979 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7980 + else {
7981 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7982 + return ~0UL;
7983 + }
7984
7985 /* Find this entry, or if that fails, the next avail. entry */
7986 while (entry->jump[0]) {
7987 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7988 index 96d2fdf..f6d10c8 100644
7989 --- a/arch/powerpc/kernel/process.c
7990 +++ b/arch/powerpc/kernel/process.c
7991 @@ -886,8 +886,8 @@ void show_regs(struct pt_regs * regs)
7992 * Lookup NIP late so we have the best change of getting the
7993 * above info out without failing
7994 */
7995 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7996 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7997 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7998 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7999 #endif
8000 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8001 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8002 @@ -1352,10 +1352,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8003 newsp = stack[0];
8004 ip = stack[STACK_FRAME_LR_SAVE];
8005 if (!firstframe || ip != lr) {
8006 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8007 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8008 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8009 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8010 - printk(" (%pS)",
8011 + printk(" (%pA)",
8012 (void *)current->ret_stack[curr_frame].ret);
8013 curr_frame--;
8014 }
8015 @@ -1375,7 +1375,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8016 struct pt_regs *regs = (struct pt_regs *)
8017 (sp + STACK_FRAME_OVERHEAD);
8018 lr = regs->link;
8019 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8020 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8021 regs->trap, (void *)regs->nip, (void *)lr);
8022 firstframe = 1;
8023 }
8024 @@ -1411,58 +1411,3 @@ void notrace __ppc64_runlatch_off(void)
8025 mtspr(SPRN_CTRLT, ctrl);
8026 }
8027 #endif /* CONFIG_PPC64 */
8028 -
8029 -unsigned long arch_align_stack(unsigned long sp)
8030 -{
8031 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8032 - sp -= get_random_int() & ~PAGE_MASK;
8033 - return sp & ~0xf;
8034 -}
8035 -
8036 -static inline unsigned long brk_rnd(void)
8037 -{
8038 - unsigned long rnd = 0;
8039 -
8040 - /* 8MB for 32bit, 1GB for 64bit */
8041 - if (is_32bit_task())
8042 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8043 - else
8044 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8045 -
8046 - return rnd << PAGE_SHIFT;
8047 -}
8048 -
8049 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8050 -{
8051 - unsigned long base = mm->brk;
8052 - unsigned long ret;
8053 -
8054 -#ifdef CONFIG_PPC_STD_MMU_64
8055 - /*
8056 - * If we are using 1TB segments and we are allowed to randomise
8057 - * the heap, we can put it above 1TB so it is backed by a 1TB
8058 - * segment. Otherwise the heap will be in the bottom 1TB
8059 - * which always uses 256MB segments and this may result in a
8060 - * performance penalty.
8061 - */
8062 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8063 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8064 -#endif
8065 -
8066 - ret = PAGE_ALIGN(base + brk_rnd());
8067 -
8068 - if (ret < mm->brk)
8069 - return mm->brk;
8070 -
8071 - return ret;
8072 -}
8073 -
8074 -unsigned long randomize_et_dyn(unsigned long base)
8075 -{
8076 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8077 -
8078 - if (ret < base)
8079 - return base;
8080 -
8081 - return ret;
8082 -}
8083 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8084 index 9a0d24c..e7fbedf 100644
8085 --- a/arch/powerpc/kernel/ptrace.c
8086 +++ b/arch/powerpc/kernel/ptrace.c
8087 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8088 return ret;
8089 }
8090
8091 +#ifdef CONFIG_GRKERNSEC_SETXID
8092 +extern void gr_delayed_cred_worker(void);
8093 +#endif
8094 +
8095 /*
8096 * We must return the syscall number to actually look up in the table.
8097 * This can be -1L to skip running any syscall at all.
8098 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8099
8100 secure_computing_strict(regs->gpr[0]);
8101
8102 +#ifdef CONFIG_GRKERNSEC_SETXID
8103 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8104 + gr_delayed_cred_worker();
8105 +#endif
8106 +
8107 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8108 tracehook_report_syscall_entry(regs))
8109 /*
8110 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8111 {
8112 int step;
8113
8114 +#ifdef CONFIG_GRKERNSEC_SETXID
8115 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8116 + gr_delayed_cred_worker();
8117 +#endif
8118 +
8119 audit_syscall_exit(regs);
8120
8121 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8122 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8123 index bebdf1a..7a9e095 100644
8124 --- a/arch/powerpc/kernel/signal_32.c
8125 +++ b/arch/powerpc/kernel/signal_32.c
8126 @@ -996,7 +996,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8127 /* Save user registers on the stack */
8128 frame = &rt_sf->uc.uc_mcontext;
8129 addr = frame;
8130 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8131 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8132 sigret = 0;
8133 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8134 } else {
8135 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8136 index f93ec28..97e0fbb 100644
8137 --- a/arch/powerpc/kernel/signal_64.c
8138 +++ b/arch/powerpc/kernel/signal_64.c
8139 @@ -757,7 +757,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8140 #endif
8141
8142 /* Set up to return from userspace. */
8143 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8144 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8145 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8146 } else {
8147 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8148 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8149 index f783c93..619baf1 100644
8150 --- a/arch/powerpc/kernel/traps.c
8151 +++ b/arch/powerpc/kernel/traps.c
8152 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8153 return flags;
8154 }
8155
8156 +extern void gr_handle_kernel_exploit(void);
8157 +
8158 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8159 int signr)
8160 {
8161 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8162 panic("Fatal exception in interrupt");
8163 if (panic_on_oops)
8164 panic("Fatal exception");
8165 +
8166 + gr_handle_kernel_exploit();
8167 +
8168 do_exit(signr);
8169 }
8170
8171 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8172 index 1d9c926..25f4741 100644
8173 --- a/arch/powerpc/kernel/vdso.c
8174 +++ b/arch/powerpc/kernel/vdso.c
8175 @@ -34,6 +34,7 @@
8176 #include <asm/firmware.h>
8177 #include <asm/vdso.h>
8178 #include <asm/vdso_datapage.h>
8179 +#include <asm/mman.h>
8180
8181 #include "setup.h"
8182
8183 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8184 vdso_base = VDSO32_MBASE;
8185 #endif
8186
8187 - current->mm->context.vdso_base = 0;
8188 + current->mm->context.vdso_base = ~0UL;
8189
8190 /* vDSO has a problem and was disabled, just don't "enable" it for the
8191 * process
8192 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8193 vdso_base = get_unmapped_area(NULL, vdso_base,
8194 (vdso_pages << PAGE_SHIFT) +
8195 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8196 - 0, 0);
8197 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8198 if (IS_ERR_VALUE(vdso_base)) {
8199 rc = vdso_base;
8200 goto fail_mmapsem;
8201 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8202 index 5eea6f3..5d10396 100644
8203 --- a/arch/powerpc/lib/usercopy_64.c
8204 +++ b/arch/powerpc/lib/usercopy_64.c
8205 @@ -9,22 +9,6 @@
8206 #include <linux/module.h>
8207 #include <asm/uaccess.h>
8208
8209 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8210 -{
8211 - if (likely(access_ok(VERIFY_READ, from, n)))
8212 - n = __copy_from_user(to, from, n);
8213 - else
8214 - memset(to, 0, n);
8215 - return n;
8216 -}
8217 -
8218 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8219 -{
8220 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8221 - n = __copy_to_user(to, from, n);
8222 - return n;
8223 -}
8224 -
8225 unsigned long copy_in_user(void __user *to, const void __user *from,
8226 unsigned long n)
8227 {
8228 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8229 return n;
8230 }
8231
8232 -EXPORT_SYMBOL(copy_from_user);
8233 -EXPORT_SYMBOL(copy_to_user);
8234 EXPORT_SYMBOL(copy_in_user);
8235
8236 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8237 index 51ab9e7..7d3c78b 100644
8238 --- a/arch/powerpc/mm/fault.c
8239 +++ b/arch/powerpc/mm/fault.c
8240 @@ -33,6 +33,10 @@
8241 #include <linux/magic.h>
8242 #include <linux/ratelimit.h>
8243 #include <linux/context_tracking.h>
8244 +#include <linux/slab.h>
8245 +#include <linux/pagemap.h>
8246 +#include <linux/compiler.h>
8247 +#include <linux/unistd.h>
8248
8249 #include <asm/firmware.h>
8250 #include <asm/page.h>
8251 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8252 }
8253 #endif
8254
8255 +#ifdef CONFIG_PAX_PAGEEXEC
8256 +/*
8257 + * PaX: decide what to do with offenders (regs->nip = fault address)
8258 + *
8259 + * returns 1 when task should be killed
8260 + */
8261 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8262 +{
8263 + return 1;
8264 +}
8265 +
8266 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8267 +{
8268 + unsigned long i;
8269 +
8270 + printk(KERN_ERR "PAX: bytes at PC: ");
8271 + for (i = 0; i < 5; i++) {
8272 + unsigned int c;
8273 + if (get_user(c, (unsigned int __user *)pc+i))
8274 + printk(KERN_CONT "???????? ");
8275 + else
8276 + printk(KERN_CONT "%08x ", c);
8277 + }
8278 + printk("\n");
8279 +}
8280 +#endif
8281 +
8282 /*
8283 * Check whether the instruction at regs->nip is a store using
8284 * an update addressing form which will update r1.
8285 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8286 * indicate errors in DSISR but can validly be set in SRR1.
8287 */
8288 if (trap == 0x400)
8289 - error_code &= 0x48200000;
8290 + error_code &= 0x58200000;
8291 else
8292 is_write = error_code & DSISR_ISSTORE;
8293 #else
8294 @@ -378,7 +409,7 @@ good_area:
8295 * "undefined". Of those that can be set, this is the only
8296 * one which seems bad.
8297 */
8298 - if (error_code & 0x10000000)
8299 + if (error_code & DSISR_GUARDED)
8300 /* Guarded storage error. */
8301 goto bad_area;
8302 #endif /* CONFIG_8xx */
8303 @@ -393,7 +424,7 @@ good_area:
8304 * processors use the same I/D cache coherency mechanism
8305 * as embedded.
8306 */
8307 - if (error_code & DSISR_PROTFAULT)
8308 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8309 goto bad_area;
8310 #endif /* CONFIG_PPC_STD_MMU */
8311
8312 @@ -483,6 +514,23 @@ bad_area:
8313 bad_area_nosemaphore:
8314 /* User mode accesses cause a SIGSEGV */
8315 if (user_mode(regs)) {
8316 +
8317 +#ifdef CONFIG_PAX_PAGEEXEC
8318 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8319 +#ifdef CONFIG_PPC_STD_MMU
8320 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8321 +#else
8322 + if (is_exec && regs->nip == address) {
8323 +#endif
8324 + switch (pax_handle_fetch_fault(regs)) {
8325 + }
8326 +
8327 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8328 + do_group_exit(SIGKILL);
8329 + }
8330 + }
8331 +#endif
8332 +
8333 _exception(SIGSEGV, regs, code, address);
8334 goto bail;
8335 }
8336 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8337 index cb8bdbe..d770680 100644
8338 --- a/arch/powerpc/mm/mmap.c
8339 +++ b/arch/powerpc/mm/mmap.c
8340 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8341 {
8342 unsigned long rnd = 0;
8343
8344 +#ifdef CONFIG_PAX_RANDMMAP
8345 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8346 +#endif
8347 +
8348 if (current->flags & PF_RANDOMIZE) {
8349 /* 8MB for 32bit, 1GB for 64bit */
8350 if (is_32bit_task())
8351 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8352 */
8353 if (mmap_is_legacy()) {
8354 mm->mmap_base = TASK_UNMAPPED_BASE;
8355 +
8356 +#ifdef CONFIG_PAX_RANDMMAP
8357 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8358 + mm->mmap_base += mm->delta_mmap;
8359 +#endif
8360 +
8361 mm->get_unmapped_area = arch_get_unmapped_area;
8362 } else {
8363 mm->mmap_base = mmap_base();
8364 +
8365 +#ifdef CONFIG_PAX_RANDMMAP
8366 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8367 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8368 +#endif
8369 +
8370 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8371 }
8372 }
8373 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8374 index 3e99c14..f00953c 100644
8375 --- a/arch/powerpc/mm/slice.c
8376 +++ b/arch/powerpc/mm/slice.c
8377 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8378 if ((mm->task_size - len) < addr)
8379 return 0;
8380 vma = find_vma(mm, addr);
8381 - return (!vma || (addr + len) <= vma->vm_start);
8382 + return check_heap_stack_gap(vma, addr, len, 0);
8383 }
8384
8385 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8386 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8387 info.align_offset = 0;
8388
8389 addr = TASK_UNMAPPED_BASE;
8390 +
8391 +#ifdef CONFIG_PAX_RANDMMAP
8392 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8393 + addr += mm->delta_mmap;
8394 +#endif
8395 +
8396 while (addr < TASK_SIZE) {
8397 info.low_limit = addr;
8398 if (!slice_scan_available(addr, available, 1, &addr))
8399 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8400 if (fixed && addr > (mm->task_size - len))
8401 return -EINVAL;
8402
8403 +#ifdef CONFIG_PAX_RANDMMAP
8404 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8405 + addr = 0;
8406 +#endif
8407 +
8408 /* If hint, make sure it matches our alignment restrictions */
8409 if (!fixed && addr) {
8410 addr = _ALIGN_UP(addr, 1ul << pshift);
8411 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8412 index 9098692..3d54cd1 100644
8413 --- a/arch/powerpc/platforms/cell/spufs/file.c
8414 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8415 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8416 return VM_FAULT_NOPAGE;
8417 }
8418
8419 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8420 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8421 unsigned long address,
8422 - void *buf, int len, int write)
8423 + void *buf, size_t len, int write)
8424 {
8425 struct spu_context *ctx = vma->vm_file->private_data;
8426 unsigned long offset = address - vma->vm_start;
8427 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8428 index c797832..ce575c8 100644
8429 --- a/arch/s390/include/asm/atomic.h
8430 +++ b/arch/s390/include/asm/atomic.h
8431 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8432 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8433 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8434
8435 +#define atomic64_read_unchecked(v) atomic64_read(v)
8436 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8437 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8438 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8439 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8440 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8441 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8442 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8443 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8444 +
8445 #define smp_mb__before_atomic_dec() smp_mb()
8446 #define smp_mb__after_atomic_dec() smp_mb()
8447 #define smp_mb__before_atomic_inc() smp_mb()
8448 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8449 index 4d7ccac..d03d0ad 100644
8450 --- a/arch/s390/include/asm/cache.h
8451 +++ b/arch/s390/include/asm/cache.h
8452 @@ -9,8 +9,10 @@
8453 #ifndef __ARCH_S390_CACHE_H
8454 #define __ARCH_S390_CACHE_H
8455
8456 -#define L1_CACHE_BYTES 256
8457 +#include <linux/const.h>
8458 +
8459 #define L1_CACHE_SHIFT 8
8460 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8461 #define NET_SKB_PAD 32
8462
8463 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8464 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8465 index 78f4f87..598ce39 100644
8466 --- a/arch/s390/include/asm/elf.h
8467 +++ b/arch/s390/include/asm/elf.h
8468 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8469 the loader. We need to make sure that it is out of the way of the program
8470 that it will "exec", and that there is sufficient room for the brk. */
8471
8472 -extern unsigned long randomize_et_dyn(unsigned long base);
8473 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8474 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8475 +
8476 +#ifdef CONFIG_PAX_ASLR
8477 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8478 +
8479 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8480 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8481 +#endif
8482
8483 /* This yields a mask that user programs can use to figure out what
8484 instruction set this CPU supports. */
8485 @@ -222,9 +228,6 @@ struct linux_binprm;
8486 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8487 int arch_setup_additional_pages(struct linux_binprm *, int);
8488
8489 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8490 -#define arch_randomize_brk arch_randomize_brk
8491 -
8492 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8493
8494 #endif
8495 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8496 index c4a93d6..4d2a9b4 100644
8497 --- a/arch/s390/include/asm/exec.h
8498 +++ b/arch/s390/include/asm/exec.h
8499 @@ -7,6 +7,6 @@
8500 #ifndef __ASM_EXEC_H
8501 #define __ASM_EXEC_H
8502
8503 -extern unsigned long arch_align_stack(unsigned long sp);
8504 +#define arch_align_stack(x) ((x) & ~0xfUL)
8505
8506 #endif /* __ASM_EXEC_H */
8507 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8508 index 9c33ed4..e40cbef 100644
8509 --- a/arch/s390/include/asm/uaccess.h
8510 +++ b/arch/s390/include/asm/uaccess.h
8511 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8512 copy_to_user(void __user *to, const void *from, unsigned long n)
8513 {
8514 might_fault();
8515 +
8516 + if ((long)n < 0)
8517 + return n;
8518 +
8519 return __copy_to_user(to, from, n);
8520 }
8521
8522 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8523 static inline unsigned long __must_check
8524 __copy_from_user(void *to, const void __user *from, unsigned long n)
8525 {
8526 + if ((long)n < 0)
8527 + return n;
8528 +
8529 if (__builtin_constant_p(n) && (n <= 256))
8530 return uaccess.copy_from_user_small(n, from, to);
8531 else
8532 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8533 static inline unsigned long __must_check
8534 copy_from_user(void *to, const void __user *from, unsigned long n)
8535 {
8536 - unsigned int sz = __compiletime_object_size(to);
8537 + size_t sz = __compiletime_object_size(to);
8538
8539 might_fault();
8540 - if (unlikely(sz != -1 && sz < n)) {
8541 +
8542 + if ((long)n < 0)
8543 + return n;
8544 +
8545 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8546 copy_from_user_overflow();
8547 return n;
8548 }
8549 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8550 index 7845e15..59c4353 100644
8551 --- a/arch/s390/kernel/module.c
8552 +++ b/arch/s390/kernel/module.c
8553 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8554
8555 /* Increase core size by size of got & plt and set start
8556 offsets for got and plt. */
8557 - me->core_size = ALIGN(me->core_size, 4);
8558 - me->arch.got_offset = me->core_size;
8559 - me->core_size += me->arch.got_size;
8560 - me->arch.plt_offset = me->core_size;
8561 - me->core_size += me->arch.plt_size;
8562 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8563 + me->arch.got_offset = me->core_size_rw;
8564 + me->core_size_rw += me->arch.got_size;
8565 + me->arch.plt_offset = me->core_size_rx;
8566 + me->core_size_rx += me->arch.plt_size;
8567 return 0;
8568 }
8569
8570 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8571 if (info->got_initialized == 0) {
8572 Elf_Addr *gotent;
8573
8574 - gotent = me->module_core + me->arch.got_offset +
8575 + gotent = me->module_core_rw + me->arch.got_offset +
8576 info->got_offset;
8577 *gotent = val;
8578 info->got_initialized = 1;
8579 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8580 rc = apply_rela_bits(loc, val, 0, 64, 0);
8581 else if (r_type == R_390_GOTENT ||
8582 r_type == R_390_GOTPLTENT) {
8583 - val += (Elf_Addr) me->module_core - loc;
8584 + val += (Elf_Addr) me->module_core_rw - loc;
8585 rc = apply_rela_bits(loc, val, 1, 32, 1);
8586 }
8587 break;
8588 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8589 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8590 if (info->plt_initialized == 0) {
8591 unsigned int *ip;
8592 - ip = me->module_core + me->arch.plt_offset +
8593 + ip = me->module_core_rx + me->arch.plt_offset +
8594 info->plt_offset;
8595 #ifndef CONFIG_64BIT
8596 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8597 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8598 val - loc + 0xffffUL < 0x1ffffeUL) ||
8599 (r_type == R_390_PLT32DBL &&
8600 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8601 - val = (Elf_Addr) me->module_core +
8602 + val = (Elf_Addr) me->module_core_rx +
8603 me->arch.plt_offset +
8604 info->plt_offset;
8605 val += rela->r_addend - loc;
8606 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8607 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8608 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8609 val = val + rela->r_addend -
8610 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8611 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8612 if (r_type == R_390_GOTOFF16)
8613 rc = apply_rela_bits(loc, val, 0, 16, 0);
8614 else if (r_type == R_390_GOTOFF32)
8615 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8616 break;
8617 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8618 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8619 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8620 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8621 rela->r_addend - loc;
8622 if (r_type == R_390_GOTPC)
8623 rc = apply_rela_bits(loc, val, 1, 32, 0);
8624 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8625 index c5dbb33..b41f4ee 100644
8626 --- a/arch/s390/kernel/process.c
8627 +++ b/arch/s390/kernel/process.c
8628 @@ -237,39 +237,3 @@ unsigned long get_wchan(struct task_struct *p)
8629 }
8630 return 0;
8631 }
8632 -
8633 -unsigned long arch_align_stack(unsigned long sp)
8634 -{
8635 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8636 - sp -= get_random_int() & ~PAGE_MASK;
8637 - return sp & ~0xf;
8638 -}
8639 -
8640 -static inline unsigned long brk_rnd(void)
8641 -{
8642 - /* 8MB for 32bit, 1GB for 64bit */
8643 - if (is_32bit_task())
8644 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8645 - else
8646 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8647 -}
8648 -
8649 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8650 -{
8651 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8652 -
8653 - if (ret < mm->brk)
8654 - return mm->brk;
8655 - return ret;
8656 -}
8657 -
8658 -unsigned long randomize_et_dyn(unsigned long base)
8659 -{
8660 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8661 -
8662 - if (!(current->flags & PF_RANDOMIZE))
8663 - return base;
8664 - if (ret < base)
8665 - return base;
8666 - return ret;
8667 -}
8668 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8669 index 4002329..99b67cb 100644
8670 --- a/arch/s390/mm/mmap.c
8671 +++ b/arch/s390/mm/mmap.c
8672 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8673 */
8674 if (mmap_is_legacy()) {
8675 mm->mmap_base = TASK_UNMAPPED_BASE;
8676 +
8677 +#ifdef CONFIG_PAX_RANDMMAP
8678 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8679 + mm->mmap_base += mm->delta_mmap;
8680 +#endif
8681 +
8682 mm->get_unmapped_area = arch_get_unmapped_area;
8683 } else {
8684 mm->mmap_base = mmap_base();
8685 +
8686 +#ifdef CONFIG_PAX_RANDMMAP
8687 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8688 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8689 +#endif
8690 +
8691 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8692 }
8693 }
8694 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8695 */
8696 if (mmap_is_legacy()) {
8697 mm->mmap_base = TASK_UNMAPPED_BASE;
8698 +
8699 +#ifdef CONFIG_PAX_RANDMMAP
8700 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8701 + mm->mmap_base += mm->delta_mmap;
8702 +#endif
8703 +
8704 mm->get_unmapped_area = s390_get_unmapped_area;
8705 } else {
8706 mm->mmap_base = mmap_base();
8707 +
8708 +#ifdef CONFIG_PAX_RANDMMAP
8709 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8710 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8711 +#endif
8712 +
8713 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8714 }
8715 }
8716 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8717 index ae3d59f..f65f075 100644
8718 --- a/arch/score/include/asm/cache.h
8719 +++ b/arch/score/include/asm/cache.h
8720 @@ -1,7 +1,9 @@
8721 #ifndef _ASM_SCORE_CACHE_H
8722 #define _ASM_SCORE_CACHE_H
8723
8724 +#include <linux/const.h>
8725 +
8726 #define L1_CACHE_SHIFT 4
8727 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8728 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8729
8730 #endif /* _ASM_SCORE_CACHE_H */
8731 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8732 index f9f3cd5..58ff438 100644
8733 --- a/arch/score/include/asm/exec.h
8734 +++ b/arch/score/include/asm/exec.h
8735 @@ -1,6 +1,6 @@
8736 #ifndef _ASM_SCORE_EXEC_H
8737 #define _ASM_SCORE_EXEC_H
8738
8739 -extern unsigned long arch_align_stack(unsigned long sp);
8740 +#define arch_align_stack(x) (x)
8741
8742 #endif /* _ASM_SCORE_EXEC_H */
8743 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8744 index a1519ad3..e8ac1ff 100644
8745 --- a/arch/score/kernel/process.c
8746 +++ b/arch/score/kernel/process.c
8747 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8748
8749 return task_pt_regs(task)->cp0_epc;
8750 }
8751 -
8752 -unsigned long arch_align_stack(unsigned long sp)
8753 -{
8754 - return sp;
8755 -}
8756 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8757 index ef9e555..331bd29 100644
8758 --- a/arch/sh/include/asm/cache.h
8759 +++ b/arch/sh/include/asm/cache.h
8760 @@ -9,10 +9,11 @@
8761 #define __ASM_SH_CACHE_H
8762 #ifdef __KERNEL__
8763
8764 +#include <linux/const.h>
8765 #include <linux/init.h>
8766 #include <cpu/cache.h>
8767
8768 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8769 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8770
8771 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8772
8773 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8774 index 6777177..cb5e44f 100644
8775 --- a/arch/sh/mm/mmap.c
8776 +++ b/arch/sh/mm/mmap.c
8777 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8778 struct mm_struct *mm = current->mm;
8779 struct vm_area_struct *vma;
8780 int do_colour_align;
8781 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8782 struct vm_unmapped_area_info info;
8783
8784 if (flags & MAP_FIXED) {
8785 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8786 if (filp || (flags & MAP_SHARED))
8787 do_colour_align = 1;
8788
8789 +#ifdef CONFIG_PAX_RANDMMAP
8790 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8791 +#endif
8792 +
8793 if (addr) {
8794 if (do_colour_align)
8795 addr = COLOUR_ALIGN(addr, pgoff);
8796 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8797 addr = PAGE_ALIGN(addr);
8798
8799 vma = find_vma(mm, addr);
8800 - if (TASK_SIZE - len >= addr &&
8801 - (!vma || addr + len <= vma->vm_start))
8802 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8803 return addr;
8804 }
8805
8806 info.flags = 0;
8807 info.length = len;
8808 - info.low_limit = TASK_UNMAPPED_BASE;
8809 + info.low_limit = mm->mmap_base;
8810 info.high_limit = TASK_SIZE;
8811 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8812 info.align_offset = pgoff << PAGE_SHIFT;
8813 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8814 struct mm_struct *mm = current->mm;
8815 unsigned long addr = addr0;
8816 int do_colour_align;
8817 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8818 struct vm_unmapped_area_info info;
8819
8820 if (flags & MAP_FIXED) {
8821 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8822 if (filp || (flags & MAP_SHARED))
8823 do_colour_align = 1;
8824
8825 +#ifdef CONFIG_PAX_RANDMMAP
8826 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8827 +#endif
8828 +
8829 /* requesting a specific address */
8830 if (addr) {
8831 if (do_colour_align)
8832 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8833 addr = PAGE_ALIGN(addr);
8834
8835 vma = find_vma(mm, addr);
8836 - if (TASK_SIZE - len >= addr &&
8837 - (!vma || addr + len <= vma->vm_start))
8838 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8839 return addr;
8840 }
8841
8842 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8843 VM_BUG_ON(addr != -ENOMEM);
8844 info.flags = 0;
8845 info.low_limit = TASK_UNMAPPED_BASE;
8846 +
8847 +#ifdef CONFIG_PAX_RANDMMAP
8848 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8849 + info.low_limit += mm->delta_mmap;
8850 +#endif
8851 +
8852 info.high_limit = TASK_SIZE;
8853 addr = vm_unmapped_area(&info);
8854 }
8855 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8856 index be56a24..443328f 100644
8857 --- a/arch/sparc/include/asm/atomic_64.h
8858 +++ b/arch/sparc/include/asm/atomic_64.h
8859 @@ -14,18 +14,40 @@
8860 #define ATOMIC64_INIT(i) { (i) }
8861
8862 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8863 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8864 +{
8865 + return v->counter;
8866 +}
8867 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8868 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8869 +{
8870 + return v->counter;
8871 +}
8872
8873 #define atomic_set(v, i) (((v)->counter) = i)
8874 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8875 +{
8876 + v->counter = i;
8877 +}
8878 #define atomic64_set(v, i) (((v)->counter) = i)
8879 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8880 +{
8881 + v->counter = i;
8882 +}
8883
8884 extern void atomic_add(int, atomic_t *);
8885 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8886 extern void atomic64_add(long, atomic64_t *);
8887 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8888 extern void atomic_sub(int, atomic_t *);
8889 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8890 extern void atomic64_sub(long, atomic64_t *);
8891 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8892
8893 extern int atomic_add_ret(int, atomic_t *);
8894 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8895 extern long atomic64_add_ret(long, atomic64_t *);
8896 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8897 extern int atomic_sub_ret(int, atomic_t *);
8898 extern long atomic64_sub_ret(long, atomic64_t *);
8899
8900 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8901 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8902
8903 #define atomic_inc_return(v) atomic_add_ret(1, v)
8904 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8905 +{
8906 + return atomic_add_ret_unchecked(1, v);
8907 +}
8908 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8909 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8910 +{
8911 + return atomic64_add_ret_unchecked(1, v);
8912 +}
8913
8914 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8915 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8916
8917 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8918 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8919 +{
8920 + return atomic_add_ret_unchecked(i, v);
8921 +}
8922 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8923 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8924 +{
8925 + return atomic64_add_ret_unchecked(i, v);
8926 +}
8927
8928 /*
8929 * atomic_inc_and_test - increment and test
8930 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8931 * other cases.
8932 */
8933 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8934 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8935 +{
8936 + return atomic_inc_return_unchecked(v) == 0;
8937 +}
8938 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8939
8940 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8941 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8942 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8943
8944 #define atomic_inc(v) atomic_add(1, v)
8945 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8946 +{
8947 + atomic_add_unchecked(1, v);
8948 +}
8949 #define atomic64_inc(v) atomic64_add(1, v)
8950 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8951 +{
8952 + atomic64_add_unchecked(1, v);
8953 +}
8954
8955 #define atomic_dec(v) atomic_sub(1, v)
8956 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8957 +{
8958 + atomic_sub_unchecked(1, v);
8959 +}
8960 #define atomic64_dec(v) atomic64_sub(1, v)
8961 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8962 +{
8963 + atomic64_sub_unchecked(1, v);
8964 +}
8965
8966 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8967 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8968
8969 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8970 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8971 +{
8972 + return cmpxchg(&v->counter, old, new);
8973 +}
8974 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8975 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8976 +{
8977 + return xchg(&v->counter, new);
8978 +}
8979
8980 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8981 {
8982 - int c, old;
8983 + int c, old, new;
8984 c = atomic_read(v);
8985 for (;;) {
8986 - if (unlikely(c == (u)))
8987 + if (unlikely(c == u))
8988 break;
8989 - old = atomic_cmpxchg((v), c, c + (a));
8990 +
8991 + asm volatile("addcc %2, %0, %0\n"
8992 +
8993 +#ifdef CONFIG_PAX_REFCOUNT
8994 + "tvs %%icc, 6\n"
8995 +#endif
8996 +
8997 + : "=r" (new)
8998 + : "0" (c), "ir" (a)
8999 + : "cc");
9000 +
9001 + old = atomic_cmpxchg(v, c, new);
9002 if (likely(old == c))
9003 break;
9004 c = old;
9005 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9006 #define atomic64_cmpxchg(v, o, n) \
9007 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9008 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9009 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9010 +{
9011 + return xchg(&v->counter, new);
9012 +}
9013
9014 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9015 {
9016 - long c, old;
9017 + long c, old, new;
9018 c = atomic64_read(v);
9019 for (;;) {
9020 - if (unlikely(c == (u)))
9021 + if (unlikely(c == u))
9022 break;
9023 - old = atomic64_cmpxchg((v), c, c + (a));
9024 +
9025 + asm volatile("addcc %2, %0, %0\n"
9026 +
9027 +#ifdef CONFIG_PAX_REFCOUNT
9028 + "tvs %%xcc, 6\n"
9029 +#endif
9030 +
9031 + : "=r" (new)
9032 + : "0" (c), "ir" (a)
9033 + : "cc");
9034 +
9035 + old = atomic64_cmpxchg(v, c, new);
9036 if (likely(old == c))
9037 break;
9038 c = old;
9039 }
9040 - return c != (u);
9041 + return c != u;
9042 }
9043
9044 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9045 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9046 index 5bb6991..5c2132e 100644
9047 --- a/arch/sparc/include/asm/cache.h
9048 +++ b/arch/sparc/include/asm/cache.h
9049 @@ -7,10 +7,12 @@
9050 #ifndef _SPARC_CACHE_H
9051 #define _SPARC_CACHE_H
9052
9053 +#include <linux/const.h>
9054 +
9055 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9056
9057 #define L1_CACHE_SHIFT 5
9058 -#define L1_CACHE_BYTES 32
9059 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9060
9061 #ifdef CONFIG_SPARC32
9062 #define SMP_CACHE_BYTES_SHIFT 5
9063 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9064 index a24e41f..47677ff 100644
9065 --- a/arch/sparc/include/asm/elf_32.h
9066 +++ b/arch/sparc/include/asm/elf_32.h
9067 @@ -114,6 +114,13 @@ typedef struct {
9068
9069 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9070
9071 +#ifdef CONFIG_PAX_ASLR
9072 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9073 +
9074 +#define PAX_DELTA_MMAP_LEN 16
9075 +#define PAX_DELTA_STACK_LEN 16
9076 +#endif
9077 +
9078 /* This yields a mask that user programs can use to figure out what
9079 instruction set this cpu supports. This can NOT be done in userspace
9080 on Sparc. */
9081 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9082 index 370ca1e..d4f4a98 100644
9083 --- a/arch/sparc/include/asm/elf_64.h
9084 +++ b/arch/sparc/include/asm/elf_64.h
9085 @@ -189,6 +189,13 @@ typedef struct {
9086 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9087 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9088
9089 +#ifdef CONFIG_PAX_ASLR
9090 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9091 +
9092 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9093 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9094 +#endif
9095 +
9096 extern unsigned long sparc64_elf_hwcap;
9097 #define ELF_HWCAP sparc64_elf_hwcap
9098
9099 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9100 index 9b1c36d..209298b 100644
9101 --- a/arch/sparc/include/asm/pgalloc_32.h
9102 +++ b/arch/sparc/include/asm/pgalloc_32.h
9103 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9104 }
9105
9106 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9107 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9108
9109 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9110 unsigned long address)
9111 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9112 index bcfe063..b333142 100644
9113 --- a/arch/sparc/include/asm/pgalloc_64.h
9114 +++ b/arch/sparc/include/asm/pgalloc_64.h
9115 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9116 }
9117
9118 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9119 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9120
9121 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9122 {
9123 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9124 index 502f632..da1917f 100644
9125 --- a/arch/sparc/include/asm/pgtable_32.h
9126 +++ b/arch/sparc/include/asm/pgtable_32.h
9127 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9128 #define PAGE_SHARED SRMMU_PAGE_SHARED
9129 #define PAGE_COPY SRMMU_PAGE_COPY
9130 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9131 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9132 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9133 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9134 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9135
9136 /* Top-level page directory - dummy used by init-mm.
9137 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9138
9139 /* xwr */
9140 #define __P000 PAGE_NONE
9141 -#define __P001 PAGE_READONLY
9142 -#define __P010 PAGE_COPY
9143 -#define __P011 PAGE_COPY
9144 +#define __P001 PAGE_READONLY_NOEXEC
9145 +#define __P010 PAGE_COPY_NOEXEC
9146 +#define __P011 PAGE_COPY_NOEXEC
9147 #define __P100 PAGE_READONLY
9148 #define __P101 PAGE_READONLY
9149 #define __P110 PAGE_COPY
9150 #define __P111 PAGE_COPY
9151
9152 #define __S000 PAGE_NONE
9153 -#define __S001 PAGE_READONLY
9154 -#define __S010 PAGE_SHARED
9155 -#define __S011 PAGE_SHARED
9156 +#define __S001 PAGE_READONLY_NOEXEC
9157 +#define __S010 PAGE_SHARED_NOEXEC
9158 +#define __S011 PAGE_SHARED_NOEXEC
9159 #define __S100 PAGE_READONLY
9160 #define __S101 PAGE_READONLY
9161 #define __S110 PAGE_SHARED
9162 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9163 index 79da178..c2eede8 100644
9164 --- a/arch/sparc/include/asm/pgtsrmmu.h
9165 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9166 @@ -115,6 +115,11 @@
9167 SRMMU_EXEC | SRMMU_REF)
9168 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9169 SRMMU_EXEC | SRMMU_REF)
9170 +
9171 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9172 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9173 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9174 +
9175 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9176 SRMMU_DIRTY | SRMMU_REF)
9177
9178 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9179 index 9689176..63c18ea 100644
9180 --- a/arch/sparc/include/asm/spinlock_64.h
9181 +++ b/arch/sparc/include/asm/spinlock_64.h
9182 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9183
9184 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9185
9186 -static void inline arch_read_lock(arch_rwlock_t *lock)
9187 +static inline void arch_read_lock(arch_rwlock_t *lock)
9188 {
9189 unsigned long tmp1, tmp2;
9190
9191 __asm__ __volatile__ (
9192 "1: ldsw [%2], %0\n"
9193 " brlz,pn %0, 2f\n"
9194 -"4: add %0, 1, %1\n"
9195 +"4: addcc %0, 1, %1\n"
9196 +
9197 +#ifdef CONFIG_PAX_REFCOUNT
9198 +" tvs %%icc, 6\n"
9199 +#endif
9200 +
9201 " cas [%2], %0, %1\n"
9202 " cmp %0, %1\n"
9203 " bne,pn %%icc, 1b\n"
9204 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9205 " .previous"
9206 : "=&r" (tmp1), "=&r" (tmp2)
9207 : "r" (lock)
9208 - : "memory");
9209 + : "memory", "cc");
9210 }
9211
9212 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9213 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9214 {
9215 int tmp1, tmp2;
9216
9217 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9218 "1: ldsw [%2], %0\n"
9219 " brlz,a,pn %0, 2f\n"
9220 " mov 0, %0\n"
9221 -" add %0, 1, %1\n"
9222 +" addcc %0, 1, %1\n"
9223 +
9224 +#ifdef CONFIG_PAX_REFCOUNT
9225 +" tvs %%icc, 6\n"
9226 +#endif
9227 +
9228 " cas [%2], %0, %1\n"
9229 " cmp %0, %1\n"
9230 " bne,pn %%icc, 1b\n"
9231 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9232 return tmp1;
9233 }
9234
9235 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9236 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9237 {
9238 unsigned long tmp1, tmp2;
9239
9240 __asm__ __volatile__(
9241 "1: lduw [%2], %0\n"
9242 -" sub %0, 1, %1\n"
9243 +" subcc %0, 1, %1\n"
9244 +
9245 +#ifdef CONFIG_PAX_REFCOUNT
9246 +" tvs %%icc, 6\n"
9247 +#endif
9248 +
9249 " cas [%2], %0, %1\n"
9250 " cmp %0, %1\n"
9251 " bne,pn %%xcc, 1b\n"
9252 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9253 : "memory");
9254 }
9255
9256 -static void inline arch_write_lock(arch_rwlock_t *lock)
9257 +static inline void arch_write_lock(arch_rwlock_t *lock)
9258 {
9259 unsigned long mask, tmp1, tmp2;
9260
9261 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9262 : "memory");
9263 }
9264
9265 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9266 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9267 {
9268 __asm__ __volatile__(
9269 " stw %%g0, [%0]"
9270 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9271 : "memory");
9272 }
9273
9274 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9275 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9276 {
9277 unsigned long mask, tmp1, tmp2, result;
9278
9279 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9280 index dd38075..e7cac83 100644
9281 --- a/arch/sparc/include/asm/thread_info_32.h
9282 +++ b/arch/sparc/include/asm/thread_info_32.h
9283 @@ -49,6 +49,8 @@ struct thread_info {
9284 unsigned long w_saved;
9285
9286 struct restart_block restart_block;
9287 +
9288 + unsigned long lowest_stack;
9289 };
9290
9291 /*
9292 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9293 index d5e5042..9bfee76 100644
9294 --- a/arch/sparc/include/asm/thread_info_64.h
9295 +++ b/arch/sparc/include/asm/thread_info_64.h
9296 @@ -63,6 +63,8 @@ struct thread_info {
9297 struct pt_regs *kern_una_regs;
9298 unsigned int kern_una_insn;
9299
9300 + unsigned long lowest_stack;
9301 +
9302 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9303 };
9304
9305 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9306 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9307 /* flag bit 6 is available */
9308 #define TIF_32BIT 7 /* 32-bit binary */
9309 -/* flag bit 8 is available */
9310 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9311 #define TIF_SECCOMP 9 /* secure computing */
9312 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9313 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9314 +
9315 /* NOTE: Thread flags >= 12 should be ones we have no interest
9316 * in using in assembly, else we can't use the mask as
9317 * an immediate value in instructions such as andcc.
9318 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9319 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9320 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9321 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9322 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9323
9324 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9325 _TIF_DO_NOTIFY_RESUME_MASK | \
9326 _TIF_NEED_RESCHED)
9327 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9328
9329 +#define _TIF_WORK_SYSCALL \
9330 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9331 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9332 +
9333 +
9334 /*
9335 * Thread-synchronous status.
9336 *
9337 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9338 index 0167d26..767bb0c 100644
9339 --- a/arch/sparc/include/asm/uaccess.h
9340 +++ b/arch/sparc/include/asm/uaccess.h
9341 @@ -1,5 +1,6 @@
9342 #ifndef ___ASM_SPARC_UACCESS_H
9343 #define ___ASM_SPARC_UACCESS_H
9344 +
9345 #if defined(__sparc__) && defined(__arch64__)
9346 #include <asm/uaccess_64.h>
9347 #else
9348 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9349 index 53a28dd..50c38c3 100644
9350 --- a/arch/sparc/include/asm/uaccess_32.h
9351 +++ b/arch/sparc/include/asm/uaccess_32.h
9352 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9353
9354 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9355 {
9356 - if (n && __access_ok((unsigned long) to, n))
9357 + if ((long)n < 0)
9358 + return n;
9359 +
9360 + if (n && __access_ok((unsigned long) to, n)) {
9361 + if (!__builtin_constant_p(n))
9362 + check_object_size(from, n, true);
9363 return __copy_user(to, (__force void __user *) from, n);
9364 - else
9365 + } else
9366 return n;
9367 }
9368
9369 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9370 {
9371 + if ((long)n < 0)
9372 + return n;
9373 +
9374 + if (!__builtin_constant_p(n))
9375 + check_object_size(from, n, true);
9376 +
9377 return __copy_user(to, (__force void __user *) from, n);
9378 }
9379
9380 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9381 {
9382 - if (n && __access_ok((unsigned long) from, n))
9383 + if ((long)n < 0)
9384 + return n;
9385 +
9386 + if (n && __access_ok((unsigned long) from, n)) {
9387 + if (!__builtin_constant_p(n))
9388 + check_object_size(to, n, false);
9389 return __copy_user((__force void __user *) to, from, n);
9390 - else
9391 + } else
9392 return n;
9393 }
9394
9395 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9396 {
9397 + if ((long)n < 0)
9398 + return n;
9399 +
9400 return __copy_user((__force void __user *) to, from, n);
9401 }
9402
9403 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9404 index e562d3c..191f176 100644
9405 --- a/arch/sparc/include/asm/uaccess_64.h
9406 +++ b/arch/sparc/include/asm/uaccess_64.h
9407 @@ -10,6 +10,7 @@
9408 #include <linux/compiler.h>
9409 #include <linux/string.h>
9410 #include <linux/thread_info.h>
9411 +#include <linux/kernel.h>
9412 #include <asm/asi.h>
9413 #include <asm/spitfire.h>
9414 #include <asm-generic/uaccess-unaligned.h>
9415 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9416 static inline unsigned long __must_check
9417 copy_from_user(void *to, const void __user *from, unsigned long size)
9418 {
9419 - unsigned long ret = ___copy_from_user(to, from, size);
9420 + unsigned long ret;
9421
9422 + if ((long)size < 0 || size > INT_MAX)
9423 + return size;
9424 +
9425 + if (!__builtin_constant_p(size))
9426 + check_object_size(to, size, false);
9427 +
9428 + ret = ___copy_from_user(to, from, size);
9429 if (unlikely(ret))
9430 ret = copy_from_user_fixup(to, from, size);
9431
9432 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9433 static inline unsigned long __must_check
9434 copy_to_user(void __user *to, const void *from, unsigned long size)
9435 {
9436 - unsigned long ret = ___copy_to_user(to, from, size);
9437 + unsigned long ret;
9438
9439 + if ((long)size < 0 || size > INT_MAX)
9440 + return size;
9441 +
9442 + if (!__builtin_constant_p(size))
9443 + check_object_size(from, size, true);
9444 +
9445 + ret = ___copy_to_user(to, from, size);
9446 if (unlikely(ret))
9447 ret = copy_to_user_fixup(to, from, size);
9448 return ret;
9449 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9450 index d15cc17..d0ae796 100644
9451 --- a/arch/sparc/kernel/Makefile
9452 +++ b/arch/sparc/kernel/Makefile
9453 @@ -4,7 +4,7 @@
9454 #
9455
9456 asflags-y := -ansi
9457 -ccflags-y := -Werror
9458 +#ccflags-y := -Werror
9459
9460 extra-y := head_$(BITS).o
9461
9462 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9463 index fdd819d..5af08c8 100644
9464 --- a/arch/sparc/kernel/process_32.c
9465 +++ b/arch/sparc/kernel/process_32.c
9466 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9467
9468 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9469 r->psr, r->pc, r->npc, r->y, print_tainted());
9470 - printk("PC: <%pS>\n", (void *) r->pc);
9471 + printk("PC: <%pA>\n", (void *) r->pc);
9472 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9473 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9474 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9475 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9476 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9477 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9478 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9479 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9480
9481 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9482 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9483 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9484 rw = (struct reg_window32 *) fp;
9485 pc = rw->ins[7];
9486 printk("[%08lx : ", pc);
9487 - printk("%pS ] ", (void *) pc);
9488 + printk("%pA ] ", (void *) pc);
9489 fp = rw->ins[6];
9490 } while (++count < 16);
9491 printk("\n");
9492 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9493 index baebab2..9cd13b1 100644
9494 --- a/arch/sparc/kernel/process_64.c
9495 +++ b/arch/sparc/kernel/process_64.c
9496 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9497 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9498 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9499 if (regs->tstate & TSTATE_PRIV)
9500 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9501 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9502 }
9503
9504 void show_regs(struct pt_regs *regs)
9505 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9506
9507 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9508 regs->tpc, regs->tnpc, regs->y, print_tainted());
9509 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9510 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9511 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9512 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9513 regs->u_regs[3]);
9514 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9515 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9516 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9517 regs->u_regs[15]);
9518 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9519 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9520 show_regwindow(regs);
9521 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9522 }
9523 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9524 ((tp && tp->task) ? tp->task->pid : -1));
9525
9526 if (gp->tstate & TSTATE_PRIV) {
9527 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9528 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9529 (void *) gp->tpc,
9530 (void *) gp->o7,
9531 (void *) gp->i7,
9532 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9533 index 79cc0d1..ec62734 100644
9534 --- a/arch/sparc/kernel/prom_common.c
9535 +++ b/arch/sparc/kernel/prom_common.c
9536 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9537
9538 unsigned int prom_early_allocated __initdata;
9539
9540 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9541 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9542 .nextprop = prom_common_nextprop,
9543 .getproplen = prom_getproplen,
9544 .getproperty = prom_getproperty,
9545 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9546 index 773c1f2..a8bdd87 100644
9547 --- a/arch/sparc/kernel/ptrace_64.c
9548 +++ b/arch/sparc/kernel/ptrace_64.c
9549 @@ -1059,6 +1059,10 @@ long arch_ptrace(struct task_struct *child, long request,
9550 return ret;
9551 }
9552
9553 +#ifdef CONFIG_GRKERNSEC_SETXID
9554 +extern void gr_delayed_cred_worker(void);
9555 +#endif
9556 +
9557 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9558 {
9559 int ret = 0;
9560 @@ -1066,6 +1070,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9561 /* do the secure computing check first */
9562 secure_computing_strict(regs->u_regs[UREG_G1]);
9563
9564 +#ifdef CONFIG_GRKERNSEC_SETXID
9565 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9566 + gr_delayed_cred_worker();
9567 +#endif
9568 +
9569 if (test_thread_flag(TIF_SYSCALL_TRACE))
9570 ret = tracehook_report_syscall_entry(regs);
9571
9572 @@ -1086,6 +1095,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9573
9574 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9575 {
9576 +#ifdef CONFIG_GRKERNSEC_SETXID
9577 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9578 + gr_delayed_cred_worker();
9579 +#endif
9580 +
9581 audit_syscall_exit(regs);
9582
9583 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9584 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9585 index e142545..fd29654 100644
9586 --- a/arch/sparc/kernel/smp_64.c
9587 +++ b/arch/sparc/kernel/smp_64.c
9588 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9589 extern unsigned long xcall_flush_dcache_page_spitfire;
9590
9591 #ifdef CONFIG_DEBUG_DCFLUSH
9592 -extern atomic_t dcpage_flushes;
9593 -extern atomic_t dcpage_flushes_xcall;
9594 +extern atomic_unchecked_t dcpage_flushes;
9595 +extern atomic_unchecked_t dcpage_flushes_xcall;
9596 #endif
9597
9598 static inline void __local_flush_dcache_page(struct page *page)
9599 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9600 return;
9601
9602 #ifdef CONFIG_DEBUG_DCFLUSH
9603 - atomic_inc(&dcpage_flushes);
9604 + atomic_inc_unchecked(&dcpage_flushes);
9605 #endif
9606
9607 this_cpu = get_cpu();
9608 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9609 xcall_deliver(data0, __pa(pg_addr),
9610 (u64) pg_addr, cpumask_of(cpu));
9611 #ifdef CONFIG_DEBUG_DCFLUSH
9612 - atomic_inc(&dcpage_flushes_xcall);
9613 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9614 #endif
9615 }
9616 }
9617 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9618 preempt_disable();
9619
9620 #ifdef CONFIG_DEBUG_DCFLUSH
9621 - atomic_inc(&dcpage_flushes);
9622 + atomic_inc_unchecked(&dcpage_flushes);
9623 #endif
9624 data0 = 0;
9625 pg_addr = page_address(page);
9626 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9627 xcall_deliver(data0, __pa(pg_addr),
9628 (u64) pg_addr, cpu_online_mask);
9629 #ifdef CONFIG_DEBUG_DCFLUSH
9630 - atomic_inc(&dcpage_flushes_xcall);
9631 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9632 #endif
9633 }
9634 __local_flush_dcache_page(page);
9635 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9636 index 3a8d184..49498a8 100644
9637 --- a/arch/sparc/kernel/sys_sparc_32.c
9638 +++ b/arch/sparc/kernel/sys_sparc_32.c
9639 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9640 if (len > TASK_SIZE - PAGE_SIZE)
9641 return -ENOMEM;
9642 if (!addr)
9643 - addr = TASK_UNMAPPED_BASE;
9644 + addr = current->mm->mmap_base;
9645
9646 info.flags = 0;
9647 info.length = len;
9648 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9649 index 51561b8..8256764 100644
9650 --- a/arch/sparc/kernel/sys_sparc_64.c
9651 +++ b/arch/sparc/kernel/sys_sparc_64.c
9652 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9653 struct vm_area_struct * vma;
9654 unsigned long task_size = TASK_SIZE;
9655 int do_color_align;
9656 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9657 struct vm_unmapped_area_info info;
9658
9659 if (flags & MAP_FIXED) {
9660 /* We do not accept a shared mapping if it would violate
9661 * cache aliasing constraints.
9662 */
9663 - if ((flags & MAP_SHARED) &&
9664 + if ((filp || (flags & MAP_SHARED)) &&
9665 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9666 return -EINVAL;
9667 return addr;
9668 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9669 if (filp || (flags & MAP_SHARED))
9670 do_color_align = 1;
9671
9672 +#ifdef CONFIG_PAX_RANDMMAP
9673 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9674 +#endif
9675 +
9676 if (addr) {
9677 if (do_color_align)
9678 addr = COLOR_ALIGN(addr, pgoff);
9679 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9680 addr = PAGE_ALIGN(addr);
9681
9682 vma = find_vma(mm, addr);
9683 - if (task_size - len >= addr &&
9684 - (!vma || addr + len <= vma->vm_start))
9685 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9686 return addr;
9687 }
9688
9689 info.flags = 0;
9690 info.length = len;
9691 - info.low_limit = TASK_UNMAPPED_BASE;
9692 + info.low_limit = mm->mmap_base;
9693 info.high_limit = min(task_size, VA_EXCLUDE_START);
9694 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9695 info.align_offset = pgoff << PAGE_SHIFT;
9696 + info.threadstack_offset = offset;
9697 addr = vm_unmapped_area(&info);
9698
9699 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9700 VM_BUG_ON(addr != -ENOMEM);
9701 info.low_limit = VA_EXCLUDE_END;
9702 +
9703 +#ifdef CONFIG_PAX_RANDMMAP
9704 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9705 + info.low_limit += mm->delta_mmap;
9706 +#endif
9707 +
9708 info.high_limit = task_size;
9709 addr = vm_unmapped_area(&info);
9710 }
9711 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9712 unsigned long task_size = STACK_TOP32;
9713 unsigned long addr = addr0;
9714 int do_color_align;
9715 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9716 struct vm_unmapped_area_info info;
9717
9718 /* This should only ever run for 32-bit processes. */
9719 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9720 /* We do not accept a shared mapping if it would violate
9721 * cache aliasing constraints.
9722 */
9723 - if ((flags & MAP_SHARED) &&
9724 + if ((filp || (flags & MAP_SHARED)) &&
9725 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9726 return -EINVAL;
9727 return addr;
9728 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9729 if (filp || (flags & MAP_SHARED))
9730 do_color_align = 1;
9731
9732 +#ifdef CONFIG_PAX_RANDMMAP
9733 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9734 +#endif
9735 +
9736 /* requesting a specific address */
9737 if (addr) {
9738 if (do_color_align)
9739 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9740 addr = PAGE_ALIGN(addr);
9741
9742 vma = find_vma(mm, addr);
9743 - if (task_size - len >= addr &&
9744 - (!vma || addr + len <= vma->vm_start))
9745 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9746 return addr;
9747 }
9748
9749 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9750 info.high_limit = mm->mmap_base;
9751 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9752 info.align_offset = pgoff << PAGE_SHIFT;
9753 + info.threadstack_offset = offset;
9754 addr = vm_unmapped_area(&info);
9755
9756 /*
9757 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9758 VM_BUG_ON(addr != -ENOMEM);
9759 info.flags = 0;
9760 info.low_limit = TASK_UNMAPPED_BASE;
9761 +
9762 +#ifdef CONFIG_PAX_RANDMMAP
9763 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9764 + info.low_limit += mm->delta_mmap;
9765 +#endif
9766 +
9767 info.high_limit = STACK_TOP32;
9768 addr = vm_unmapped_area(&info);
9769 }
9770 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9771 EXPORT_SYMBOL(get_fb_unmapped_area);
9772
9773 /* Essentially the same as PowerPC. */
9774 -static unsigned long mmap_rnd(void)
9775 +static unsigned long mmap_rnd(struct mm_struct *mm)
9776 {
9777 unsigned long rnd = 0UL;
9778
9779 +#ifdef CONFIG_PAX_RANDMMAP
9780 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9781 +#endif
9782 +
9783 if (current->flags & PF_RANDOMIZE) {
9784 unsigned long val = get_random_int();
9785 if (test_thread_flag(TIF_32BIT))
9786 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9787
9788 void arch_pick_mmap_layout(struct mm_struct *mm)
9789 {
9790 - unsigned long random_factor = mmap_rnd();
9791 + unsigned long random_factor = mmap_rnd(mm);
9792 unsigned long gap;
9793
9794 /*
9795 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9796 gap == RLIM_INFINITY ||
9797 sysctl_legacy_va_layout) {
9798 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9799 +
9800 +#ifdef CONFIG_PAX_RANDMMAP
9801 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9802 + mm->mmap_base += mm->delta_mmap;
9803 +#endif
9804 +
9805 mm->get_unmapped_area = arch_get_unmapped_area;
9806 } else {
9807 /* We know it's 32-bit */
9808 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9809 gap = (task_size / 6 * 5);
9810
9811 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9812 +
9813 +#ifdef CONFIG_PAX_RANDMMAP
9814 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9815 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9816 +#endif
9817 +
9818 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9819 }
9820 }
9821 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9822 index d950197..192f9d8 100644
9823 --- a/arch/sparc/kernel/syscalls.S
9824 +++ b/arch/sparc/kernel/syscalls.S
9825 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9826 #endif
9827 .align 32
9828 1: ldx [%g6 + TI_FLAGS], %l5
9829 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9830 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9831 be,pt %icc, rtrap
9832 nop
9833 call syscall_trace_leave
9834 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9835
9836 srl %i3, 0, %o3 ! IEU0
9837 srl %i2, 0, %o2 ! IEU0 Group
9838 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9839 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9840 bne,pn %icc, linux_syscall_trace32 ! CTI
9841 mov %i0, %l5 ! IEU1
9842 5: call %l7 ! CTI Group brk forced
9843 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9844
9845 mov %i3, %o3 ! IEU1
9846 mov %i4, %o4 ! IEU0 Group
9847 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9848 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9849 bne,pn %icc, linux_syscall_trace ! CTI Group
9850 mov %i0, %l5 ! IEU0
9851 2: call %l7 ! CTI Group brk forced
9852 @@ -223,7 +223,7 @@ ret_sys_call:
9853
9854 cmp %o0, -ERESTART_RESTARTBLOCK
9855 bgeu,pn %xcc, 1f
9856 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9857 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9858 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9859
9860 2:
9861 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9862 index 6629829..036032d 100644
9863 --- a/arch/sparc/kernel/traps_32.c
9864 +++ b/arch/sparc/kernel/traps_32.c
9865 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9866 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9867 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9868
9869 +extern void gr_handle_kernel_exploit(void);
9870 +
9871 void die_if_kernel(char *str, struct pt_regs *regs)
9872 {
9873 static int die_counter;
9874 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9875 count++ < 30 &&
9876 (((unsigned long) rw) >= PAGE_OFFSET) &&
9877 !(((unsigned long) rw) & 0x7)) {
9878 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9879 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9880 (void *) rw->ins[7]);
9881 rw = (struct reg_window32 *)rw->ins[6];
9882 }
9883 }
9884 printk("Instruction DUMP:");
9885 instruction_dump ((unsigned long *) regs->pc);
9886 - if(regs->psr & PSR_PS)
9887 + if(regs->psr & PSR_PS) {
9888 + gr_handle_kernel_exploit();
9889 do_exit(SIGKILL);
9890 + }
9891 do_exit(SIGSEGV);
9892 }
9893
9894 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9895 index b3f833a..f485f80 100644
9896 --- a/arch/sparc/kernel/traps_64.c
9897 +++ b/arch/sparc/kernel/traps_64.c
9898 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9899 i + 1,
9900 p->trapstack[i].tstate, p->trapstack[i].tpc,
9901 p->trapstack[i].tnpc, p->trapstack[i].tt);
9902 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9903 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9904 }
9905 }
9906
9907 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9908
9909 lvl -= 0x100;
9910 if (regs->tstate & TSTATE_PRIV) {
9911 +
9912 +#ifdef CONFIG_PAX_REFCOUNT
9913 + if (lvl == 6)
9914 + pax_report_refcount_overflow(regs);
9915 +#endif
9916 +
9917 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9918 die_if_kernel(buffer, regs);
9919 }
9920 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9921 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9922 {
9923 char buffer[32];
9924 -
9925 +
9926 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9927 0, lvl, SIGTRAP) == NOTIFY_STOP)
9928 return;
9929
9930 +#ifdef CONFIG_PAX_REFCOUNT
9931 + if (lvl == 6)
9932 + pax_report_refcount_overflow(regs);
9933 +#endif
9934 +
9935 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9936
9937 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9938 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9939 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9940 printk("%s" "ERROR(%d): ",
9941 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9942 - printk("TPC<%pS>\n", (void *) regs->tpc);
9943 + printk("TPC<%pA>\n", (void *) regs->tpc);
9944 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9945 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9946 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9947 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9948 smp_processor_id(),
9949 (type & 0x1) ? 'I' : 'D',
9950 regs->tpc);
9951 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9952 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9953 panic("Irrecoverable Cheetah+ parity error.");
9954 }
9955
9956 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9957 smp_processor_id(),
9958 (type & 0x1) ? 'I' : 'D',
9959 regs->tpc);
9960 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9961 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9962 }
9963
9964 struct sun4v_error_entry {
9965 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9966 /*0x38*/u64 reserved_5;
9967 };
9968
9969 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9970 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9971 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9972 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9973
9974 static const char *sun4v_err_type_to_str(u8 type)
9975 {
9976 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9977 }
9978
9979 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9980 - int cpu, const char *pfx, atomic_t *ocnt)
9981 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9982 {
9983 u64 *raw_ptr = (u64 *) ent;
9984 u32 attrs;
9985 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9986
9987 show_regs(regs);
9988
9989 - if ((cnt = atomic_read(ocnt)) != 0) {
9990 - atomic_set(ocnt, 0);
9991 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9992 + atomic_set_unchecked(ocnt, 0);
9993 wmb();
9994 printk("%s: Queue overflowed %d times.\n",
9995 pfx, cnt);
9996 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9997 */
9998 void sun4v_resum_overflow(struct pt_regs *regs)
9999 {
10000 - atomic_inc(&sun4v_resum_oflow_cnt);
10001 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10002 }
10003
10004 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10005 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10006 /* XXX Actually even this can make not that much sense. Perhaps
10007 * XXX we should just pull the plug and panic directly from here?
10008 */
10009 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10010 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10011 }
10012
10013 unsigned long sun4v_err_itlb_vaddr;
10014 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10015
10016 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10017 regs->tpc, tl);
10018 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10019 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10020 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10021 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10022 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10023 (void *) regs->u_regs[UREG_I7]);
10024 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10025 "pte[%lx] error[%lx]\n",
10026 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10027
10028 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10029 regs->tpc, tl);
10030 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10031 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10032 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10033 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10034 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10035 (void *) regs->u_regs[UREG_I7]);
10036 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10037 "pte[%lx] error[%lx]\n",
10038 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10039 fp = (unsigned long)sf->fp + STACK_BIAS;
10040 }
10041
10042 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10043 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10044 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10045 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10046 int index = tsk->curr_ret_stack;
10047 if (tsk->ret_stack && index >= graph) {
10048 pc = tsk->ret_stack[index - graph].ret;
10049 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10050 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10051 graph++;
10052 }
10053 }
10054 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10055 return (struct reg_window *) (fp + STACK_BIAS);
10056 }
10057
10058 +extern void gr_handle_kernel_exploit(void);
10059 +
10060 void die_if_kernel(char *str, struct pt_regs *regs)
10061 {
10062 static int die_counter;
10063 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10064 while (rw &&
10065 count++ < 30 &&
10066 kstack_valid(tp, (unsigned long) rw)) {
10067 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10068 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10069 (void *) rw->ins[7]);
10070
10071 rw = kernel_stack_up(rw);
10072 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10073 }
10074 user_instruction_dump ((unsigned int __user *) regs->tpc);
10075 }
10076 - if (regs->tstate & TSTATE_PRIV)
10077 + if (regs->tstate & TSTATE_PRIV) {
10078 + gr_handle_kernel_exploit();
10079 do_exit(SIGKILL);
10080 + }
10081 do_exit(SIGSEGV);
10082 }
10083 EXPORT_SYMBOL(die_if_kernel);
10084 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10085 index 8201c25e..072a2a7 100644
10086 --- a/arch/sparc/kernel/unaligned_64.c
10087 +++ b/arch/sparc/kernel/unaligned_64.c
10088 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10089 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10090
10091 if (__ratelimit(&ratelimit)) {
10092 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10093 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10094 regs->tpc, (void *) regs->tpc);
10095 }
10096 }
10097 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10098 index dbe119b..089c7c1 100644
10099 --- a/arch/sparc/lib/Makefile
10100 +++ b/arch/sparc/lib/Makefile
10101 @@ -2,7 +2,7 @@
10102 #
10103
10104 asflags-y := -ansi -DST_DIV0=0x02
10105 -ccflags-y := -Werror
10106 +#ccflags-y := -Werror
10107
10108 lib-$(CONFIG_SPARC32) += ashrdi3.o
10109 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10110 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10111 index 85c233d..68500e0 100644
10112 --- a/arch/sparc/lib/atomic_64.S
10113 +++ b/arch/sparc/lib/atomic_64.S
10114 @@ -17,7 +17,12 @@
10115 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10116 BACKOFF_SETUP(%o2)
10117 1: lduw [%o1], %g1
10118 - add %g1, %o0, %g7
10119 + addcc %g1, %o0, %g7
10120 +
10121 +#ifdef CONFIG_PAX_REFCOUNT
10122 + tvs %icc, 6
10123 +#endif
10124 +
10125 cas [%o1], %g1, %g7
10126 cmp %g1, %g7
10127 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10128 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10129 2: BACKOFF_SPIN(%o2, %o3, 1b)
10130 ENDPROC(atomic_add)
10131
10132 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10133 + BACKOFF_SETUP(%o2)
10134 +1: lduw [%o1], %g1
10135 + add %g1, %o0, %g7
10136 + cas [%o1], %g1, %g7
10137 + cmp %g1, %g7
10138 + bne,pn %icc, 2f
10139 + nop
10140 + retl
10141 + nop
10142 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10143 +ENDPROC(atomic_add_unchecked)
10144 +
10145 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10146 BACKOFF_SETUP(%o2)
10147 1: lduw [%o1], %g1
10148 - sub %g1, %o0, %g7
10149 + subcc %g1, %o0, %g7
10150 +
10151 +#ifdef CONFIG_PAX_REFCOUNT
10152 + tvs %icc, 6
10153 +#endif
10154 +
10155 cas [%o1], %g1, %g7
10156 cmp %g1, %g7
10157 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10158 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10159 2: BACKOFF_SPIN(%o2, %o3, 1b)
10160 ENDPROC(atomic_sub)
10161
10162 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10163 + BACKOFF_SETUP(%o2)
10164 +1: lduw [%o1], %g1
10165 + sub %g1, %o0, %g7
10166 + cas [%o1], %g1, %g7
10167 + cmp %g1, %g7
10168 + bne,pn %icc, 2f
10169 + nop
10170 + retl
10171 + nop
10172 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10173 +ENDPROC(atomic_sub_unchecked)
10174 +
10175 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10176 BACKOFF_SETUP(%o2)
10177 1: lduw [%o1], %g1
10178 - add %g1, %o0, %g7
10179 + addcc %g1, %o0, %g7
10180 +
10181 +#ifdef CONFIG_PAX_REFCOUNT
10182 + tvs %icc, 6
10183 +#endif
10184 +
10185 cas [%o1], %g1, %g7
10186 cmp %g1, %g7
10187 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10188 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10189 2: BACKOFF_SPIN(%o2, %o3, 1b)
10190 ENDPROC(atomic_add_ret)
10191
10192 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10193 + BACKOFF_SETUP(%o2)
10194 +1: lduw [%o1], %g1
10195 + addcc %g1, %o0, %g7
10196 + cas [%o1], %g1, %g7
10197 + cmp %g1, %g7
10198 + bne,pn %icc, 2f
10199 + add %g7, %o0, %g7
10200 + sra %g7, 0, %o0
10201 + retl
10202 + nop
10203 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10204 +ENDPROC(atomic_add_ret_unchecked)
10205 +
10206 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10207 BACKOFF_SETUP(%o2)
10208 1: lduw [%o1], %g1
10209 - sub %g1, %o0, %g7
10210 + subcc %g1, %o0, %g7
10211 +
10212 +#ifdef CONFIG_PAX_REFCOUNT
10213 + tvs %icc, 6
10214 +#endif
10215 +
10216 cas [%o1], %g1, %g7
10217 cmp %g1, %g7
10218 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10219 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10220 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10221 BACKOFF_SETUP(%o2)
10222 1: ldx [%o1], %g1
10223 - add %g1, %o0, %g7
10224 + addcc %g1, %o0, %g7
10225 +
10226 +#ifdef CONFIG_PAX_REFCOUNT
10227 + tvs %xcc, 6
10228 +#endif
10229 +
10230 casx [%o1], %g1, %g7
10231 cmp %g1, %g7
10232 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10233 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10234 2: BACKOFF_SPIN(%o2, %o3, 1b)
10235 ENDPROC(atomic64_add)
10236
10237 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10238 + BACKOFF_SETUP(%o2)
10239 +1: ldx [%o1], %g1
10240 + addcc %g1, %o0, %g7
10241 + casx [%o1], %g1, %g7
10242 + cmp %g1, %g7
10243 + bne,pn %xcc, 2f
10244 + nop
10245 + retl
10246 + nop
10247 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10248 +ENDPROC(atomic64_add_unchecked)
10249 +
10250 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10251 BACKOFF_SETUP(%o2)
10252 1: ldx [%o1], %g1
10253 - sub %g1, %o0, %g7
10254 + subcc %g1, %o0, %g7
10255 +
10256 +#ifdef CONFIG_PAX_REFCOUNT
10257 + tvs %xcc, 6
10258 +#endif
10259 +
10260 casx [%o1], %g1, %g7
10261 cmp %g1, %g7
10262 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10263 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10264 2: BACKOFF_SPIN(%o2, %o3, 1b)
10265 ENDPROC(atomic64_sub)
10266
10267 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10268 + BACKOFF_SETUP(%o2)
10269 +1: ldx [%o1], %g1
10270 + subcc %g1, %o0, %g7
10271 + casx [%o1], %g1, %g7
10272 + cmp %g1, %g7
10273 + bne,pn %xcc, 2f
10274 + nop
10275 + retl
10276 + nop
10277 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10278 +ENDPROC(atomic64_sub_unchecked)
10279 +
10280 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10281 BACKOFF_SETUP(%o2)
10282 1: ldx [%o1], %g1
10283 - add %g1, %o0, %g7
10284 + addcc %g1, %o0, %g7
10285 +
10286 +#ifdef CONFIG_PAX_REFCOUNT
10287 + tvs %xcc, 6
10288 +#endif
10289 +
10290 casx [%o1], %g1, %g7
10291 cmp %g1, %g7
10292 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10293 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10294 2: BACKOFF_SPIN(%o2, %o3, 1b)
10295 ENDPROC(atomic64_add_ret)
10296
10297 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10298 + BACKOFF_SETUP(%o2)
10299 +1: ldx [%o1], %g1
10300 + addcc %g1, %o0, %g7
10301 + casx [%o1], %g1, %g7
10302 + cmp %g1, %g7
10303 + bne,pn %xcc, 2f
10304 + add %g7, %o0, %g7
10305 + mov %g7, %o0
10306 + retl
10307 + nop
10308 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10309 +ENDPROC(atomic64_add_ret_unchecked)
10310 +
10311 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10312 BACKOFF_SETUP(%o2)
10313 1: ldx [%o1], %g1
10314 - sub %g1, %o0, %g7
10315 + subcc %g1, %o0, %g7
10316 +
10317 +#ifdef CONFIG_PAX_REFCOUNT
10318 + tvs %xcc, 6
10319 +#endif
10320 +
10321 casx [%o1], %g1, %g7
10322 cmp %g1, %g7
10323 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10324 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10325 index 323335b..ed85ea2 100644
10326 --- a/arch/sparc/lib/ksyms.c
10327 +++ b/arch/sparc/lib/ksyms.c
10328 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10329
10330 /* Atomic counter implementation. */
10331 EXPORT_SYMBOL(atomic_add);
10332 +EXPORT_SYMBOL(atomic_add_unchecked);
10333 EXPORT_SYMBOL(atomic_add_ret);
10334 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10335 EXPORT_SYMBOL(atomic_sub);
10336 +EXPORT_SYMBOL(atomic_sub_unchecked);
10337 EXPORT_SYMBOL(atomic_sub_ret);
10338 EXPORT_SYMBOL(atomic64_add);
10339 +EXPORT_SYMBOL(atomic64_add_unchecked);
10340 EXPORT_SYMBOL(atomic64_add_ret);
10341 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10342 EXPORT_SYMBOL(atomic64_sub);
10343 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10344 EXPORT_SYMBOL(atomic64_sub_ret);
10345 EXPORT_SYMBOL(atomic64_dec_if_positive);
10346
10347 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10348 index 30c3ecc..736f015 100644
10349 --- a/arch/sparc/mm/Makefile
10350 +++ b/arch/sparc/mm/Makefile
10351 @@ -2,7 +2,7 @@
10352 #
10353
10354 asflags-y := -ansi
10355 -ccflags-y := -Werror
10356 +#ccflags-y := -Werror
10357
10358 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10359 obj-y += fault_$(BITS).o
10360 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10361 index 59dbd46..1dd7f5e 100644
10362 --- a/arch/sparc/mm/fault_32.c
10363 +++ b/arch/sparc/mm/fault_32.c
10364 @@ -21,6 +21,9 @@
10365 #include <linux/perf_event.h>
10366 #include <linux/interrupt.h>
10367 #include <linux/kdebug.h>
10368 +#include <linux/slab.h>
10369 +#include <linux/pagemap.h>
10370 +#include <linux/compiler.h>
10371
10372 #include <asm/page.h>
10373 #include <asm/pgtable.h>
10374 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10375 return safe_compute_effective_address(regs, insn);
10376 }
10377
10378 +#ifdef CONFIG_PAX_PAGEEXEC
10379 +#ifdef CONFIG_PAX_DLRESOLVE
10380 +static void pax_emuplt_close(struct vm_area_struct *vma)
10381 +{
10382 + vma->vm_mm->call_dl_resolve = 0UL;
10383 +}
10384 +
10385 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10386 +{
10387 + unsigned int *kaddr;
10388 +
10389 + vmf->page = alloc_page(GFP_HIGHUSER);
10390 + if (!vmf->page)
10391 + return VM_FAULT_OOM;
10392 +
10393 + kaddr = kmap(vmf->page);
10394 + memset(kaddr, 0, PAGE_SIZE);
10395 + kaddr[0] = 0x9DE3BFA8U; /* save */
10396 + flush_dcache_page(vmf->page);
10397 + kunmap(vmf->page);
10398 + return VM_FAULT_MAJOR;
10399 +}
10400 +
10401 +static const struct vm_operations_struct pax_vm_ops = {
10402 + .close = pax_emuplt_close,
10403 + .fault = pax_emuplt_fault
10404 +};
10405 +
10406 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10407 +{
10408 + int ret;
10409 +
10410 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10411 + vma->vm_mm = current->mm;
10412 + vma->vm_start = addr;
10413 + vma->vm_end = addr + PAGE_SIZE;
10414 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10415 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10416 + vma->vm_ops = &pax_vm_ops;
10417 +
10418 + ret = insert_vm_struct(current->mm, vma);
10419 + if (ret)
10420 + return ret;
10421 +
10422 + ++current->mm->total_vm;
10423 + return 0;
10424 +}
10425 +#endif
10426 +
10427 +/*
10428 + * PaX: decide what to do with offenders (regs->pc = fault address)
10429 + *
10430 + * returns 1 when task should be killed
10431 + * 2 when patched PLT trampoline was detected
10432 + * 3 when unpatched PLT trampoline was detected
10433 + */
10434 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10435 +{
10436 +
10437 +#ifdef CONFIG_PAX_EMUPLT
10438 + int err;
10439 +
10440 + do { /* PaX: patched PLT emulation #1 */
10441 + unsigned int sethi1, sethi2, jmpl;
10442 +
10443 + err = get_user(sethi1, (unsigned int *)regs->pc);
10444 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10445 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10446 +
10447 + if (err)
10448 + break;
10449 +
10450 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10451 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10452 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10453 + {
10454 + unsigned int addr;
10455 +
10456 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10457 + addr = regs->u_regs[UREG_G1];
10458 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10459 + regs->pc = addr;
10460 + regs->npc = addr+4;
10461 + return 2;
10462 + }
10463 + } while (0);
10464 +
10465 + do { /* PaX: patched PLT emulation #2 */
10466 + unsigned int ba;
10467 +
10468 + err = get_user(ba, (unsigned int *)regs->pc);
10469 +
10470 + if (err)
10471 + break;
10472 +
10473 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10474 + unsigned int addr;
10475 +
10476 + if ((ba & 0xFFC00000U) == 0x30800000U)
10477 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10478 + else
10479 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10480 + regs->pc = addr;
10481 + regs->npc = addr+4;
10482 + return 2;
10483 + }
10484 + } while (0);
10485 +
10486 + do { /* PaX: patched PLT emulation #3 */
10487 + unsigned int sethi, bajmpl, nop;
10488 +
10489 + err = get_user(sethi, (unsigned int *)regs->pc);
10490 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10491 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10492 +
10493 + if (err)
10494 + break;
10495 +
10496 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10497 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10498 + nop == 0x01000000U)
10499 + {
10500 + unsigned int addr;
10501 +
10502 + addr = (sethi & 0x003FFFFFU) << 10;
10503 + regs->u_regs[UREG_G1] = addr;
10504 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10505 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10506 + else
10507 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10508 + regs->pc = addr;
10509 + regs->npc = addr+4;
10510 + return 2;
10511 + }
10512 + } while (0);
10513 +
10514 + do { /* PaX: unpatched PLT emulation step 1 */
10515 + unsigned int sethi, ba, nop;
10516 +
10517 + err = get_user(sethi, (unsigned int *)regs->pc);
10518 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10519 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10520 +
10521 + if (err)
10522 + break;
10523 +
10524 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10525 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10526 + nop == 0x01000000U)
10527 + {
10528 + unsigned int addr, save, call;
10529 +
10530 + if ((ba & 0xFFC00000U) == 0x30800000U)
10531 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10532 + else
10533 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10534 +
10535 + err = get_user(save, (unsigned int *)addr);
10536 + err |= get_user(call, (unsigned int *)(addr+4));
10537 + err |= get_user(nop, (unsigned int *)(addr+8));
10538 + if (err)
10539 + break;
10540 +
10541 +#ifdef CONFIG_PAX_DLRESOLVE
10542 + if (save == 0x9DE3BFA8U &&
10543 + (call & 0xC0000000U) == 0x40000000U &&
10544 + nop == 0x01000000U)
10545 + {
10546 + struct vm_area_struct *vma;
10547 + unsigned long call_dl_resolve;
10548 +
10549 + down_read(&current->mm->mmap_sem);
10550 + call_dl_resolve = current->mm->call_dl_resolve;
10551 + up_read(&current->mm->mmap_sem);
10552 + if (likely(call_dl_resolve))
10553 + goto emulate;
10554 +
10555 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10556 +
10557 + down_write(&current->mm->mmap_sem);
10558 + if (current->mm->call_dl_resolve) {
10559 + call_dl_resolve = current->mm->call_dl_resolve;
10560 + up_write(&current->mm->mmap_sem);
10561 + if (vma)
10562 + kmem_cache_free(vm_area_cachep, vma);
10563 + goto emulate;
10564 + }
10565 +
10566 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10567 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10568 + up_write(&current->mm->mmap_sem);
10569 + if (vma)
10570 + kmem_cache_free(vm_area_cachep, vma);
10571 + return 1;
10572 + }
10573 +
10574 + if (pax_insert_vma(vma, call_dl_resolve)) {
10575 + up_write(&current->mm->mmap_sem);
10576 + kmem_cache_free(vm_area_cachep, vma);
10577 + return 1;
10578 + }
10579 +
10580 + current->mm->call_dl_resolve = call_dl_resolve;
10581 + up_write(&current->mm->mmap_sem);
10582 +
10583 +emulate:
10584 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10585 + regs->pc = call_dl_resolve;
10586 + regs->npc = addr+4;
10587 + return 3;
10588 + }
10589 +#endif
10590 +
10591 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10592 + if ((save & 0xFFC00000U) == 0x05000000U &&
10593 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10594 + nop == 0x01000000U)
10595 + {
10596 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10597 + regs->u_regs[UREG_G2] = addr + 4;
10598 + addr = (save & 0x003FFFFFU) << 10;
10599 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10600 + regs->pc = addr;
10601 + regs->npc = addr+4;
10602 + return 3;
10603 + }
10604 + }
10605 + } while (0);
10606 +
10607 + do { /* PaX: unpatched PLT emulation step 2 */
10608 + unsigned int save, call, nop;
10609 +
10610 + err = get_user(save, (unsigned int *)(regs->pc-4));
10611 + err |= get_user(call, (unsigned int *)regs->pc);
10612 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10613 + if (err)
10614 + break;
10615 +
10616 + if (save == 0x9DE3BFA8U &&
10617 + (call & 0xC0000000U) == 0x40000000U &&
10618 + nop == 0x01000000U)
10619 + {
10620 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10621 +
10622 + regs->u_regs[UREG_RETPC] = regs->pc;
10623 + regs->pc = dl_resolve;
10624 + regs->npc = dl_resolve+4;
10625 + return 3;
10626 + }
10627 + } while (0);
10628 +#endif
10629 +
10630 + return 1;
10631 +}
10632 +
10633 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10634 +{
10635 + unsigned long i;
10636 +
10637 + printk(KERN_ERR "PAX: bytes at PC: ");
10638 + for (i = 0; i < 8; i++) {
10639 + unsigned int c;
10640 + if (get_user(c, (unsigned int *)pc+i))
10641 + printk(KERN_CONT "???????? ");
10642 + else
10643 + printk(KERN_CONT "%08x ", c);
10644 + }
10645 + printk("\n");
10646 +}
10647 +#endif
10648 +
10649 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10650 int text_fault)
10651 {
10652 @@ -229,6 +503,24 @@ good_area:
10653 if (!(vma->vm_flags & VM_WRITE))
10654 goto bad_area;
10655 } else {
10656 +
10657 +#ifdef CONFIG_PAX_PAGEEXEC
10658 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10659 + up_read(&mm->mmap_sem);
10660 + switch (pax_handle_fetch_fault(regs)) {
10661 +
10662 +#ifdef CONFIG_PAX_EMUPLT
10663 + case 2:
10664 + case 3:
10665 + return;
10666 +#endif
10667 +
10668 + }
10669 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10670 + do_group_exit(SIGKILL);
10671 + }
10672 +#endif
10673 +
10674 /* Allow reads even for write-only mappings */
10675 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10676 goto bad_area;
10677 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10678 index 2ebec26..b212598 100644
10679 --- a/arch/sparc/mm/fault_64.c
10680 +++ b/arch/sparc/mm/fault_64.c
10681 @@ -21,6 +21,9 @@
10682 #include <linux/kprobes.h>
10683 #include <linux/kdebug.h>
10684 #include <linux/percpu.h>
10685 +#include <linux/slab.h>
10686 +#include <linux/pagemap.h>
10687 +#include <linux/compiler.h>
10688
10689 #include <asm/page.h>
10690 #include <asm/pgtable.h>
10691 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10692 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10693 regs->tpc);
10694 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10695 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10696 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10697 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10698 dump_stack();
10699 unhandled_fault(regs->tpc, current, regs);
10700 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10701 show_regs(regs);
10702 }
10703
10704 +#ifdef CONFIG_PAX_PAGEEXEC
10705 +#ifdef CONFIG_PAX_DLRESOLVE
10706 +static void pax_emuplt_close(struct vm_area_struct *vma)
10707 +{
10708 + vma->vm_mm->call_dl_resolve = 0UL;
10709 +}
10710 +
10711 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10712 +{
10713 + unsigned int *kaddr;
10714 +
10715 + vmf->page = alloc_page(GFP_HIGHUSER);
10716 + if (!vmf->page)
10717 + return VM_FAULT_OOM;
10718 +
10719 + kaddr = kmap(vmf->page);
10720 + memset(kaddr, 0, PAGE_SIZE);
10721 + kaddr[0] = 0x9DE3BFA8U; /* save */
10722 + flush_dcache_page(vmf->page);
10723 + kunmap(vmf->page);
10724 + return VM_FAULT_MAJOR;
10725 +}
10726 +
10727 +static const struct vm_operations_struct pax_vm_ops = {
10728 + .close = pax_emuplt_close,
10729 + .fault = pax_emuplt_fault
10730 +};
10731 +
10732 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10733 +{
10734 + int ret;
10735 +
10736 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10737 + vma->vm_mm = current->mm;
10738 + vma->vm_start = addr;
10739 + vma->vm_end = addr + PAGE_SIZE;
10740 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10741 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10742 + vma->vm_ops = &pax_vm_ops;
10743 +
10744 + ret = insert_vm_struct(current->mm, vma);
10745 + if (ret)
10746 + return ret;
10747 +
10748 + ++current->mm->total_vm;
10749 + return 0;
10750 +}
10751 +#endif
10752 +
10753 +/*
10754 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10755 + *
10756 + * returns 1 when task should be killed
10757 + * 2 when patched PLT trampoline was detected
10758 + * 3 when unpatched PLT trampoline was detected
10759 + */
10760 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10761 +{
10762 +
10763 +#ifdef CONFIG_PAX_EMUPLT
10764 + int err;
10765 +
10766 + do { /* PaX: patched PLT emulation #1 */
10767 + unsigned int sethi1, sethi2, jmpl;
10768 +
10769 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10770 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10771 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10772 +
10773 + if (err)
10774 + break;
10775 +
10776 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10777 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10778 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10779 + {
10780 + unsigned long addr;
10781 +
10782 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10783 + addr = regs->u_regs[UREG_G1];
10784 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10785 +
10786 + if (test_thread_flag(TIF_32BIT))
10787 + addr &= 0xFFFFFFFFUL;
10788 +
10789 + regs->tpc = addr;
10790 + regs->tnpc = addr+4;
10791 + return 2;
10792 + }
10793 + } while (0);
10794 +
10795 + do { /* PaX: patched PLT emulation #2 */
10796 + unsigned int ba;
10797 +
10798 + err = get_user(ba, (unsigned int *)regs->tpc);
10799 +
10800 + if (err)
10801 + break;
10802 +
10803 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10804 + unsigned long addr;
10805 +
10806 + if ((ba & 0xFFC00000U) == 0x30800000U)
10807 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10808 + else
10809 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10810 +
10811 + if (test_thread_flag(TIF_32BIT))
10812 + addr &= 0xFFFFFFFFUL;
10813 +
10814 + regs->tpc = addr;
10815 + regs->tnpc = addr+4;
10816 + return 2;
10817 + }
10818 + } while (0);
10819 +
10820 + do { /* PaX: patched PLT emulation #3 */
10821 + unsigned int sethi, bajmpl, nop;
10822 +
10823 + err = get_user(sethi, (unsigned int *)regs->tpc);
10824 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10825 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10826 +
10827 + if (err)
10828 + break;
10829 +
10830 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10831 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10832 + nop == 0x01000000U)
10833 + {
10834 + unsigned long addr;
10835 +
10836 + addr = (sethi & 0x003FFFFFU) << 10;
10837 + regs->u_regs[UREG_G1] = addr;
10838 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10839 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10840 + else
10841 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10842 +
10843 + if (test_thread_flag(TIF_32BIT))
10844 + addr &= 0xFFFFFFFFUL;
10845 +
10846 + regs->tpc = addr;
10847 + regs->tnpc = addr+4;
10848 + return 2;
10849 + }
10850 + } while (0);
10851 +
10852 + do { /* PaX: patched PLT emulation #4 */
10853 + unsigned int sethi, mov1, call, mov2;
10854 +
10855 + err = get_user(sethi, (unsigned int *)regs->tpc);
10856 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10857 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10858 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10859 +
10860 + if (err)
10861 + break;
10862 +
10863 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10864 + mov1 == 0x8210000FU &&
10865 + (call & 0xC0000000U) == 0x40000000U &&
10866 + mov2 == 0x9E100001U)
10867 + {
10868 + unsigned long addr;
10869 +
10870 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10871 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10872 +
10873 + if (test_thread_flag(TIF_32BIT))
10874 + addr &= 0xFFFFFFFFUL;
10875 +
10876 + regs->tpc = addr;
10877 + regs->tnpc = addr+4;
10878 + return 2;
10879 + }
10880 + } while (0);
10881 +
10882 + do { /* PaX: patched PLT emulation #5 */
10883 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10884 +
10885 + err = get_user(sethi, (unsigned int *)regs->tpc);
10886 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10887 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10888 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10889 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10890 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10891 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10892 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10893 +
10894 + if (err)
10895 + break;
10896 +
10897 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10898 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10899 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10900 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10901 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10902 + sllx == 0x83287020U &&
10903 + jmpl == 0x81C04005U &&
10904 + nop == 0x01000000U)
10905 + {
10906 + unsigned long addr;
10907 +
10908 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10909 + regs->u_regs[UREG_G1] <<= 32;
10910 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10911 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10912 + regs->tpc = addr;
10913 + regs->tnpc = addr+4;
10914 + return 2;
10915 + }
10916 + } while (0);
10917 +
10918 + do { /* PaX: patched PLT emulation #6 */
10919 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10920 +
10921 + err = get_user(sethi, (unsigned int *)regs->tpc);
10922 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10923 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10924 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10925 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10926 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10927 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10928 +
10929 + if (err)
10930 + break;
10931 +
10932 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10933 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10934 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10935 + sllx == 0x83287020U &&
10936 + (or & 0xFFFFE000U) == 0x8A116000U &&
10937 + jmpl == 0x81C04005U &&
10938 + nop == 0x01000000U)
10939 + {
10940 + unsigned long addr;
10941 +
10942 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10943 + regs->u_regs[UREG_G1] <<= 32;
10944 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10945 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10946 + regs->tpc = addr;
10947 + regs->tnpc = addr+4;
10948 + return 2;
10949 + }
10950 + } while (0);
10951 +
10952 + do { /* PaX: unpatched PLT emulation step 1 */
10953 + unsigned int sethi, ba, nop;
10954 +
10955 + err = get_user(sethi, (unsigned int *)regs->tpc);
10956 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10957 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10958 +
10959 + if (err)
10960 + break;
10961 +
10962 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10963 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10964 + nop == 0x01000000U)
10965 + {
10966 + unsigned long addr;
10967 + unsigned int save, call;
10968 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10969 +
10970 + if ((ba & 0xFFC00000U) == 0x30800000U)
10971 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10972 + else
10973 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10974 +
10975 + if (test_thread_flag(TIF_32BIT))
10976 + addr &= 0xFFFFFFFFUL;
10977 +
10978 + err = get_user(save, (unsigned int *)addr);
10979 + err |= get_user(call, (unsigned int *)(addr+4));
10980 + err |= get_user(nop, (unsigned int *)(addr+8));
10981 + if (err)
10982 + break;
10983 +
10984 +#ifdef CONFIG_PAX_DLRESOLVE
10985 + if (save == 0x9DE3BFA8U &&
10986 + (call & 0xC0000000U) == 0x40000000U &&
10987 + nop == 0x01000000U)
10988 + {
10989 + struct vm_area_struct *vma;
10990 + unsigned long call_dl_resolve;
10991 +
10992 + down_read(&current->mm->mmap_sem);
10993 + call_dl_resolve = current->mm->call_dl_resolve;
10994 + up_read(&current->mm->mmap_sem);
10995 + if (likely(call_dl_resolve))
10996 + goto emulate;
10997 +
10998 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10999 +
11000 + down_write(&current->mm->mmap_sem);
11001 + if (current->mm->call_dl_resolve) {
11002 + call_dl_resolve = current->mm->call_dl_resolve;
11003 + up_write(&current->mm->mmap_sem);
11004 + if (vma)
11005 + kmem_cache_free(vm_area_cachep, vma);
11006 + goto emulate;
11007 + }
11008 +
11009 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11010 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11011 + up_write(&current->mm->mmap_sem);
11012 + if (vma)
11013 + kmem_cache_free(vm_area_cachep, vma);
11014 + return 1;
11015 + }
11016 +
11017 + if (pax_insert_vma(vma, call_dl_resolve)) {
11018 + up_write(&current->mm->mmap_sem);
11019 + kmem_cache_free(vm_area_cachep, vma);
11020 + return 1;
11021 + }
11022 +
11023 + current->mm->call_dl_resolve = call_dl_resolve;
11024 + up_write(&current->mm->mmap_sem);
11025 +
11026 +emulate:
11027 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11028 + regs->tpc = call_dl_resolve;
11029 + regs->tnpc = addr+4;
11030 + return 3;
11031 + }
11032 +#endif
11033 +
11034 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11035 + if ((save & 0xFFC00000U) == 0x05000000U &&
11036 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11037 + nop == 0x01000000U)
11038 + {
11039 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11040 + regs->u_regs[UREG_G2] = addr + 4;
11041 + addr = (save & 0x003FFFFFU) << 10;
11042 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11043 +
11044 + if (test_thread_flag(TIF_32BIT))
11045 + addr &= 0xFFFFFFFFUL;
11046 +
11047 + regs->tpc = addr;
11048 + regs->tnpc = addr+4;
11049 + return 3;
11050 + }
11051 +
11052 + /* PaX: 64-bit PLT stub */
11053 + err = get_user(sethi1, (unsigned int *)addr);
11054 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11055 + err |= get_user(or1, (unsigned int *)(addr+8));
11056 + err |= get_user(or2, (unsigned int *)(addr+12));
11057 + err |= get_user(sllx, (unsigned int *)(addr+16));
11058 + err |= get_user(add, (unsigned int *)(addr+20));
11059 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11060 + err |= get_user(nop, (unsigned int *)(addr+28));
11061 + if (err)
11062 + break;
11063 +
11064 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11065 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11066 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11067 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11068 + sllx == 0x89293020U &&
11069 + add == 0x8A010005U &&
11070 + jmpl == 0x89C14000U &&
11071 + nop == 0x01000000U)
11072 + {
11073 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11074 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11075 + regs->u_regs[UREG_G4] <<= 32;
11076 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11077 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11078 + regs->u_regs[UREG_G4] = addr + 24;
11079 + addr = regs->u_regs[UREG_G5];
11080 + regs->tpc = addr;
11081 + regs->tnpc = addr+4;
11082 + return 3;
11083 + }
11084 + }
11085 + } while (0);
11086 +
11087 +#ifdef CONFIG_PAX_DLRESOLVE
11088 + do { /* PaX: unpatched PLT emulation step 2 */
11089 + unsigned int save, call, nop;
11090 +
11091 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11092 + err |= get_user(call, (unsigned int *)regs->tpc);
11093 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11094 + if (err)
11095 + break;
11096 +
11097 + if (save == 0x9DE3BFA8U &&
11098 + (call & 0xC0000000U) == 0x40000000U &&
11099 + nop == 0x01000000U)
11100 + {
11101 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11102 +
11103 + if (test_thread_flag(TIF_32BIT))
11104 + dl_resolve &= 0xFFFFFFFFUL;
11105 +
11106 + regs->u_regs[UREG_RETPC] = regs->tpc;
11107 + regs->tpc = dl_resolve;
11108 + regs->tnpc = dl_resolve+4;
11109 + return 3;
11110 + }
11111 + } while (0);
11112 +#endif
11113 +
11114 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11115 + unsigned int sethi, ba, nop;
11116 +
11117 + err = get_user(sethi, (unsigned int *)regs->tpc);
11118 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11119 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11120 +
11121 + if (err)
11122 + break;
11123 +
11124 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11125 + (ba & 0xFFF00000U) == 0x30600000U &&
11126 + nop == 0x01000000U)
11127 + {
11128 + unsigned long addr;
11129 +
11130 + addr = (sethi & 0x003FFFFFU) << 10;
11131 + regs->u_regs[UREG_G1] = addr;
11132 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11133 +
11134 + if (test_thread_flag(TIF_32BIT))
11135 + addr &= 0xFFFFFFFFUL;
11136 +
11137 + regs->tpc = addr;
11138 + regs->tnpc = addr+4;
11139 + return 2;
11140 + }
11141 + } while (0);
11142 +
11143 +#endif
11144 +
11145 + return 1;
11146 +}
11147 +
11148 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11149 +{
11150 + unsigned long i;
11151 +
11152 + printk(KERN_ERR "PAX: bytes at PC: ");
11153 + for (i = 0; i < 8; i++) {
11154 + unsigned int c;
11155 + if (get_user(c, (unsigned int *)pc+i))
11156 + printk(KERN_CONT "???????? ");
11157 + else
11158 + printk(KERN_CONT "%08x ", c);
11159 + }
11160 + printk("\n");
11161 +}
11162 +#endif
11163 +
11164 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11165 {
11166 struct mm_struct *mm = current->mm;
11167 @@ -342,6 +805,29 @@ retry:
11168 if (!vma)
11169 goto bad_area;
11170
11171 +#ifdef CONFIG_PAX_PAGEEXEC
11172 + /* PaX: detect ITLB misses on non-exec pages */
11173 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11174 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11175 + {
11176 + if (address != regs->tpc)
11177 + goto good_area;
11178 +
11179 + up_read(&mm->mmap_sem);
11180 + switch (pax_handle_fetch_fault(regs)) {
11181 +
11182 +#ifdef CONFIG_PAX_EMUPLT
11183 + case 2:
11184 + case 3:
11185 + return;
11186 +#endif
11187 +
11188 + }
11189 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11190 + do_group_exit(SIGKILL);
11191 + }
11192 +#endif
11193 +
11194 /* Pure DTLB misses do not tell us whether the fault causing
11195 * load/store/atomic was a write or not, it only says that there
11196 * was no match. So in such a case we (carefully) read the
11197 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11198 index 9639964..806cd0c 100644
11199 --- a/arch/sparc/mm/hugetlbpage.c
11200 +++ b/arch/sparc/mm/hugetlbpage.c
11201 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11202 unsigned long addr,
11203 unsigned long len,
11204 unsigned long pgoff,
11205 - unsigned long flags)
11206 + unsigned long flags,
11207 + unsigned long offset)
11208 {
11209 unsigned long task_size = TASK_SIZE;
11210 struct vm_unmapped_area_info info;
11211 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11212
11213 info.flags = 0;
11214 info.length = len;
11215 - info.low_limit = TASK_UNMAPPED_BASE;
11216 + info.low_limit = mm->mmap_base;
11217 info.high_limit = min(task_size, VA_EXCLUDE_START);
11218 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11219 info.align_offset = 0;
11220 + info.threadstack_offset = offset;
11221 addr = vm_unmapped_area(&info);
11222
11223 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11224 VM_BUG_ON(addr != -ENOMEM);
11225 info.low_limit = VA_EXCLUDE_END;
11226 +
11227 +#ifdef CONFIG_PAX_RANDMMAP
11228 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11229 + info.low_limit += mm->delta_mmap;
11230 +#endif
11231 +
11232 info.high_limit = task_size;
11233 addr = vm_unmapped_area(&info);
11234 }
11235 @@ -58,7 +66,8 @@ static unsigned long
11236 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11237 const unsigned long len,
11238 const unsigned long pgoff,
11239 - const unsigned long flags)
11240 + const unsigned long flags,
11241 + const unsigned long offset)
11242 {
11243 struct mm_struct *mm = current->mm;
11244 unsigned long addr = addr0;
11245 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11246 info.high_limit = mm->mmap_base;
11247 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11248 info.align_offset = 0;
11249 + info.threadstack_offset = offset;
11250 addr = vm_unmapped_area(&info);
11251
11252 /*
11253 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11254 VM_BUG_ON(addr != -ENOMEM);
11255 info.flags = 0;
11256 info.low_limit = TASK_UNMAPPED_BASE;
11257 +
11258 +#ifdef CONFIG_PAX_RANDMMAP
11259 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11260 + info.low_limit += mm->delta_mmap;
11261 +#endif
11262 +
11263 info.high_limit = STACK_TOP32;
11264 addr = vm_unmapped_area(&info);
11265 }
11266 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11267 struct mm_struct *mm = current->mm;
11268 struct vm_area_struct *vma;
11269 unsigned long task_size = TASK_SIZE;
11270 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11271
11272 if (test_thread_flag(TIF_32BIT))
11273 task_size = STACK_TOP32;
11274 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11275 return addr;
11276 }
11277
11278 +#ifdef CONFIG_PAX_RANDMMAP
11279 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11280 +#endif
11281 +
11282 if (addr) {
11283 addr = ALIGN(addr, HPAGE_SIZE);
11284 vma = find_vma(mm, addr);
11285 - if (task_size - len >= addr &&
11286 - (!vma || addr + len <= vma->vm_start))
11287 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11288 return addr;
11289 }
11290 if (mm->get_unmapped_area == arch_get_unmapped_area)
11291 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11292 - pgoff, flags);
11293 + pgoff, flags, offset);
11294 else
11295 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11296 - pgoff, flags);
11297 + pgoff, flags, offset);
11298 }
11299
11300 pte_t *huge_pte_alloc(struct mm_struct *mm,
11301 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11302 index ed82eda..0d80e77 100644
11303 --- a/arch/sparc/mm/init_64.c
11304 +++ b/arch/sparc/mm/init_64.c
11305 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11306 int num_kernel_image_mappings;
11307
11308 #ifdef CONFIG_DEBUG_DCFLUSH
11309 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11310 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11311 #ifdef CONFIG_SMP
11312 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11313 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11314 #endif
11315 #endif
11316
11317 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11318 {
11319 BUG_ON(tlb_type == hypervisor);
11320 #ifdef CONFIG_DEBUG_DCFLUSH
11321 - atomic_inc(&dcpage_flushes);
11322 + atomic_inc_unchecked(&dcpage_flushes);
11323 #endif
11324
11325 #ifdef DCACHE_ALIASING_POSSIBLE
11326 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11327
11328 #ifdef CONFIG_DEBUG_DCFLUSH
11329 seq_printf(m, "DCPageFlushes\t: %d\n",
11330 - atomic_read(&dcpage_flushes));
11331 + atomic_read_unchecked(&dcpage_flushes));
11332 #ifdef CONFIG_SMP
11333 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11334 - atomic_read(&dcpage_flushes_xcall));
11335 + atomic_read_unchecked(&dcpage_flushes_xcall));
11336 #endif /* CONFIG_SMP */
11337 #endif /* CONFIG_DEBUG_DCFLUSH */
11338 }
11339 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11340 index ad220ee..2f537b3 100644
11341 --- a/arch/tile/include/asm/atomic_64.h
11342 +++ b/arch/tile/include/asm/atomic_64.h
11343 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11344
11345 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11346
11347 +#define atomic64_read_unchecked(v) atomic64_read(v)
11348 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11349 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11350 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11351 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11352 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11353 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11354 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11355 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11356 +
11357 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11358 #define smp_mb__before_atomic_dec() smp_mb()
11359 #define smp_mb__after_atomic_dec() smp_mb()
11360 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11361 index 6160761..00cac88 100644
11362 --- a/arch/tile/include/asm/cache.h
11363 +++ b/arch/tile/include/asm/cache.h
11364 @@ -15,11 +15,12 @@
11365 #ifndef _ASM_TILE_CACHE_H
11366 #define _ASM_TILE_CACHE_H
11367
11368 +#include <linux/const.h>
11369 #include <arch/chip.h>
11370
11371 /* bytes per L1 data cache line */
11372 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11373 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11374 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11375
11376 /* bytes per L2 cache line */
11377 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11378 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11379 index b6cde32..c0cb736 100644
11380 --- a/arch/tile/include/asm/uaccess.h
11381 +++ b/arch/tile/include/asm/uaccess.h
11382 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11383 const void __user *from,
11384 unsigned long n)
11385 {
11386 - int sz = __compiletime_object_size(to);
11387 + size_t sz = __compiletime_object_size(to);
11388
11389 - if (likely(sz == -1 || sz >= n))
11390 + if (likely(sz == (size_t)-1 || sz >= n))
11391 n = _copy_from_user(to, from, n);
11392 else
11393 copy_from_user_overflow();
11394 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11395 index 0cb3bba..7338b2d 100644
11396 --- a/arch/tile/mm/hugetlbpage.c
11397 +++ b/arch/tile/mm/hugetlbpage.c
11398 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11399 info.high_limit = TASK_SIZE;
11400 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11401 info.align_offset = 0;
11402 + info.threadstack_offset = 0;
11403 return vm_unmapped_area(&info);
11404 }
11405
11406 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11407 info.high_limit = current->mm->mmap_base;
11408 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11409 info.align_offset = 0;
11410 + info.threadstack_offset = 0;
11411 addr = vm_unmapped_area(&info);
11412
11413 /*
11414 diff --git a/arch/um/Makefile b/arch/um/Makefile
11415 index 133f7de..1d6f2f1 100644
11416 --- a/arch/um/Makefile
11417 +++ b/arch/um/Makefile
11418 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11419 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11420 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11421
11422 +ifdef CONSTIFY_PLUGIN
11423 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11424 +endif
11425 +
11426 #This will adjust *FLAGS accordingly to the platform.
11427 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11428
11429 diff --git a/arch/um/defconfig b/arch/um/defconfig
11430 index 2665e6b..3e3822b 100644
11431 --- a/arch/um/defconfig
11432 +++ b/arch/um/defconfig
11433 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11434 CONFIG_X86_L1_CACHE_SHIFT=5
11435 CONFIG_X86_XADD=y
11436 CONFIG_X86_PPRO_FENCE=y
11437 -CONFIG_X86_WP_WORKS_OK=y
11438 CONFIG_X86_INVLPG=y
11439 CONFIG_X86_BSWAP=y
11440 CONFIG_X86_POPAD_OK=y
11441 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11442 index 19e1bdd..3665b77 100644
11443 --- a/arch/um/include/asm/cache.h
11444 +++ b/arch/um/include/asm/cache.h
11445 @@ -1,6 +1,7 @@
11446 #ifndef __UM_CACHE_H
11447 #define __UM_CACHE_H
11448
11449 +#include <linux/const.h>
11450
11451 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11452 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11453 @@ -12,6 +13,6 @@
11454 # define L1_CACHE_SHIFT 5
11455 #endif
11456
11457 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11458 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11459
11460 #endif
11461 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11462 index 2e0a6b1..a64d0f5 100644
11463 --- a/arch/um/include/asm/kmap_types.h
11464 +++ b/arch/um/include/asm/kmap_types.h
11465 @@ -8,6 +8,6 @@
11466
11467 /* No more #include "asm/arch/kmap_types.h" ! */
11468
11469 -#define KM_TYPE_NR 14
11470 +#define KM_TYPE_NR 15
11471
11472 #endif
11473 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11474 index 5ff53d9..5850cdf 100644
11475 --- a/arch/um/include/asm/page.h
11476 +++ b/arch/um/include/asm/page.h
11477 @@ -14,6 +14,9 @@
11478 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11479 #define PAGE_MASK (~(PAGE_SIZE-1))
11480
11481 +#define ktla_ktva(addr) (addr)
11482 +#define ktva_ktla(addr) (addr)
11483 +
11484 #ifndef __ASSEMBLY__
11485
11486 struct page;
11487 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11488 index 0032f92..cd151e0 100644
11489 --- a/arch/um/include/asm/pgtable-3level.h
11490 +++ b/arch/um/include/asm/pgtable-3level.h
11491 @@ -58,6 +58,7 @@
11492 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11493 #define pud_populate(mm, pud, pmd) \
11494 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11495 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11496
11497 #ifdef CONFIG_64BIT
11498 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11499 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11500 index bbcef52..6a2a483 100644
11501 --- a/arch/um/kernel/process.c
11502 +++ b/arch/um/kernel/process.c
11503 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11504 return 2;
11505 }
11506
11507 -/*
11508 - * Only x86 and x86_64 have an arch_align_stack().
11509 - * All other arches have "#define arch_align_stack(x) (x)"
11510 - * in their asm/system.h
11511 - * As this is included in UML from asm-um/system-generic.h,
11512 - * we can use it to behave as the subarch does.
11513 - */
11514 -#ifndef arch_align_stack
11515 -unsigned long arch_align_stack(unsigned long sp)
11516 -{
11517 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11518 - sp -= get_random_int() % 8192;
11519 - return sp & ~0xf;
11520 -}
11521 -#endif
11522 -
11523 unsigned long get_wchan(struct task_struct *p)
11524 {
11525 unsigned long stack_page, sp, ip;
11526 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11527 index ad8f795..2c7eec6 100644
11528 --- a/arch/unicore32/include/asm/cache.h
11529 +++ b/arch/unicore32/include/asm/cache.h
11530 @@ -12,8 +12,10 @@
11531 #ifndef __UNICORE_CACHE_H__
11532 #define __UNICORE_CACHE_H__
11533
11534 -#define L1_CACHE_SHIFT (5)
11535 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11536 +#include <linux/const.h>
11537 +
11538 +#define L1_CACHE_SHIFT 5
11539 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11540
11541 /*
11542 * Memory returned by kmalloc() may be used for DMA, so we must make
11543 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11544 index f67e839..419b5f7 100644
11545 --- a/arch/x86/Kconfig
11546 +++ b/arch/x86/Kconfig
11547 @@ -247,7 +247,7 @@ config X86_HT
11548
11549 config X86_32_LAZY_GS
11550 def_bool y
11551 - depends on X86_32 && !CC_STACKPROTECTOR
11552 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11553
11554 config ARCH_HWEIGHT_CFLAGS
11555 string
11556 @@ -1099,6 +1099,7 @@ config MICROCODE_EARLY
11557
11558 config X86_MSR
11559 tristate "/dev/cpu/*/msr - Model-specific register support"
11560 + depends on !GRKERNSEC_KMEM
11561 ---help---
11562 This device gives privileged processes access to the x86
11563 Model-Specific Registers (MSRs). It is a character device with
11564 @@ -1122,7 +1123,7 @@ choice
11565
11566 config NOHIGHMEM
11567 bool "off"
11568 - depends on !X86_NUMAQ
11569 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11570 ---help---
11571 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11572 However, the address space of 32-bit x86 processors is only 4
11573 @@ -1159,7 +1160,7 @@ config NOHIGHMEM
11574
11575 config HIGHMEM4G
11576 bool "4GB"
11577 - depends on !X86_NUMAQ
11578 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11579 ---help---
11580 Select this if you have a 32-bit processor and between 1 and 4
11581 gigabytes of physical RAM.
11582 @@ -1212,7 +1213,7 @@ config PAGE_OFFSET
11583 hex
11584 default 0xB0000000 if VMSPLIT_3G_OPT
11585 default 0x80000000 if VMSPLIT_2G
11586 - default 0x78000000 if VMSPLIT_2G_OPT
11587 + default 0x70000000 if VMSPLIT_2G_OPT
11588 default 0x40000000 if VMSPLIT_1G
11589 default 0xC0000000
11590 depends on X86_32
11591 @@ -1614,6 +1615,7 @@ config SECCOMP
11592
11593 config CC_STACKPROTECTOR
11594 bool "Enable -fstack-protector buffer overflow detection"
11595 + depends on X86_64 || !PAX_MEMORY_UDEREF
11596 ---help---
11597 This option turns on the -fstack-protector GCC feature. This
11598 feature puts, at the beginning of functions, a canary value on
11599 @@ -1733,6 +1735,8 @@ config X86_NEED_RELOCS
11600 config PHYSICAL_ALIGN
11601 hex "Alignment value to which kernel should be aligned"
11602 default "0x1000000"
11603 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11604 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11605 range 0x2000 0x1000000 if X86_32
11606 range 0x200000 0x1000000 if X86_64
11607 ---help---
11608 @@ -1812,9 +1816,10 @@ config DEBUG_HOTPLUG_CPU0
11609 If unsure, say N.
11610
11611 config COMPAT_VDSO
11612 - def_bool y
11613 + def_bool n
11614 prompt "Compat VDSO support"
11615 depends on X86_32 || IA32_EMULATION
11616 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11617 ---help---
11618 Map the 32-bit VDSO to the predictable old-style address too.
11619
11620 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11621 index c026cca..14657ae 100644
11622 --- a/arch/x86/Kconfig.cpu
11623 +++ b/arch/x86/Kconfig.cpu
11624 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11625
11626 config X86_F00F_BUG
11627 def_bool y
11628 - depends on M586MMX || M586TSC || M586 || M486
11629 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11630
11631 config X86_INVD_BUG
11632 def_bool y
11633 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11634
11635 config X86_ALIGNMENT_16
11636 def_bool y
11637 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11638 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11639
11640 config X86_INTEL_USERCOPY
11641 def_bool y
11642 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11643 # generates cmov.
11644 config X86_CMOV
11645 def_bool y
11646 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11647 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11648
11649 config X86_MINIMUM_CPU_FAMILY
11650 int
11651 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11652 index 78d91af..8ceb94b 100644
11653 --- a/arch/x86/Kconfig.debug
11654 +++ b/arch/x86/Kconfig.debug
11655 @@ -74,7 +74,7 @@ config X86_PTDUMP
11656 config DEBUG_RODATA
11657 bool "Write protect kernel read-only data structures"
11658 default y
11659 - depends on DEBUG_KERNEL
11660 + depends on DEBUG_KERNEL && BROKEN
11661 ---help---
11662 Mark the kernel read-only data as write-protected in the pagetables,
11663 in order to catch accidental (and incorrect) writes to such const
11664 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11665
11666 config DEBUG_SET_MODULE_RONX
11667 bool "Set loadable kernel module data as NX and text as RO"
11668 - depends on MODULES
11669 + depends on MODULES && BROKEN
11670 ---help---
11671 This option helps catch unintended modifications to loadable
11672 kernel module's text and read-only data. It also prevents execution
11673 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11674 index 41250fb..863762e 100644
11675 --- a/arch/x86/Makefile
11676 +++ b/arch/x86/Makefile
11677 @@ -46,14 +46,12 @@ ifeq ($(CONFIG_X86_32),y)
11678 # CPU-specific tuning. Anything which can be shared with UML should go here.
11679 include $(srctree)/arch/x86/Makefile_32.cpu
11680 KBUILD_CFLAGS += $(cflags-y)
11681 -
11682 - # temporary until string.h is fixed
11683 - KBUILD_CFLAGS += -ffreestanding
11684 else
11685 BITS := 64
11686 UTS_MACHINE := x86_64
11687 CHECKFLAGS += -D__x86_64__ -m64
11688
11689 + biarch := $(call cc-option,-m64)
11690 KBUILD_AFLAGS += -m64
11691 KBUILD_CFLAGS += -m64
11692
11693 @@ -83,6 +81,9 @@ else
11694 KBUILD_CFLAGS += -maccumulate-outgoing-args
11695 endif
11696
11697 +# temporary until string.h is fixed
11698 +KBUILD_CFLAGS += -ffreestanding
11699 +
11700 ifdef CONFIG_CC_STACKPROTECTOR
11701 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
11702 ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
11703 @@ -241,3 +242,12 @@ define archhelp
11704 echo ' FDINITRD=file initrd for the booted kernel'
11705 echo ' kvmconfig - Enable additional options for guest kernel support'
11706 endef
11707 +
11708 +define OLD_LD
11709 +
11710 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11711 +*** Please upgrade your binutils to 2.18 or newer
11712 +endef
11713 +
11714 +archprepare:
11715 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11716 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11717 index 379814b..add62ce 100644
11718 --- a/arch/x86/boot/Makefile
11719 +++ b/arch/x86/boot/Makefile
11720 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11721 $(call cc-option, -fno-stack-protector) \
11722 $(call cc-option, -mpreferred-stack-boundary=2)
11723 KBUILD_CFLAGS += $(call cc-option, -m32)
11724 +ifdef CONSTIFY_PLUGIN
11725 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11726 +endif
11727 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11728 GCOV_PROFILE := n
11729
11730 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11731 index 878e4b9..20537ab 100644
11732 --- a/arch/x86/boot/bitops.h
11733 +++ b/arch/x86/boot/bitops.h
11734 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11735 u8 v;
11736 const u32 *p = (const u32 *)addr;
11737
11738 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11739 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11740 return v;
11741 }
11742
11743 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11744
11745 static inline void set_bit(int nr, void *addr)
11746 {
11747 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11748 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11749 }
11750
11751 #endif /* BOOT_BITOPS_H */
11752 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11753 index ef72bae..353a184 100644
11754 --- a/arch/x86/boot/boot.h
11755 +++ b/arch/x86/boot/boot.h
11756 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11757 static inline u16 ds(void)
11758 {
11759 u16 seg;
11760 - asm("movw %%ds,%0" : "=rm" (seg));
11761 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11762 return seg;
11763 }
11764
11765 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11766 static inline int memcmp(const void *s1, const void *s2, size_t len)
11767 {
11768 u8 diff;
11769 - asm("repe; cmpsb; setnz %0"
11770 + asm volatile("repe; cmpsb; setnz %0"
11771 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11772 return diff;
11773 }
11774 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11775 index dcd90df..c830d7d 100644
11776 --- a/arch/x86/boot/compressed/Makefile
11777 +++ b/arch/x86/boot/compressed/Makefile
11778 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11779 KBUILD_CFLAGS += $(cflags-y)
11780 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11781 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11782 +ifdef CONSTIFY_PLUGIN
11783 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11784 +endif
11785
11786 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11787 GCOV_PROFILE := n
11788 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11789 index b7388a4..03844ec 100644
11790 --- a/arch/x86/boot/compressed/eboot.c
11791 +++ b/arch/x86/boot/compressed/eboot.c
11792 @@ -150,7 +150,6 @@ again:
11793 *addr = max_addr;
11794 }
11795
11796 -free_pool:
11797 efi_call_phys1(sys_table->boottime->free_pool, map);
11798
11799 fail:
11800 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11801 if (i == map_size / desc_size)
11802 status = EFI_NOT_FOUND;
11803
11804 -free_pool:
11805 efi_call_phys1(sys_table->boottime->free_pool, map);
11806 fail:
11807 return status;
11808 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11809 index a53440e..c3dbf1e 100644
11810 --- a/arch/x86/boot/compressed/efi_stub_32.S
11811 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11812 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11813 * parameter 2, ..., param n. To make things easy, we save the return
11814 * address of efi_call_phys in a global variable.
11815 */
11816 - popl %ecx
11817 - movl %ecx, saved_return_addr(%edx)
11818 - /* get the function pointer into ECX*/
11819 - popl %ecx
11820 - movl %ecx, efi_rt_function_ptr(%edx)
11821 + popl saved_return_addr(%edx)
11822 + popl efi_rt_function_ptr(%edx)
11823
11824 /*
11825 * 3. Call the physical function.
11826 */
11827 - call *%ecx
11828 + call *efi_rt_function_ptr(%edx)
11829
11830 /*
11831 * 4. Balance the stack. And because EAX contain the return value,
11832 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11833 1: popl %edx
11834 subl $1b, %edx
11835
11836 - movl efi_rt_function_ptr(%edx), %ecx
11837 - pushl %ecx
11838 + pushl efi_rt_function_ptr(%edx)
11839
11840 /*
11841 * 10. Push the saved return address onto the stack and return.
11842 */
11843 - movl saved_return_addr(%edx), %ecx
11844 - pushl %ecx
11845 - ret
11846 + jmpl *saved_return_addr(%edx)
11847 ENDPROC(efi_call_phys)
11848 .previous
11849
11850 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11851 index 5d6f689..9d06730 100644
11852 --- a/arch/x86/boot/compressed/head_32.S
11853 +++ b/arch/x86/boot/compressed/head_32.S
11854 @@ -118,7 +118,7 @@ preferred_addr:
11855 notl %eax
11856 andl %eax, %ebx
11857 #else
11858 - movl $LOAD_PHYSICAL_ADDR, %ebx
11859 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11860 #endif
11861
11862 /* Target address to relocate to for decompression */
11863 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11864 index c337422..2c5be72 100644
11865 --- a/arch/x86/boot/compressed/head_64.S
11866 +++ b/arch/x86/boot/compressed/head_64.S
11867 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11868 notl %eax
11869 andl %eax, %ebx
11870 #else
11871 - movl $LOAD_PHYSICAL_ADDR, %ebx
11872 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11873 #endif
11874
11875 /* Target address to relocate to for decompression */
11876 @@ -270,7 +270,7 @@ preferred_addr:
11877 notq %rax
11878 andq %rax, %rbp
11879 #else
11880 - movq $LOAD_PHYSICAL_ADDR, %rbp
11881 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11882 #endif
11883
11884 /* Target address to relocate to for decompression */
11885 @@ -362,8 +362,8 @@ gdt:
11886 .long gdt
11887 .word 0
11888 .quad 0x0000000000000000 /* NULL descriptor */
11889 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11890 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11891 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11892 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11893 .quad 0x0080890000000000 /* TS descriptor */
11894 .quad 0x0000000000000000 /* TS continued */
11895 gdt_end:
11896 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11897 index 434f077..b6b4b38 100644
11898 --- a/arch/x86/boot/compressed/misc.c
11899 +++ b/arch/x86/boot/compressed/misc.c
11900 @@ -283,7 +283,7 @@ static void handle_relocations(void *output, unsigned long output_len)
11901 * Calculate the delta between where vmlinux was linked to load
11902 * and where it was actually loaded.
11903 */
11904 - delta = min_addr - LOAD_PHYSICAL_ADDR;
11905 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
11906 if (!delta) {
11907 debug_putstr("No relocation needed... ");
11908 return;
11909 @@ -380,7 +380,7 @@ static void parse_elf(void *output)
11910 case PT_LOAD:
11911 #ifdef CONFIG_RELOCATABLE
11912 dest = output;
11913 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11914 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11915 #else
11916 dest = (void *)(phdr->p_paddr);
11917 #endif
11918 @@ -432,7 +432,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11919 error("Destination address too large");
11920 #endif
11921 #ifndef CONFIG_RELOCATABLE
11922 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11923 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11924 error("Wrong destination address");
11925 #endif
11926
11927 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11928 index 4d3ff03..e4972ff 100644
11929 --- a/arch/x86/boot/cpucheck.c
11930 +++ b/arch/x86/boot/cpucheck.c
11931 @@ -74,7 +74,7 @@ static int has_fpu(void)
11932 u16 fcw = -1, fsw = -1;
11933 u32 cr0;
11934
11935 - asm("movl %%cr0,%0" : "=r" (cr0));
11936 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11937 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11938 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11939 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11940 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11941 {
11942 u32 f0, f1;
11943
11944 - asm("pushfl ; "
11945 + asm volatile("pushfl ; "
11946 "pushfl ; "
11947 "popl %0 ; "
11948 "movl %0,%1 ; "
11949 @@ -115,7 +115,7 @@ static void get_flags(void)
11950 set_bit(X86_FEATURE_FPU, cpu.flags);
11951
11952 if (has_eflag(X86_EFLAGS_ID)) {
11953 - asm("cpuid"
11954 + asm volatile("cpuid"
11955 : "=a" (max_intel_level),
11956 "=b" (cpu_vendor[0]),
11957 "=d" (cpu_vendor[1]),
11958 @@ -124,7 +124,7 @@ static void get_flags(void)
11959
11960 if (max_intel_level >= 0x00000001 &&
11961 max_intel_level <= 0x0000ffff) {
11962 - asm("cpuid"
11963 + asm volatile("cpuid"
11964 : "=a" (tfms),
11965 "=c" (cpu.flags[4]),
11966 "=d" (cpu.flags[0])
11967 @@ -136,7 +136,7 @@ static void get_flags(void)
11968 cpu.model += ((tfms >> 16) & 0xf) << 4;
11969 }
11970
11971 - asm("cpuid"
11972 + asm volatile("cpuid"
11973 : "=a" (max_amd_level)
11974 : "a" (0x80000000)
11975 : "ebx", "ecx", "edx");
11976 @@ -144,7 +144,7 @@ static void get_flags(void)
11977 if (max_amd_level >= 0x80000001 &&
11978 max_amd_level <= 0x8000ffff) {
11979 u32 eax = 0x80000001;
11980 - asm("cpuid"
11981 + asm volatile("cpuid"
11982 : "+a" (eax),
11983 "=c" (cpu.flags[6]),
11984 "=d" (cpu.flags[1])
11985 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11986 u32 ecx = MSR_K7_HWCR;
11987 u32 eax, edx;
11988
11989 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11990 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11991 eax &= ~(1 << 15);
11992 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11993 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11994
11995 get_flags(); /* Make sure it really did something */
11996 err = check_flags();
11997 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11998 u32 ecx = MSR_VIA_FCR;
11999 u32 eax, edx;
12000
12001 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12002 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12003 eax |= (1<<1)|(1<<7);
12004 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12005 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12006
12007 set_bit(X86_FEATURE_CX8, cpu.flags);
12008 err = check_flags();
12009 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12010 u32 eax, edx;
12011 u32 level = 1;
12012
12013 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12014 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12015 - asm("cpuid"
12016 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12017 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12018 + asm volatile("cpuid"
12019 : "+a" (level), "=d" (cpu.flags[0])
12020 : : "ecx", "ebx");
12021 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12022 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12023
12024 err = check_flags();
12025 }
12026 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12027 index 9ec06a1..2c25e79 100644
12028 --- a/arch/x86/boot/header.S
12029 +++ b/arch/x86/boot/header.S
12030 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12031 # single linked list of
12032 # struct setup_data
12033
12034 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12035 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12036
12037 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12038 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12039 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12040 +#else
12041 #define VO_INIT_SIZE (VO__end - VO__text)
12042 +#endif
12043 #if ZO_INIT_SIZE > VO_INIT_SIZE
12044 #define INIT_SIZE ZO_INIT_SIZE
12045 #else
12046 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12047 index db75d07..8e6d0af 100644
12048 --- a/arch/x86/boot/memory.c
12049 +++ b/arch/x86/boot/memory.c
12050 @@ -19,7 +19,7 @@
12051
12052 static int detect_memory_e820(void)
12053 {
12054 - int count = 0;
12055 + unsigned int count = 0;
12056 struct biosregs ireg, oreg;
12057 struct e820entry *desc = boot_params.e820_map;
12058 static struct e820entry buf; /* static so it is zeroed */
12059 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12060 index 11e8c6e..fdbb1ed 100644
12061 --- a/arch/x86/boot/video-vesa.c
12062 +++ b/arch/x86/boot/video-vesa.c
12063 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12064
12065 boot_params.screen_info.vesapm_seg = oreg.es;
12066 boot_params.screen_info.vesapm_off = oreg.di;
12067 + boot_params.screen_info.vesapm_size = oreg.cx;
12068 }
12069
12070 /*
12071 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12072 index 43eda28..5ab5fdb 100644
12073 --- a/arch/x86/boot/video.c
12074 +++ b/arch/x86/boot/video.c
12075 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12076 static unsigned int get_entry(void)
12077 {
12078 char entry_buf[4];
12079 - int i, len = 0;
12080 + unsigned int i, len = 0;
12081 int key;
12082 unsigned int v;
12083
12084 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12085 index 9105655..5e37f27 100644
12086 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12087 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12088 @@ -8,6 +8,8 @@
12089 * including this sentence is retained in full.
12090 */
12091
12092 +#include <asm/alternative-asm.h>
12093 +
12094 .extern crypto_ft_tab
12095 .extern crypto_it_tab
12096 .extern crypto_fl_tab
12097 @@ -70,6 +72,8 @@
12098 je B192; \
12099 leaq 32(r9),r9;
12100
12101 +#define ret pax_force_retaddr 0, 1; ret
12102 +
12103 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12104 movq r1,r2; \
12105 movq r3,r4; \
12106 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12107 index 477e9d7..3ab339f 100644
12108 --- a/arch/x86/crypto/aesni-intel_asm.S
12109 +++ b/arch/x86/crypto/aesni-intel_asm.S
12110 @@ -31,6 +31,7 @@
12111
12112 #include <linux/linkage.h>
12113 #include <asm/inst.h>
12114 +#include <asm/alternative-asm.h>
12115
12116 #ifdef __x86_64__
12117 .data
12118 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12119 pop %r14
12120 pop %r13
12121 pop %r12
12122 + pax_force_retaddr 0, 1
12123 ret
12124 ENDPROC(aesni_gcm_dec)
12125
12126 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12127 pop %r14
12128 pop %r13
12129 pop %r12
12130 + pax_force_retaddr 0, 1
12131 ret
12132 ENDPROC(aesni_gcm_enc)
12133
12134 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12135 pxor %xmm1, %xmm0
12136 movaps %xmm0, (TKEYP)
12137 add $0x10, TKEYP
12138 + pax_force_retaddr_bts
12139 ret
12140 ENDPROC(_key_expansion_128)
12141 ENDPROC(_key_expansion_256a)
12142 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12143 shufps $0b01001110, %xmm2, %xmm1
12144 movaps %xmm1, 0x10(TKEYP)
12145 add $0x20, TKEYP
12146 + pax_force_retaddr_bts
12147 ret
12148 ENDPROC(_key_expansion_192a)
12149
12150 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12151
12152 movaps %xmm0, (TKEYP)
12153 add $0x10, TKEYP
12154 + pax_force_retaddr_bts
12155 ret
12156 ENDPROC(_key_expansion_192b)
12157
12158 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12159 pxor %xmm1, %xmm2
12160 movaps %xmm2, (TKEYP)
12161 add $0x10, TKEYP
12162 + pax_force_retaddr_bts
12163 ret
12164 ENDPROC(_key_expansion_256b)
12165
12166 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12167 #ifndef __x86_64__
12168 popl KEYP
12169 #endif
12170 + pax_force_retaddr 0, 1
12171 ret
12172 ENDPROC(aesni_set_key)
12173
12174 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12175 popl KLEN
12176 popl KEYP
12177 #endif
12178 + pax_force_retaddr 0, 1
12179 ret
12180 ENDPROC(aesni_enc)
12181
12182 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12183 AESENC KEY STATE
12184 movaps 0x70(TKEYP), KEY
12185 AESENCLAST KEY STATE
12186 + pax_force_retaddr_bts
12187 ret
12188 ENDPROC(_aesni_enc1)
12189
12190 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12191 AESENCLAST KEY STATE2
12192 AESENCLAST KEY STATE3
12193 AESENCLAST KEY STATE4
12194 + pax_force_retaddr_bts
12195 ret
12196 ENDPROC(_aesni_enc4)
12197
12198 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12199 popl KLEN
12200 popl KEYP
12201 #endif
12202 + pax_force_retaddr 0, 1
12203 ret
12204 ENDPROC(aesni_dec)
12205
12206 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12207 AESDEC KEY STATE
12208 movaps 0x70(TKEYP), KEY
12209 AESDECLAST KEY STATE
12210 + pax_force_retaddr_bts
12211 ret
12212 ENDPROC(_aesni_dec1)
12213
12214 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12215 AESDECLAST KEY STATE2
12216 AESDECLAST KEY STATE3
12217 AESDECLAST KEY STATE4
12218 + pax_force_retaddr_bts
12219 ret
12220 ENDPROC(_aesni_dec4)
12221
12222 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12223 popl KEYP
12224 popl LEN
12225 #endif
12226 + pax_force_retaddr 0, 1
12227 ret
12228 ENDPROC(aesni_ecb_enc)
12229
12230 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12231 popl KEYP
12232 popl LEN
12233 #endif
12234 + pax_force_retaddr 0, 1
12235 ret
12236 ENDPROC(aesni_ecb_dec)
12237
12238 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12239 popl LEN
12240 popl IVP
12241 #endif
12242 + pax_force_retaddr 0, 1
12243 ret
12244 ENDPROC(aesni_cbc_enc)
12245
12246 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12247 popl LEN
12248 popl IVP
12249 #endif
12250 + pax_force_retaddr 0, 1
12251 ret
12252 ENDPROC(aesni_cbc_dec)
12253
12254 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12255 mov $1, TCTR_LOW
12256 MOVQ_R64_XMM TCTR_LOW INC
12257 MOVQ_R64_XMM CTR TCTR_LOW
12258 + pax_force_retaddr_bts
12259 ret
12260 ENDPROC(_aesni_inc_init)
12261
12262 @@ -2579,6 +2598,7 @@ _aesni_inc:
12263 .Linc_low:
12264 movaps CTR, IV
12265 PSHUFB_XMM BSWAP_MASK IV
12266 + pax_force_retaddr_bts
12267 ret
12268 ENDPROC(_aesni_inc)
12269
12270 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12271 .Lctr_enc_ret:
12272 movups IV, (IVP)
12273 .Lctr_enc_just_ret:
12274 + pax_force_retaddr 0, 1
12275 ret
12276 ENDPROC(aesni_ctr_enc)
12277
12278 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12279 pxor INC, STATE4
12280 movdqu STATE4, 0x70(OUTP)
12281
12282 + pax_force_retaddr 0, 1
12283 ret
12284 ENDPROC(aesni_xts_crypt8)
12285
12286 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12287 index 246c670..4d1ed00 100644
12288 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12289 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12290 @@ -21,6 +21,7 @@
12291 */
12292
12293 #include <linux/linkage.h>
12294 +#include <asm/alternative-asm.h>
12295
12296 .file "blowfish-x86_64-asm.S"
12297 .text
12298 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12299 jnz .L__enc_xor;
12300
12301 write_block();
12302 + pax_force_retaddr 0, 1
12303 ret;
12304 .L__enc_xor:
12305 xor_block();
12306 + pax_force_retaddr 0, 1
12307 ret;
12308 ENDPROC(__blowfish_enc_blk)
12309
12310 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12311
12312 movq %r11, %rbp;
12313
12314 + pax_force_retaddr 0, 1
12315 ret;
12316 ENDPROC(blowfish_dec_blk)
12317
12318 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12319
12320 popq %rbx;
12321 popq %rbp;
12322 + pax_force_retaddr 0, 1
12323 ret;
12324
12325 .L__enc_xor4:
12326 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12327
12328 popq %rbx;
12329 popq %rbp;
12330 + pax_force_retaddr 0, 1
12331 ret;
12332 ENDPROC(__blowfish_enc_blk_4way)
12333
12334 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12335 popq %rbx;
12336 popq %rbp;
12337
12338 + pax_force_retaddr 0, 1
12339 ret;
12340 ENDPROC(blowfish_dec_blk_4way)
12341 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12342 index ce71f92..2dd5b1e 100644
12343 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12344 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12345 @@ -16,6 +16,7 @@
12346 */
12347
12348 #include <linux/linkage.h>
12349 +#include <asm/alternative-asm.h>
12350
12351 #define CAMELLIA_TABLE_BYTE_LEN 272
12352
12353 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12354 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12355 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12356 %rcx, (%r9));
12357 + pax_force_retaddr_bts
12358 ret;
12359 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12360
12361 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12362 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12363 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12364 %rax, (%r9));
12365 + pax_force_retaddr_bts
12366 ret;
12367 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12368
12369 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12370 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12371 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12372
12373 + pax_force_retaddr_bts
12374 ret;
12375
12376 .align 8
12377 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12378 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12379 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12380
12381 + pax_force_retaddr_bts
12382 ret;
12383
12384 .align 8
12385 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12386 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12387 %xmm8, %rsi);
12388
12389 + pax_force_retaddr 0, 1
12390 ret;
12391 ENDPROC(camellia_ecb_enc_16way)
12392
12393 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12394 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12395 %xmm8, %rsi);
12396
12397 + pax_force_retaddr 0, 1
12398 ret;
12399 ENDPROC(camellia_ecb_dec_16way)
12400
12401 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12402 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12403 %xmm8, %rsi);
12404
12405 + pax_force_retaddr 0, 1
12406 ret;
12407 ENDPROC(camellia_cbc_dec_16way)
12408
12409 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12410 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12411 %xmm8, %rsi);
12412
12413 + pax_force_retaddr 0, 1
12414 ret;
12415 ENDPROC(camellia_ctr_16way)
12416
12417 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12418 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12419 %xmm8, %rsi);
12420
12421 + pax_force_retaddr 0, 1
12422 ret;
12423 ENDPROC(camellia_xts_crypt_16way)
12424
12425 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12426 index 0e0b886..8fc756a 100644
12427 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12428 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12429 @@ -11,6 +11,7 @@
12430 */
12431
12432 #include <linux/linkage.h>
12433 +#include <asm/alternative-asm.h>
12434
12435 #define CAMELLIA_TABLE_BYTE_LEN 272
12436
12437 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12438 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12439 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12440 %rcx, (%r9));
12441 + pax_force_retaddr_bts
12442 ret;
12443 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12444
12445 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12446 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12447 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12448 %rax, (%r9));
12449 + pax_force_retaddr_bts
12450 ret;
12451 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12452
12453 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12454 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12455 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12456
12457 + pax_force_retaddr_bts
12458 ret;
12459
12460 .align 8
12461 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12462 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12463 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12464
12465 + pax_force_retaddr_bts
12466 ret;
12467
12468 .align 8
12469 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12470
12471 vzeroupper;
12472
12473 + pax_force_retaddr 0, 1
12474 ret;
12475 ENDPROC(camellia_ecb_enc_32way)
12476
12477 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12478
12479 vzeroupper;
12480
12481 + pax_force_retaddr 0, 1
12482 ret;
12483 ENDPROC(camellia_ecb_dec_32way)
12484
12485 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12486
12487 vzeroupper;
12488
12489 + pax_force_retaddr 0, 1
12490 ret;
12491 ENDPROC(camellia_cbc_dec_32way)
12492
12493 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12494
12495 vzeroupper;
12496
12497 + pax_force_retaddr 0, 1
12498 ret;
12499 ENDPROC(camellia_ctr_32way)
12500
12501 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12502
12503 vzeroupper;
12504
12505 + pax_force_retaddr 0, 1
12506 ret;
12507 ENDPROC(camellia_xts_crypt_32way)
12508
12509 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12510 index 310319c..ce174a4 100644
12511 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12512 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12513 @@ -21,6 +21,7 @@
12514 */
12515
12516 #include <linux/linkage.h>
12517 +#include <asm/alternative-asm.h>
12518
12519 .file "camellia-x86_64-asm_64.S"
12520 .text
12521 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12522 enc_outunpack(mov, RT1);
12523
12524 movq RRBP, %rbp;
12525 + pax_force_retaddr 0, 1
12526 ret;
12527
12528 .L__enc_xor:
12529 enc_outunpack(xor, RT1);
12530
12531 movq RRBP, %rbp;
12532 + pax_force_retaddr 0, 1
12533 ret;
12534 ENDPROC(__camellia_enc_blk)
12535
12536 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12537 dec_outunpack();
12538
12539 movq RRBP, %rbp;
12540 + pax_force_retaddr 0, 1
12541 ret;
12542 ENDPROC(camellia_dec_blk)
12543
12544 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12545
12546 movq RRBP, %rbp;
12547 popq %rbx;
12548 + pax_force_retaddr 0, 1
12549 ret;
12550
12551 .L__enc2_xor:
12552 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12553
12554 movq RRBP, %rbp;
12555 popq %rbx;
12556 + pax_force_retaddr 0, 1
12557 ret;
12558 ENDPROC(__camellia_enc_blk_2way)
12559
12560 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12561
12562 movq RRBP, %rbp;
12563 movq RXOR, %rbx;
12564 + pax_force_retaddr 0, 1
12565 ret;
12566 ENDPROC(camellia_dec_blk_2way)
12567 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12568 index c35fd5d..c1ee236 100644
12569 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12570 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12571 @@ -24,6 +24,7 @@
12572 */
12573
12574 #include <linux/linkage.h>
12575 +#include <asm/alternative-asm.h>
12576
12577 .file "cast5-avx-x86_64-asm_64.S"
12578
12579 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12580 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12581 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12582
12583 + pax_force_retaddr 0, 1
12584 ret;
12585 ENDPROC(__cast5_enc_blk16)
12586
12587 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12588 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12589 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12590
12591 + pax_force_retaddr 0, 1
12592 ret;
12593
12594 .L__skip_dec:
12595 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12596 vmovdqu RR4, (6*4*4)(%r11);
12597 vmovdqu RL4, (7*4*4)(%r11);
12598
12599 + pax_force_retaddr
12600 ret;
12601 ENDPROC(cast5_ecb_enc_16way)
12602
12603 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12604 vmovdqu RR4, (6*4*4)(%r11);
12605 vmovdqu RL4, (7*4*4)(%r11);
12606
12607 + pax_force_retaddr
12608 ret;
12609 ENDPROC(cast5_ecb_dec_16way)
12610
12611 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12612
12613 popq %r12;
12614
12615 + pax_force_retaddr
12616 ret;
12617 ENDPROC(cast5_cbc_dec_16way)
12618
12619 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12620
12621 popq %r12;
12622
12623 + pax_force_retaddr
12624 ret;
12625 ENDPROC(cast5_ctr_16way)
12626 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12627 index e3531f8..18ded3a 100644
12628 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12629 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12630 @@ -24,6 +24,7 @@
12631 */
12632
12633 #include <linux/linkage.h>
12634 +#include <asm/alternative-asm.h>
12635 #include "glue_helper-asm-avx.S"
12636
12637 .file "cast6-avx-x86_64-asm_64.S"
12638 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12639 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12640 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12641
12642 + pax_force_retaddr 0, 1
12643 ret;
12644 ENDPROC(__cast6_enc_blk8)
12645
12646 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12647 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12648 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12649
12650 + pax_force_retaddr 0, 1
12651 ret;
12652 ENDPROC(__cast6_dec_blk8)
12653
12654 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12655
12656 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12657
12658 + pax_force_retaddr
12659 ret;
12660 ENDPROC(cast6_ecb_enc_8way)
12661
12662 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12663
12664 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12665
12666 + pax_force_retaddr
12667 ret;
12668 ENDPROC(cast6_ecb_dec_8way)
12669
12670 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12671
12672 popq %r12;
12673
12674 + pax_force_retaddr
12675 ret;
12676 ENDPROC(cast6_cbc_dec_8way)
12677
12678 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12679
12680 popq %r12;
12681
12682 + pax_force_retaddr
12683 ret;
12684 ENDPROC(cast6_ctr_8way)
12685
12686 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12687 /* dst <= regs xor IVs(in dst) */
12688 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12689
12690 + pax_force_retaddr
12691 ret;
12692 ENDPROC(cast6_xts_enc_8way)
12693
12694 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12695 /* dst <= regs xor IVs(in dst) */
12696 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12697
12698 + pax_force_retaddr
12699 ret;
12700 ENDPROC(cast6_xts_dec_8way)
12701 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12702 index dbc4339..3d868c5 100644
12703 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12704 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12705 @@ -45,6 +45,7 @@
12706
12707 #include <asm/inst.h>
12708 #include <linux/linkage.h>
12709 +#include <asm/alternative-asm.h>
12710
12711 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12712
12713 @@ -312,6 +313,7 @@ do_return:
12714 popq %rsi
12715 popq %rdi
12716 popq %rbx
12717 + pax_force_retaddr 0, 1
12718 ret
12719
12720 ################################################################
12721 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12722 index 586f41a..d02851e 100644
12723 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12724 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12725 @@ -18,6 +18,7 @@
12726
12727 #include <linux/linkage.h>
12728 #include <asm/inst.h>
12729 +#include <asm/alternative-asm.h>
12730
12731 .data
12732
12733 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12734 psrlq $1, T2
12735 pxor T2, T1
12736 pxor T1, DATA
12737 + pax_force_retaddr
12738 ret
12739 ENDPROC(__clmul_gf128mul_ble)
12740
12741 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12742 call __clmul_gf128mul_ble
12743 PSHUFB_XMM BSWAP DATA
12744 movups DATA, (%rdi)
12745 + pax_force_retaddr
12746 ret
12747 ENDPROC(clmul_ghash_mul)
12748
12749 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12750 PSHUFB_XMM BSWAP DATA
12751 movups DATA, (%rdi)
12752 .Lupdate_just_ret:
12753 + pax_force_retaddr
12754 ret
12755 ENDPROC(clmul_ghash_update)
12756
12757 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12758 pand .Lpoly, %xmm1
12759 pxor %xmm1, %xmm0
12760 movups %xmm0, (%rdi)
12761 + pax_force_retaddr
12762 ret
12763 ENDPROC(clmul_ghash_setkey)
12764 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12765 index 9279e0b..9270820 100644
12766 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12767 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12768 @@ -1,4 +1,5 @@
12769 #include <linux/linkage.h>
12770 +#include <asm/alternative-asm.h>
12771
12772 # enter salsa20_encrypt_bytes
12773 ENTRY(salsa20_encrypt_bytes)
12774 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12775 add %r11,%rsp
12776 mov %rdi,%rax
12777 mov %rsi,%rdx
12778 + pax_force_retaddr 0, 1
12779 ret
12780 # bytesatleast65:
12781 ._bytesatleast65:
12782 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12783 add %r11,%rsp
12784 mov %rdi,%rax
12785 mov %rsi,%rdx
12786 + pax_force_retaddr
12787 ret
12788 ENDPROC(salsa20_keysetup)
12789
12790 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12791 add %r11,%rsp
12792 mov %rdi,%rax
12793 mov %rsi,%rdx
12794 + pax_force_retaddr
12795 ret
12796 ENDPROC(salsa20_ivsetup)
12797 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12798 index 2f202f4..d9164d6 100644
12799 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12800 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12801 @@ -24,6 +24,7 @@
12802 */
12803
12804 #include <linux/linkage.h>
12805 +#include <asm/alternative-asm.h>
12806 #include "glue_helper-asm-avx.S"
12807
12808 .file "serpent-avx-x86_64-asm_64.S"
12809 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12810 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12811 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12812
12813 + pax_force_retaddr
12814 ret;
12815 ENDPROC(__serpent_enc_blk8_avx)
12816
12817 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12818 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12819 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12820
12821 + pax_force_retaddr
12822 ret;
12823 ENDPROC(__serpent_dec_blk8_avx)
12824
12825 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12826
12827 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12828
12829 + pax_force_retaddr
12830 ret;
12831 ENDPROC(serpent_ecb_enc_8way_avx)
12832
12833 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12834
12835 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12836
12837 + pax_force_retaddr
12838 ret;
12839 ENDPROC(serpent_ecb_dec_8way_avx)
12840
12841 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12842
12843 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12844
12845 + pax_force_retaddr
12846 ret;
12847 ENDPROC(serpent_cbc_dec_8way_avx)
12848
12849 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12850
12851 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12852
12853 + pax_force_retaddr
12854 ret;
12855 ENDPROC(serpent_ctr_8way_avx)
12856
12857 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12858 /* dst <= regs xor IVs(in dst) */
12859 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12860
12861 + pax_force_retaddr
12862 ret;
12863 ENDPROC(serpent_xts_enc_8way_avx)
12864
12865 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12866 /* dst <= regs xor IVs(in dst) */
12867 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12868
12869 + pax_force_retaddr
12870 ret;
12871 ENDPROC(serpent_xts_dec_8way_avx)
12872 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12873 index b222085..abd483c 100644
12874 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12875 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12876 @@ -15,6 +15,7 @@
12877 */
12878
12879 #include <linux/linkage.h>
12880 +#include <asm/alternative-asm.h>
12881 #include "glue_helper-asm-avx2.S"
12882
12883 .file "serpent-avx2-asm_64.S"
12884 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12885 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12886 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12887
12888 + pax_force_retaddr
12889 ret;
12890 ENDPROC(__serpent_enc_blk16)
12891
12892 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12893 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12894 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12895
12896 + pax_force_retaddr
12897 ret;
12898 ENDPROC(__serpent_dec_blk16)
12899
12900 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12901
12902 vzeroupper;
12903
12904 + pax_force_retaddr
12905 ret;
12906 ENDPROC(serpent_ecb_enc_16way)
12907
12908 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12909
12910 vzeroupper;
12911
12912 + pax_force_retaddr
12913 ret;
12914 ENDPROC(serpent_ecb_dec_16way)
12915
12916 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12917
12918 vzeroupper;
12919
12920 + pax_force_retaddr
12921 ret;
12922 ENDPROC(serpent_cbc_dec_16way)
12923
12924 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12925
12926 vzeroupper;
12927
12928 + pax_force_retaddr
12929 ret;
12930 ENDPROC(serpent_ctr_16way)
12931
12932 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12933
12934 vzeroupper;
12935
12936 + pax_force_retaddr
12937 ret;
12938 ENDPROC(serpent_xts_enc_16way)
12939
12940 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12941
12942 vzeroupper;
12943
12944 + pax_force_retaddr
12945 ret;
12946 ENDPROC(serpent_xts_dec_16way)
12947 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12948 index acc066c..1559cc4 100644
12949 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12950 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12951 @@ -25,6 +25,7 @@
12952 */
12953
12954 #include <linux/linkage.h>
12955 +#include <asm/alternative-asm.h>
12956
12957 .file "serpent-sse2-x86_64-asm_64.S"
12958 .text
12959 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12960 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12961 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12962
12963 + pax_force_retaddr
12964 ret;
12965
12966 .L__enc_xor8:
12967 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12968 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12969
12970 + pax_force_retaddr
12971 ret;
12972 ENDPROC(__serpent_enc_blk_8way)
12973
12974 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12975 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12976 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12977
12978 + pax_force_retaddr
12979 ret;
12980 ENDPROC(serpent_dec_blk_8way)
12981 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12982 index a410950..3356d42 100644
12983 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12984 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12985 @@ -29,6 +29,7 @@
12986 */
12987
12988 #include <linux/linkage.h>
12989 +#include <asm/alternative-asm.h>
12990
12991 #define CTX %rdi // arg1
12992 #define BUF %rsi // arg2
12993 @@ -104,6 +105,7 @@
12994 pop %r12
12995 pop %rbp
12996 pop %rbx
12997 + pax_force_retaddr 0, 1
12998 ret
12999
13000 ENDPROC(\name)
13001 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13002 index 642f156..4ab07b9 100644
13003 --- a/arch/x86/crypto/sha256-avx-asm.S
13004 +++ b/arch/x86/crypto/sha256-avx-asm.S
13005 @@ -49,6 +49,7 @@
13006
13007 #ifdef CONFIG_AS_AVX
13008 #include <linux/linkage.h>
13009 +#include <asm/alternative-asm.h>
13010
13011 ## assume buffers not aligned
13012 #define VMOVDQ vmovdqu
13013 @@ -460,6 +461,7 @@ done_hash:
13014 popq %r13
13015 popq %rbp
13016 popq %rbx
13017 + pax_force_retaddr 0, 1
13018 ret
13019 ENDPROC(sha256_transform_avx)
13020
13021 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13022 index 9e86944..2e7f95a 100644
13023 --- a/arch/x86/crypto/sha256-avx2-asm.S
13024 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13025 @@ -50,6 +50,7 @@
13026
13027 #ifdef CONFIG_AS_AVX2
13028 #include <linux/linkage.h>
13029 +#include <asm/alternative-asm.h>
13030
13031 ## assume buffers not aligned
13032 #define VMOVDQ vmovdqu
13033 @@ -720,6 +721,7 @@ done_hash:
13034 popq %r12
13035 popq %rbp
13036 popq %rbx
13037 + pax_force_retaddr 0, 1
13038 ret
13039 ENDPROC(sha256_transform_rorx)
13040
13041 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13042 index f833b74..c36ed14 100644
13043 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13044 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13045 @@ -47,6 +47,7 @@
13046 ########################################################################
13047
13048 #include <linux/linkage.h>
13049 +#include <asm/alternative-asm.h>
13050
13051 ## assume buffers not aligned
13052 #define MOVDQ movdqu
13053 @@ -471,6 +472,7 @@ done_hash:
13054 popq %rbp
13055 popq %rbx
13056
13057 + pax_force_retaddr 0, 1
13058 ret
13059 ENDPROC(sha256_transform_ssse3)
13060
13061 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13062 index 974dde9..4533d34 100644
13063 --- a/arch/x86/crypto/sha512-avx-asm.S
13064 +++ b/arch/x86/crypto/sha512-avx-asm.S
13065 @@ -49,6 +49,7 @@
13066
13067 #ifdef CONFIG_AS_AVX
13068 #include <linux/linkage.h>
13069 +#include <asm/alternative-asm.h>
13070
13071 .text
13072
13073 @@ -364,6 +365,7 @@ updateblock:
13074 mov frame_RSPSAVE(%rsp), %rsp
13075
13076 nowork:
13077 + pax_force_retaddr 0, 1
13078 ret
13079 ENDPROC(sha512_transform_avx)
13080
13081 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13082 index 568b961..061ef1d 100644
13083 --- a/arch/x86/crypto/sha512-avx2-asm.S
13084 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13085 @@ -51,6 +51,7 @@
13086
13087 #ifdef CONFIG_AS_AVX2
13088 #include <linux/linkage.h>
13089 +#include <asm/alternative-asm.h>
13090
13091 .text
13092
13093 @@ -678,6 +679,7 @@ done_hash:
13094
13095 # Restore Stack Pointer
13096 mov frame_RSPSAVE(%rsp), %rsp
13097 + pax_force_retaddr 0, 1
13098 ret
13099 ENDPROC(sha512_transform_rorx)
13100
13101 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13102 index fb56855..e23914f 100644
13103 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13104 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13105 @@ -48,6 +48,7 @@
13106 ########################################################################
13107
13108 #include <linux/linkage.h>
13109 +#include <asm/alternative-asm.h>
13110
13111 .text
13112
13113 @@ -363,6 +364,7 @@ updateblock:
13114 mov frame_RSPSAVE(%rsp), %rsp
13115
13116 nowork:
13117 + pax_force_retaddr 0, 1
13118 ret
13119 ENDPROC(sha512_transform_ssse3)
13120
13121 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13122 index 0505813..63b1d00 100644
13123 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13124 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13125 @@ -24,6 +24,7 @@
13126 */
13127
13128 #include <linux/linkage.h>
13129 +#include <asm/alternative-asm.h>
13130 #include "glue_helper-asm-avx.S"
13131
13132 .file "twofish-avx-x86_64-asm_64.S"
13133 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13134 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13135 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13136
13137 + pax_force_retaddr 0, 1
13138 ret;
13139 ENDPROC(__twofish_enc_blk8)
13140
13141 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13142 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13143 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13144
13145 + pax_force_retaddr 0, 1
13146 ret;
13147 ENDPROC(__twofish_dec_blk8)
13148
13149 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13150
13151 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13152
13153 + pax_force_retaddr 0, 1
13154 ret;
13155 ENDPROC(twofish_ecb_enc_8way)
13156
13157 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13158
13159 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13160
13161 + pax_force_retaddr 0, 1
13162 ret;
13163 ENDPROC(twofish_ecb_dec_8way)
13164
13165 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13166
13167 popq %r12;
13168
13169 + pax_force_retaddr 0, 1
13170 ret;
13171 ENDPROC(twofish_cbc_dec_8way)
13172
13173 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13174
13175 popq %r12;
13176
13177 + pax_force_retaddr 0, 1
13178 ret;
13179 ENDPROC(twofish_ctr_8way)
13180
13181 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13182 /* dst <= regs xor IVs(in dst) */
13183 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13184
13185 + pax_force_retaddr 0, 1
13186 ret;
13187 ENDPROC(twofish_xts_enc_8way)
13188
13189 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13190 /* dst <= regs xor IVs(in dst) */
13191 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13192
13193 + pax_force_retaddr 0, 1
13194 ret;
13195 ENDPROC(twofish_xts_dec_8way)
13196 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13197 index 1c3b7ce..b365c5e 100644
13198 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13199 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13200 @@ -21,6 +21,7 @@
13201 */
13202
13203 #include <linux/linkage.h>
13204 +#include <asm/alternative-asm.h>
13205
13206 .file "twofish-x86_64-asm-3way.S"
13207 .text
13208 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13209 popq %r13;
13210 popq %r14;
13211 popq %r15;
13212 + pax_force_retaddr 0, 1
13213 ret;
13214
13215 .L__enc_xor3:
13216 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13217 popq %r13;
13218 popq %r14;
13219 popq %r15;
13220 + pax_force_retaddr 0, 1
13221 ret;
13222 ENDPROC(__twofish_enc_blk_3way)
13223
13224 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13225 popq %r13;
13226 popq %r14;
13227 popq %r15;
13228 + pax_force_retaddr 0, 1
13229 ret;
13230 ENDPROC(twofish_dec_blk_3way)
13231 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13232 index a039d21..29e7615 100644
13233 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13234 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13235 @@ -22,6 +22,7 @@
13236
13237 #include <linux/linkage.h>
13238 #include <asm/asm-offsets.h>
13239 +#include <asm/alternative-asm.h>
13240
13241 #define a_offset 0
13242 #define b_offset 4
13243 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13244
13245 popq R1
13246 movq $1,%rax
13247 + pax_force_retaddr 0, 1
13248 ret
13249 ENDPROC(twofish_enc_blk)
13250
13251 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13252
13253 popq R1
13254 movq $1,%rax
13255 + pax_force_retaddr 0, 1
13256 ret
13257 ENDPROC(twofish_dec_blk)
13258 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13259 index bae3aba..c1788c1 100644
13260 --- a/arch/x86/ia32/ia32_aout.c
13261 +++ b/arch/x86/ia32/ia32_aout.c
13262 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13263 unsigned long dump_start, dump_size;
13264 struct user32 dump;
13265
13266 + memset(&dump, 0, sizeof(dump));
13267 +
13268 fs = get_fs();
13269 set_fs(KERNEL_DS);
13270 has_dumped = 1;
13271 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13272 index 665a730..8e7a67a 100644
13273 --- a/arch/x86/ia32/ia32_signal.c
13274 +++ b/arch/x86/ia32/ia32_signal.c
13275 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13276 sp -= frame_size;
13277 /* Align the stack pointer according to the i386 ABI,
13278 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13279 - sp = ((sp + 4) & -16ul) - 4;
13280 + sp = ((sp - 12) & -16ul) - 4;
13281 return (void __user *) sp;
13282 }
13283
13284 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13285 * These are actually not used anymore, but left because some
13286 * gdb versions depend on them as a marker.
13287 */
13288 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13289 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13290 } put_user_catch(err);
13291
13292 if (err)
13293 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13294 0xb8,
13295 __NR_ia32_rt_sigreturn,
13296 0x80cd,
13297 - 0,
13298 + 0
13299 };
13300
13301 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13302 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13303
13304 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13305 restorer = ksig->ka.sa.sa_restorer;
13306 + else if (current->mm->context.vdso)
13307 + /* Return stub is in 32bit vsyscall page */
13308 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13309 else
13310 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13311 - rt_sigreturn);
13312 + restorer = &frame->retcode;
13313 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13314
13315 /*
13316 * Not actually used anymore, but left because some gdb
13317 * versions need it.
13318 */
13319 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13320 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13321 } put_user_catch(err);
13322
13323 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13324 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13325 index 4299eb0..904b82a 100644
13326 --- a/arch/x86/ia32/ia32entry.S
13327 +++ b/arch/x86/ia32/ia32entry.S
13328 @@ -15,8 +15,10 @@
13329 #include <asm/irqflags.h>
13330 #include <asm/asm.h>
13331 #include <asm/smap.h>
13332 +#include <asm/pgtable.h>
13333 #include <linux/linkage.h>
13334 #include <linux/err.h>
13335 +#include <asm/alternative-asm.h>
13336
13337 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13338 #include <linux/elf-em.h>
13339 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13340 ENDPROC(native_irq_enable_sysexit)
13341 #endif
13342
13343 + .macro pax_enter_kernel_user
13344 + pax_set_fptr_mask
13345 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13346 + call pax_enter_kernel_user
13347 +#endif
13348 + .endm
13349 +
13350 + .macro pax_exit_kernel_user
13351 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13352 + call pax_exit_kernel_user
13353 +#endif
13354 +#ifdef CONFIG_PAX_RANDKSTACK
13355 + pushq %rax
13356 + pushq %r11
13357 + call pax_randomize_kstack
13358 + popq %r11
13359 + popq %rax
13360 +#endif
13361 + .endm
13362 +
13363 + .macro pax_erase_kstack
13364 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13365 + call pax_erase_kstack
13366 +#endif
13367 + .endm
13368 +
13369 /*
13370 * 32bit SYSENTER instruction entry.
13371 *
13372 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13373 CFI_REGISTER rsp,rbp
13374 SWAPGS_UNSAFE_STACK
13375 movq PER_CPU_VAR(kernel_stack), %rsp
13376 - addq $(KERNEL_STACK_OFFSET),%rsp
13377 - /*
13378 - * No need to follow this irqs on/off section: the syscall
13379 - * disabled irqs, here we enable it straight after entry:
13380 - */
13381 - ENABLE_INTERRUPTS(CLBR_NONE)
13382 movl %ebp,%ebp /* zero extension */
13383 pushq_cfi $__USER32_DS
13384 /*CFI_REL_OFFSET ss,0*/
13385 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13386 CFI_REL_OFFSET rsp,0
13387 pushfq_cfi
13388 /*CFI_REL_OFFSET rflags,0*/
13389 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13390 - CFI_REGISTER rip,r10
13391 + orl $X86_EFLAGS_IF,(%rsp)
13392 + GET_THREAD_INFO(%r11)
13393 + movl TI_sysenter_return(%r11), %r11d
13394 + CFI_REGISTER rip,r11
13395 pushq_cfi $__USER32_CS
13396 /*CFI_REL_OFFSET cs,0*/
13397 movl %eax, %eax
13398 - pushq_cfi %r10
13399 + pushq_cfi %r11
13400 CFI_REL_OFFSET rip,0
13401 pushq_cfi %rax
13402 cld
13403 SAVE_ARGS 0,1,0
13404 + pax_enter_kernel_user
13405 +
13406 +#ifdef CONFIG_PAX_RANDKSTACK
13407 + pax_erase_kstack
13408 +#endif
13409 +
13410 + /*
13411 + * No need to follow this irqs on/off section: the syscall
13412 + * disabled irqs, here we enable it straight after entry:
13413 + */
13414 + ENABLE_INTERRUPTS(CLBR_NONE)
13415 /* no need to do an access_ok check here because rbp has been
13416 32bit zero extended */
13417 +
13418 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13419 + addq pax_user_shadow_base,%rbp
13420 + ASM_PAX_OPEN_USERLAND
13421 +#endif
13422 +
13423 ASM_STAC
13424 1: movl (%rbp),%ebp
13425 _ASM_EXTABLE(1b,ia32_badarg)
13426 ASM_CLAC
13427 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13428 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13429 +
13430 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13431 + ASM_PAX_CLOSE_USERLAND
13432 +#endif
13433 +
13434 + GET_THREAD_INFO(%r11)
13435 + orl $TS_COMPAT,TI_status(%r11)
13436 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13437 CFI_REMEMBER_STATE
13438 jnz sysenter_tracesys
13439 cmpq $(IA32_NR_syscalls-1),%rax
13440 @@ -162,12 +209,15 @@ sysenter_do_call:
13441 sysenter_dispatch:
13442 call *ia32_sys_call_table(,%rax,8)
13443 movq %rax,RAX-ARGOFFSET(%rsp)
13444 + GET_THREAD_INFO(%r11)
13445 DISABLE_INTERRUPTS(CLBR_NONE)
13446 TRACE_IRQS_OFF
13447 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13448 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13449 jnz sysexit_audit
13450 sysexit_from_sys_call:
13451 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13452 + pax_exit_kernel_user
13453 + pax_erase_kstack
13454 + andl $~TS_COMPAT,TI_status(%r11)
13455 /* clear IF, that popfq doesn't enable interrupts early */
13456 andl $~0x200,EFLAGS-R11(%rsp)
13457 movl RIP-R11(%rsp),%edx /* User %eip */
13458 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13459 movl %eax,%esi /* 2nd arg: syscall number */
13460 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13461 call __audit_syscall_entry
13462 +
13463 + pax_erase_kstack
13464 +
13465 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13466 cmpq $(IA32_NR_syscalls-1),%rax
13467 ja ia32_badsys
13468 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13469 .endm
13470
13471 .macro auditsys_exit exit
13472 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13473 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13474 jnz ia32_ret_from_sys_call
13475 TRACE_IRQS_ON
13476 ENABLE_INTERRUPTS(CLBR_NONE)
13477 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13478 1: setbe %al /* 1 if error, 0 if not */
13479 movzbl %al,%edi /* zero-extend that into %edi */
13480 call __audit_syscall_exit
13481 + GET_THREAD_INFO(%r11)
13482 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13483 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13484 DISABLE_INTERRUPTS(CLBR_NONE)
13485 TRACE_IRQS_OFF
13486 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13487 + testl %edi,TI_flags(%r11)
13488 jz \exit
13489 CLEAR_RREGS -ARGOFFSET
13490 jmp int_with_check
13491 @@ -237,7 +291,7 @@ sysexit_audit:
13492
13493 sysenter_tracesys:
13494 #ifdef CONFIG_AUDITSYSCALL
13495 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13496 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13497 jz sysenter_auditsys
13498 #endif
13499 SAVE_REST
13500 @@ -249,6 +303,9 @@ sysenter_tracesys:
13501 RESTORE_REST
13502 cmpq $(IA32_NR_syscalls-1),%rax
13503 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13504 +
13505 + pax_erase_kstack
13506 +
13507 jmp sysenter_do_call
13508 CFI_ENDPROC
13509 ENDPROC(ia32_sysenter_target)
13510 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13511 ENTRY(ia32_cstar_target)
13512 CFI_STARTPROC32 simple
13513 CFI_SIGNAL_FRAME
13514 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13515 + CFI_DEF_CFA rsp,0
13516 CFI_REGISTER rip,rcx
13517 /*CFI_REGISTER rflags,r11*/
13518 SWAPGS_UNSAFE_STACK
13519 movl %esp,%r8d
13520 CFI_REGISTER rsp,r8
13521 movq PER_CPU_VAR(kernel_stack),%rsp
13522 + SAVE_ARGS 8*6,0,0
13523 + pax_enter_kernel_user
13524 +
13525 +#ifdef CONFIG_PAX_RANDKSTACK
13526 + pax_erase_kstack
13527 +#endif
13528 +
13529 /*
13530 * No need to follow this irqs on/off section: the syscall
13531 * disabled irqs and here we enable it straight after entry:
13532 */
13533 ENABLE_INTERRUPTS(CLBR_NONE)
13534 - SAVE_ARGS 8,0,0
13535 movl %eax,%eax /* zero extension */
13536 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13537 movq %rcx,RIP-ARGOFFSET(%rsp)
13538 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13539 /* no need to do an access_ok check here because r8 has been
13540 32bit zero extended */
13541 /* hardware stack frame is complete now */
13542 +
13543 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13544 + ASM_PAX_OPEN_USERLAND
13545 + movq pax_user_shadow_base,%r8
13546 + addq RSP-ARGOFFSET(%rsp),%r8
13547 +#endif
13548 +
13549 ASM_STAC
13550 1: movl (%r8),%r9d
13551 _ASM_EXTABLE(1b,ia32_badarg)
13552 ASM_CLAC
13553 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13554 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13555 +
13556 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13557 + ASM_PAX_CLOSE_USERLAND
13558 +#endif
13559 +
13560 + GET_THREAD_INFO(%r11)
13561 + orl $TS_COMPAT,TI_status(%r11)
13562 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13563 CFI_REMEMBER_STATE
13564 jnz cstar_tracesys
13565 cmpq $IA32_NR_syscalls-1,%rax
13566 @@ -319,12 +395,15 @@ cstar_do_call:
13567 cstar_dispatch:
13568 call *ia32_sys_call_table(,%rax,8)
13569 movq %rax,RAX-ARGOFFSET(%rsp)
13570 + GET_THREAD_INFO(%r11)
13571 DISABLE_INTERRUPTS(CLBR_NONE)
13572 TRACE_IRQS_OFF
13573 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13574 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13575 jnz sysretl_audit
13576 sysretl_from_sys_call:
13577 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13578 + pax_exit_kernel_user
13579 + pax_erase_kstack
13580 + andl $~TS_COMPAT,TI_status(%r11)
13581 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13582 movl RIP-ARGOFFSET(%rsp),%ecx
13583 CFI_REGISTER rip,rcx
13584 @@ -352,7 +431,7 @@ sysretl_audit:
13585
13586 cstar_tracesys:
13587 #ifdef CONFIG_AUDITSYSCALL
13588 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13589 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13590 jz cstar_auditsys
13591 #endif
13592 xchgl %r9d,%ebp
13593 @@ -366,11 +445,19 @@ cstar_tracesys:
13594 xchgl %ebp,%r9d
13595 cmpq $(IA32_NR_syscalls-1),%rax
13596 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13597 +
13598 + pax_erase_kstack
13599 +
13600 jmp cstar_do_call
13601 END(ia32_cstar_target)
13602
13603 ia32_badarg:
13604 ASM_CLAC
13605 +
13606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13607 + ASM_PAX_CLOSE_USERLAND
13608 +#endif
13609 +
13610 movq $-EFAULT,%rax
13611 jmp ia32_sysret
13612 CFI_ENDPROC
13613 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13614 CFI_REL_OFFSET rip,RIP-RIP
13615 PARAVIRT_ADJUST_EXCEPTION_FRAME
13616 SWAPGS
13617 - /*
13618 - * No need to follow this irqs on/off section: the syscall
13619 - * disabled irqs and here we enable it straight after entry:
13620 - */
13621 - ENABLE_INTERRUPTS(CLBR_NONE)
13622 movl %eax,%eax
13623 pushq_cfi %rax
13624 cld
13625 /* note the registers are not zero extended to the sf.
13626 this could be a problem. */
13627 SAVE_ARGS 0,1,0
13628 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13629 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13630 + pax_enter_kernel_user
13631 +
13632 +#ifdef CONFIG_PAX_RANDKSTACK
13633 + pax_erase_kstack
13634 +#endif
13635 +
13636 + /*
13637 + * No need to follow this irqs on/off section: the syscall
13638 + * disabled irqs and here we enable it straight after entry:
13639 + */
13640 + ENABLE_INTERRUPTS(CLBR_NONE)
13641 + GET_THREAD_INFO(%r11)
13642 + orl $TS_COMPAT,TI_status(%r11)
13643 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13644 jnz ia32_tracesys
13645 cmpq $(IA32_NR_syscalls-1),%rax
13646 ja ia32_badsys
13647 @@ -442,6 +536,9 @@ ia32_tracesys:
13648 RESTORE_REST
13649 cmpq $(IA32_NR_syscalls-1),%rax
13650 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13651 +
13652 + pax_erase_kstack
13653 +
13654 jmp ia32_do_call
13655 END(ia32_syscall)
13656
13657 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13658 index 8e0ceec..af13504 100644
13659 --- a/arch/x86/ia32/sys_ia32.c
13660 +++ b/arch/x86/ia32/sys_ia32.c
13661 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13662 */
13663 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13664 {
13665 - typeof(ubuf->st_uid) uid = 0;
13666 - typeof(ubuf->st_gid) gid = 0;
13667 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13668 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13669 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13670 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13671 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13672 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13673 index 372231c..a5aa1a1 100644
13674 --- a/arch/x86/include/asm/alternative-asm.h
13675 +++ b/arch/x86/include/asm/alternative-asm.h
13676 @@ -18,6 +18,45 @@
13677 .endm
13678 #endif
13679
13680 +#ifdef KERNEXEC_PLUGIN
13681 + .macro pax_force_retaddr_bts rip=0
13682 + btsq $63,\rip(%rsp)
13683 + .endm
13684 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13685 + .macro pax_force_retaddr rip=0, reload=0
13686 + btsq $63,\rip(%rsp)
13687 + .endm
13688 + .macro pax_force_fptr ptr
13689 + btsq $63,\ptr
13690 + .endm
13691 + .macro pax_set_fptr_mask
13692 + .endm
13693 +#endif
13694 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13695 + .macro pax_force_retaddr rip=0, reload=0
13696 + .if \reload
13697 + pax_set_fptr_mask
13698 + .endif
13699 + orq %r10,\rip(%rsp)
13700 + .endm
13701 + .macro pax_force_fptr ptr
13702 + orq %r10,\ptr
13703 + .endm
13704 + .macro pax_set_fptr_mask
13705 + movabs $0x8000000000000000,%r10
13706 + .endm
13707 +#endif
13708 +#else
13709 + .macro pax_force_retaddr rip=0, reload=0
13710 + .endm
13711 + .macro pax_force_fptr ptr
13712 + .endm
13713 + .macro pax_force_retaddr_bts rip=0
13714 + .endm
13715 + .macro pax_set_fptr_mask
13716 + .endm
13717 +#endif
13718 +
13719 .macro altinstruction_entry orig alt feature orig_len alt_len
13720 .long \orig - .
13721 .long \alt - .
13722 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13723 index 0a3f9c9..c9d081d 100644
13724 --- a/arch/x86/include/asm/alternative.h
13725 +++ b/arch/x86/include/asm/alternative.h
13726 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13727 ".pushsection .discard,\"aw\",@progbits\n" \
13728 DISCARD_ENTRY(1) \
13729 ".popsection\n" \
13730 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13731 + ".pushsection .altinstr_replacement, \"a\"\n" \
13732 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13733 ".popsection"
13734
13735 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13736 DISCARD_ENTRY(1) \
13737 DISCARD_ENTRY(2) \
13738 ".popsection\n" \
13739 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13740 + ".pushsection .altinstr_replacement, \"a\"\n" \
13741 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13742 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13743 ".popsection"
13744 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13745 index 1d2091a..f5074c1 100644
13746 --- a/arch/x86/include/asm/apic.h
13747 +++ b/arch/x86/include/asm/apic.h
13748 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13749
13750 #ifdef CONFIG_X86_LOCAL_APIC
13751
13752 -extern unsigned int apic_verbosity;
13753 +extern int apic_verbosity;
13754 extern int local_apic_timer_c2_ok;
13755
13756 extern int disable_apic;
13757 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13758 index 20370c6..a2eb9b0 100644
13759 --- a/arch/x86/include/asm/apm.h
13760 +++ b/arch/x86/include/asm/apm.h
13761 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13762 __asm__ __volatile__(APM_DO_ZERO_SEGS
13763 "pushl %%edi\n\t"
13764 "pushl %%ebp\n\t"
13765 - "lcall *%%cs:apm_bios_entry\n\t"
13766 + "lcall *%%ss:apm_bios_entry\n\t"
13767 "setc %%al\n\t"
13768 "popl %%ebp\n\t"
13769 "popl %%edi\n\t"
13770 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13771 __asm__ __volatile__(APM_DO_ZERO_SEGS
13772 "pushl %%edi\n\t"
13773 "pushl %%ebp\n\t"
13774 - "lcall *%%cs:apm_bios_entry\n\t"
13775 + "lcall *%%ss:apm_bios_entry\n\t"
13776 "setc %%bl\n\t"
13777 "popl %%ebp\n\t"
13778 "popl %%edi\n\t"
13779 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13780 index 722aa3b..3a0bb27 100644
13781 --- a/arch/x86/include/asm/atomic.h
13782 +++ b/arch/x86/include/asm/atomic.h
13783 @@ -22,7 +22,18 @@
13784 */
13785 static inline int atomic_read(const atomic_t *v)
13786 {
13787 - return (*(volatile int *)&(v)->counter);
13788 + return (*(volatile const int *)&(v)->counter);
13789 +}
13790 +
13791 +/**
13792 + * atomic_read_unchecked - read atomic variable
13793 + * @v: pointer of type atomic_unchecked_t
13794 + *
13795 + * Atomically reads the value of @v.
13796 + */
13797 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13798 +{
13799 + return (*(volatile const int *)&(v)->counter);
13800 }
13801
13802 /**
13803 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13804 }
13805
13806 /**
13807 + * atomic_set_unchecked - set atomic variable
13808 + * @v: pointer of type atomic_unchecked_t
13809 + * @i: required value
13810 + *
13811 + * Atomically sets the value of @v to @i.
13812 + */
13813 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13814 +{
13815 + v->counter = i;
13816 +}
13817 +
13818 +/**
13819 * atomic_add - add integer to atomic variable
13820 * @i: integer value to add
13821 * @v: pointer of type atomic_t
13822 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13823 */
13824 static inline void atomic_add(int i, atomic_t *v)
13825 {
13826 - asm volatile(LOCK_PREFIX "addl %1,%0"
13827 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13828 +
13829 +#ifdef CONFIG_PAX_REFCOUNT
13830 + "jno 0f\n"
13831 + LOCK_PREFIX "subl %1,%0\n"
13832 + "int $4\n0:\n"
13833 + _ASM_EXTABLE(0b, 0b)
13834 +#endif
13835 +
13836 + : "+m" (v->counter)
13837 + : "ir" (i));
13838 +}
13839 +
13840 +/**
13841 + * atomic_add_unchecked - add integer to atomic variable
13842 + * @i: integer value to add
13843 + * @v: pointer of type atomic_unchecked_t
13844 + *
13845 + * Atomically adds @i to @v.
13846 + */
13847 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13848 +{
13849 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13850 : "+m" (v->counter)
13851 : "ir" (i));
13852 }
13853 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13854 */
13855 static inline void atomic_sub(int i, atomic_t *v)
13856 {
13857 - asm volatile(LOCK_PREFIX "subl %1,%0"
13858 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13859 +
13860 +#ifdef CONFIG_PAX_REFCOUNT
13861 + "jno 0f\n"
13862 + LOCK_PREFIX "addl %1,%0\n"
13863 + "int $4\n0:\n"
13864 + _ASM_EXTABLE(0b, 0b)
13865 +#endif
13866 +
13867 + : "+m" (v->counter)
13868 + : "ir" (i));
13869 +}
13870 +
13871 +/**
13872 + * atomic_sub_unchecked - subtract integer from atomic variable
13873 + * @i: integer value to subtract
13874 + * @v: pointer of type atomic_unchecked_t
13875 + *
13876 + * Atomically subtracts @i from @v.
13877 + */
13878 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13879 +{
13880 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13881 : "+m" (v->counter)
13882 : "ir" (i));
13883 }
13884 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13885 {
13886 unsigned char c;
13887
13888 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13889 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13890 +
13891 +#ifdef CONFIG_PAX_REFCOUNT
13892 + "jno 0f\n"
13893 + LOCK_PREFIX "addl %2,%0\n"
13894 + "int $4\n0:\n"
13895 + _ASM_EXTABLE(0b, 0b)
13896 +#endif
13897 +
13898 + "sete %1\n"
13899 : "+m" (v->counter), "=qm" (c)
13900 : "ir" (i) : "memory");
13901 return c;
13902 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13903 */
13904 static inline void atomic_inc(atomic_t *v)
13905 {
13906 - asm volatile(LOCK_PREFIX "incl %0"
13907 + asm volatile(LOCK_PREFIX "incl %0\n"
13908 +
13909 +#ifdef CONFIG_PAX_REFCOUNT
13910 + "jno 0f\n"
13911 + LOCK_PREFIX "decl %0\n"
13912 + "int $4\n0:\n"
13913 + _ASM_EXTABLE(0b, 0b)
13914 +#endif
13915 +
13916 + : "+m" (v->counter));
13917 +}
13918 +
13919 +/**
13920 + * atomic_inc_unchecked - increment atomic variable
13921 + * @v: pointer of type atomic_unchecked_t
13922 + *
13923 + * Atomically increments @v by 1.
13924 + */
13925 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13926 +{
13927 + asm volatile(LOCK_PREFIX "incl %0\n"
13928 : "+m" (v->counter));
13929 }
13930
13931 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13932 */
13933 static inline void atomic_dec(atomic_t *v)
13934 {
13935 - asm volatile(LOCK_PREFIX "decl %0"
13936 + asm volatile(LOCK_PREFIX "decl %0\n"
13937 +
13938 +#ifdef CONFIG_PAX_REFCOUNT
13939 + "jno 0f\n"
13940 + LOCK_PREFIX "incl %0\n"
13941 + "int $4\n0:\n"
13942 + _ASM_EXTABLE(0b, 0b)
13943 +#endif
13944 +
13945 + : "+m" (v->counter));
13946 +}
13947 +
13948 +/**
13949 + * atomic_dec_unchecked - decrement atomic variable
13950 + * @v: pointer of type atomic_unchecked_t
13951 + *
13952 + * Atomically decrements @v by 1.
13953 + */
13954 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13955 +{
13956 + asm volatile(LOCK_PREFIX "decl %0\n"
13957 : "+m" (v->counter));
13958 }
13959
13960 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13961 {
13962 unsigned char c;
13963
13964 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13965 + asm volatile(LOCK_PREFIX "decl %0\n"
13966 +
13967 +#ifdef CONFIG_PAX_REFCOUNT
13968 + "jno 0f\n"
13969 + LOCK_PREFIX "incl %0\n"
13970 + "int $4\n0:\n"
13971 + _ASM_EXTABLE(0b, 0b)
13972 +#endif
13973 +
13974 + "sete %1\n"
13975 : "+m" (v->counter), "=qm" (c)
13976 : : "memory");
13977 return c != 0;
13978 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13979 {
13980 unsigned char c;
13981
13982 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13983 + asm volatile(LOCK_PREFIX "incl %0\n"
13984 +
13985 +#ifdef CONFIG_PAX_REFCOUNT
13986 + "jno 0f\n"
13987 + LOCK_PREFIX "decl %0\n"
13988 + "int $4\n0:\n"
13989 + _ASM_EXTABLE(0b, 0b)
13990 +#endif
13991 +
13992 + "sete %1\n"
13993 + : "+m" (v->counter), "=qm" (c)
13994 + : : "memory");
13995 + return c != 0;
13996 +}
13997 +
13998 +/**
13999 + * atomic_inc_and_test_unchecked - increment and test
14000 + * @v: pointer of type atomic_unchecked_t
14001 + *
14002 + * Atomically increments @v by 1
14003 + * and returns true if the result is zero, or false for all
14004 + * other cases.
14005 + */
14006 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14007 +{
14008 + unsigned char c;
14009 +
14010 + asm volatile(LOCK_PREFIX "incl %0\n"
14011 + "sete %1\n"
14012 : "+m" (v->counter), "=qm" (c)
14013 : : "memory");
14014 return c != 0;
14015 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14016 {
14017 unsigned char c;
14018
14019 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14020 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14021 +
14022 +#ifdef CONFIG_PAX_REFCOUNT
14023 + "jno 0f\n"
14024 + LOCK_PREFIX "subl %2,%0\n"
14025 + "int $4\n0:\n"
14026 + _ASM_EXTABLE(0b, 0b)
14027 +#endif
14028 +
14029 + "sets %1\n"
14030 : "+m" (v->counter), "=qm" (c)
14031 : "ir" (i) : "memory");
14032 return c;
14033 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14034 */
14035 static inline int atomic_add_return(int i, atomic_t *v)
14036 {
14037 + return i + xadd_check_overflow(&v->counter, i);
14038 +}
14039 +
14040 +/**
14041 + * atomic_add_return_unchecked - add integer and return
14042 + * @i: integer value to add
14043 + * @v: pointer of type atomic_unchecked_t
14044 + *
14045 + * Atomically adds @i to @v and returns @i + @v
14046 + */
14047 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14048 +{
14049 return i + xadd(&v->counter, i);
14050 }
14051
14052 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14053 }
14054
14055 #define atomic_inc_return(v) (atomic_add_return(1, v))
14056 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14057 +{
14058 + return atomic_add_return_unchecked(1, v);
14059 +}
14060 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14061
14062 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14063 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14064 return cmpxchg(&v->counter, old, new);
14065 }
14066
14067 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14068 +{
14069 + return cmpxchg(&v->counter, old, new);
14070 +}
14071 +
14072 static inline int atomic_xchg(atomic_t *v, int new)
14073 {
14074 return xchg(&v->counter, new);
14075 }
14076
14077 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14078 +{
14079 + return xchg(&v->counter, new);
14080 +}
14081 +
14082 /**
14083 * __atomic_add_unless - add unless the number is already a given value
14084 * @v: pointer of type atomic_t
14085 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14086 */
14087 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14088 {
14089 - int c, old;
14090 + int c, old, new;
14091 c = atomic_read(v);
14092 for (;;) {
14093 - if (unlikely(c == (u)))
14094 + if (unlikely(c == u))
14095 break;
14096 - old = atomic_cmpxchg((v), c, c + (a));
14097 +
14098 + asm volatile("addl %2,%0\n"
14099 +
14100 +#ifdef CONFIG_PAX_REFCOUNT
14101 + "jno 0f\n"
14102 + "subl %2,%0\n"
14103 + "int $4\n0:\n"
14104 + _ASM_EXTABLE(0b, 0b)
14105 +#endif
14106 +
14107 + : "=r" (new)
14108 + : "0" (c), "ir" (a));
14109 +
14110 + old = atomic_cmpxchg(v, c, new);
14111 if (likely(old == c))
14112 break;
14113 c = old;
14114 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14115 }
14116
14117 /**
14118 + * atomic_inc_not_zero_hint - increment if not null
14119 + * @v: pointer of type atomic_t
14120 + * @hint: probable value of the atomic before the increment
14121 + *
14122 + * This version of atomic_inc_not_zero() gives a hint of probable
14123 + * value of the atomic. This helps processor to not read the memory
14124 + * before doing the atomic read/modify/write cycle, lowering
14125 + * number of bus transactions on some arches.
14126 + *
14127 + * Returns: 0 if increment was not done, 1 otherwise.
14128 + */
14129 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14130 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14131 +{
14132 + int val, c = hint, new;
14133 +
14134 + /* sanity test, should be removed by compiler if hint is a constant */
14135 + if (!hint)
14136 + return __atomic_add_unless(v, 1, 0);
14137 +
14138 + do {
14139 + asm volatile("incl %0\n"
14140 +
14141 +#ifdef CONFIG_PAX_REFCOUNT
14142 + "jno 0f\n"
14143 + "decl %0\n"
14144 + "int $4\n0:\n"
14145 + _ASM_EXTABLE(0b, 0b)
14146 +#endif
14147 +
14148 + : "=r" (new)
14149 + : "0" (c));
14150 +
14151 + val = atomic_cmpxchg(v, c, new);
14152 + if (val == c)
14153 + return 1;
14154 + c = val;
14155 + } while (c);
14156 +
14157 + return 0;
14158 +}
14159 +
14160 +/**
14161 * atomic_inc_short - increment of a short integer
14162 * @v: pointer to type int
14163 *
14164 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14165 #endif
14166
14167 /* These are x86-specific, used by some header files */
14168 -#define atomic_clear_mask(mask, addr) \
14169 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14170 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14171 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14172 +{
14173 + asm volatile(LOCK_PREFIX "andl %1,%0"
14174 + : "+m" (v->counter)
14175 + : "r" (~(mask))
14176 + : "memory");
14177 +}
14178
14179 -#define atomic_set_mask(mask, addr) \
14180 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14181 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14182 - : "memory")
14183 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14184 +{
14185 + asm volatile(LOCK_PREFIX "andl %1,%0"
14186 + : "+m" (v->counter)
14187 + : "r" (~(mask))
14188 + : "memory");
14189 +}
14190 +
14191 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14192 +{
14193 + asm volatile(LOCK_PREFIX "orl %1,%0"
14194 + : "+m" (v->counter)
14195 + : "r" (mask)
14196 + : "memory");
14197 +}
14198 +
14199 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14200 +{
14201 + asm volatile(LOCK_PREFIX "orl %1,%0"
14202 + : "+m" (v->counter)
14203 + : "r" (mask)
14204 + : "memory");
14205 +}
14206
14207 /* Atomic operations are already serializing on x86 */
14208 #define smp_mb__before_atomic_dec() barrier()
14209 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14210 index b154de7..aadebd8 100644
14211 --- a/arch/x86/include/asm/atomic64_32.h
14212 +++ b/arch/x86/include/asm/atomic64_32.h
14213 @@ -12,6 +12,14 @@ typedef struct {
14214 u64 __aligned(8) counter;
14215 } atomic64_t;
14216
14217 +#ifdef CONFIG_PAX_REFCOUNT
14218 +typedef struct {
14219 + u64 __aligned(8) counter;
14220 +} atomic64_unchecked_t;
14221 +#else
14222 +typedef atomic64_t atomic64_unchecked_t;
14223 +#endif
14224 +
14225 #define ATOMIC64_INIT(val) { (val) }
14226
14227 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14228 @@ -37,21 +45,31 @@ typedef struct {
14229 ATOMIC64_DECL_ONE(sym##_386)
14230
14231 ATOMIC64_DECL_ONE(add_386);
14232 +ATOMIC64_DECL_ONE(add_unchecked_386);
14233 ATOMIC64_DECL_ONE(sub_386);
14234 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14235 ATOMIC64_DECL_ONE(inc_386);
14236 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14237 ATOMIC64_DECL_ONE(dec_386);
14238 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14239 #endif
14240
14241 #define alternative_atomic64(f, out, in...) \
14242 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14243
14244 ATOMIC64_DECL(read);
14245 +ATOMIC64_DECL(read_unchecked);
14246 ATOMIC64_DECL(set);
14247 +ATOMIC64_DECL(set_unchecked);
14248 ATOMIC64_DECL(xchg);
14249 ATOMIC64_DECL(add_return);
14250 +ATOMIC64_DECL(add_return_unchecked);
14251 ATOMIC64_DECL(sub_return);
14252 +ATOMIC64_DECL(sub_return_unchecked);
14253 ATOMIC64_DECL(inc_return);
14254 +ATOMIC64_DECL(inc_return_unchecked);
14255 ATOMIC64_DECL(dec_return);
14256 +ATOMIC64_DECL(dec_return_unchecked);
14257 ATOMIC64_DECL(dec_if_positive);
14258 ATOMIC64_DECL(inc_not_zero);
14259 ATOMIC64_DECL(add_unless);
14260 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14261 }
14262
14263 /**
14264 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14265 + * @p: pointer to type atomic64_unchecked_t
14266 + * @o: expected value
14267 + * @n: new value
14268 + *
14269 + * Atomically sets @v to @n if it was equal to @o and returns
14270 + * the old value.
14271 + */
14272 +
14273 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14274 +{
14275 + return cmpxchg64(&v->counter, o, n);
14276 +}
14277 +
14278 +/**
14279 * atomic64_xchg - xchg atomic64 variable
14280 * @v: pointer to type atomic64_t
14281 * @n: value to assign
14282 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14283 }
14284
14285 /**
14286 + * atomic64_set_unchecked - set atomic64 variable
14287 + * @v: pointer to type atomic64_unchecked_t
14288 + * @n: value to assign
14289 + *
14290 + * Atomically sets the value of @v to @n.
14291 + */
14292 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14293 +{
14294 + unsigned high = (unsigned)(i >> 32);
14295 + unsigned low = (unsigned)i;
14296 + alternative_atomic64(set, /* no output */,
14297 + "S" (v), "b" (low), "c" (high)
14298 + : "eax", "edx", "memory");
14299 +}
14300 +
14301 +/**
14302 * atomic64_read - read atomic64 variable
14303 * @v: pointer to type atomic64_t
14304 *
14305 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14306 }
14307
14308 /**
14309 + * atomic64_read_unchecked - read atomic64 variable
14310 + * @v: pointer to type atomic64_unchecked_t
14311 + *
14312 + * Atomically reads the value of @v and returns it.
14313 + */
14314 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14315 +{
14316 + long long r;
14317 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14318 + return r;
14319 + }
14320 +
14321 +/**
14322 * atomic64_add_return - add and return
14323 * @i: integer value to add
14324 * @v: pointer to type atomic64_t
14325 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14326 return i;
14327 }
14328
14329 +/**
14330 + * atomic64_add_return_unchecked - add and return
14331 + * @i: integer value to add
14332 + * @v: pointer to type atomic64_unchecked_t
14333 + *
14334 + * Atomically adds @i to @v and returns @i + *@v
14335 + */
14336 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14337 +{
14338 + alternative_atomic64(add_return_unchecked,
14339 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14340 + ASM_NO_INPUT_CLOBBER("memory"));
14341 + return i;
14342 +}
14343 +
14344 /*
14345 * Other variants with different arithmetic operators:
14346 */
14347 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14348 return a;
14349 }
14350
14351 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14352 +{
14353 + long long a;
14354 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14355 + "S" (v) : "memory", "ecx");
14356 + return a;
14357 +}
14358 +
14359 static inline long long atomic64_dec_return(atomic64_t *v)
14360 {
14361 long long a;
14362 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14363 }
14364
14365 /**
14366 + * atomic64_add_unchecked - add integer to atomic64 variable
14367 + * @i: integer value to add
14368 + * @v: pointer to type atomic64_unchecked_t
14369 + *
14370 + * Atomically adds @i to @v.
14371 + */
14372 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14373 +{
14374 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14375 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14376 + ASM_NO_INPUT_CLOBBER("memory"));
14377 + return i;
14378 +}
14379 +
14380 +/**
14381 * atomic64_sub - subtract the atomic64 variable
14382 * @i: integer value to subtract
14383 * @v: pointer to type atomic64_t
14384 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14385 index 0e1cbfc..5623683 100644
14386 --- a/arch/x86/include/asm/atomic64_64.h
14387 +++ b/arch/x86/include/asm/atomic64_64.h
14388 @@ -18,7 +18,19 @@
14389 */
14390 static inline long atomic64_read(const atomic64_t *v)
14391 {
14392 - return (*(volatile long *)&(v)->counter);
14393 + return (*(volatile const long *)&(v)->counter);
14394 +}
14395 +
14396 +/**
14397 + * atomic64_read_unchecked - read atomic64 variable
14398 + * @v: pointer of type atomic64_unchecked_t
14399 + *
14400 + * Atomically reads the value of @v.
14401 + * Doesn't imply a read memory barrier.
14402 + */
14403 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14404 +{
14405 + return (*(volatile const long *)&(v)->counter);
14406 }
14407
14408 /**
14409 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14410 }
14411
14412 /**
14413 + * atomic64_set_unchecked - set atomic64 variable
14414 + * @v: pointer to type atomic64_unchecked_t
14415 + * @i: required value
14416 + *
14417 + * Atomically sets the value of @v to @i.
14418 + */
14419 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14420 +{
14421 + v->counter = i;
14422 +}
14423 +
14424 +/**
14425 * atomic64_add - add integer to atomic64 variable
14426 * @i: integer value to add
14427 * @v: pointer to type atomic64_t
14428 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14429 */
14430 static inline void atomic64_add(long i, atomic64_t *v)
14431 {
14432 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14433 +
14434 +#ifdef CONFIG_PAX_REFCOUNT
14435 + "jno 0f\n"
14436 + LOCK_PREFIX "subq %1,%0\n"
14437 + "int $4\n0:\n"
14438 + _ASM_EXTABLE(0b, 0b)
14439 +#endif
14440 +
14441 + : "=m" (v->counter)
14442 + : "er" (i), "m" (v->counter));
14443 +}
14444 +
14445 +/**
14446 + * atomic64_add_unchecked - add integer to atomic64 variable
14447 + * @i: integer value to add
14448 + * @v: pointer to type atomic64_unchecked_t
14449 + *
14450 + * Atomically adds @i to @v.
14451 + */
14452 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14453 +{
14454 asm volatile(LOCK_PREFIX "addq %1,%0"
14455 : "=m" (v->counter)
14456 : "er" (i), "m" (v->counter));
14457 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14458 */
14459 static inline void atomic64_sub(long i, atomic64_t *v)
14460 {
14461 - asm volatile(LOCK_PREFIX "subq %1,%0"
14462 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14463 +
14464 +#ifdef CONFIG_PAX_REFCOUNT
14465 + "jno 0f\n"
14466 + LOCK_PREFIX "addq %1,%0\n"
14467 + "int $4\n0:\n"
14468 + _ASM_EXTABLE(0b, 0b)
14469 +#endif
14470 +
14471 + : "=m" (v->counter)
14472 + : "er" (i), "m" (v->counter));
14473 +}
14474 +
14475 +/**
14476 + * atomic64_sub_unchecked - subtract the atomic64 variable
14477 + * @i: integer value to subtract
14478 + * @v: pointer to type atomic64_unchecked_t
14479 + *
14480 + * Atomically subtracts @i from @v.
14481 + */
14482 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14483 +{
14484 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14485 : "=m" (v->counter)
14486 : "er" (i), "m" (v->counter));
14487 }
14488 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14489 {
14490 unsigned char c;
14491
14492 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14493 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14494 +
14495 +#ifdef CONFIG_PAX_REFCOUNT
14496 + "jno 0f\n"
14497 + LOCK_PREFIX "addq %2,%0\n"
14498 + "int $4\n0:\n"
14499 + _ASM_EXTABLE(0b, 0b)
14500 +#endif
14501 +
14502 + "sete %1\n"
14503 : "=m" (v->counter), "=qm" (c)
14504 : "er" (i), "m" (v->counter) : "memory");
14505 return c;
14506 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14507 */
14508 static inline void atomic64_inc(atomic64_t *v)
14509 {
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 + : "=m" (v->counter)
14520 + : "m" (v->counter));
14521 +}
14522 +
14523 +/**
14524 + * atomic64_inc_unchecked - increment atomic64 variable
14525 + * @v: pointer to type atomic64_unchecked_t
14526 + *
14527 + * Atomically increments @v by 1.
14528 + */
14529 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14530 +{
14531 asm volatile(LOCK_PREFIX "incq %0"
14532 : "=m" (v->counter)
14533 : "m" (v->counter));
14534 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14535 */
14536 static inline void atomic64_dec(atomic64_t *v)
14537 {
14538 - asm volatile(LOCK_PREFIX "decq %0"
14539 + asm volatile(LOCK_PREFIX "decq %0\n"
14540 +
14541 +#ifdef CONFIG_PAX_REFCOUNT
14542 + "jno 0f\n"
14543 + LOCK_PREFIX "incq %0\n"
14544 + "int $4\n0:\n"
14545 + _ASM_EXTABLE(0b, 0b)
14546 +#endif
14547 +
14548 + : "=m" (v->counter)
14549 + : "m" (v->counter));
14550 +}
14551 +
14552 +/**
14553 + * atomic64_dec_unchecked - decrement atomic64 variable
14554 + * @v: pointer to type atomic64_t
14555 + *
14556 + * Atomically decrements @v by 1.
14557 + */
14558 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14559 +{
14560 + asm volatile(LOCK_PREFIX "decq %0\n"
14561 : "=m" (v->counter)
14562 : "m" (v->counter));
14563 }
14564 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14565 {
14566 unsigned char c;
14567
14568 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14569 + asm volatile(LOCK_PREFIX "decq %0\n"
14570 +
14571 +#ifdef CONFIG_PAX_REFCOUNT
14572 + "jno 0f\n"
14573 + LOCK_PREFIX "incq %0\n"
14574 + "int $4\n0:\n"
14575 + _ASM_EXTABLE(0b, 0b)
14576 +#endif
14577 +
14578 + "sete %1\n"
14579 : "=m" (v->counter), "=qm" (c)
14580 : "m" (v->counter) : "memory");
14581 return c != 0;
14582 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14583 {
14584 unsigned char c;
14585
14586 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14587 + asm volatile(LOCK_PREFIX "incq %0\n"
14588 +
14589 +#ifdef CONFIG_PAX_REFCOUNT
14590 + "jno 0f\n"
14591 + LOCK_PREFIX "decq %0\n"
14592 + "int $4\n0:\n"
14593 + _ASM_EXTABLE(0b, 0b)
14594 +#endif
14595 +
14596 + "sete %1\n"
14597 : "=m" (v->counter), "=qm" (c)
14598 : "m" (v->counter) : "memory");
14599 return c != 0;
14600 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14601 {
14602 unsigned char c;
14603
14604 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14605 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14606 +
14607 +#ifdef CONFIG_PAX_REFCOUNT
14608 + "jno 0f\n"
14609 + LOCK_PREFIX "subq %2,%0\n"
14610 + "int $4\n0:\n"
14611 + _ASM_EXTABLE(0b, 0b)
14612 +#endif
14613 +
14614 + "sets %1\n"
14615 : "=m" (v->counter), "=qm" (c)
14616 : "er" (i), "m" (v->counter) : "memory");
14617 return c;
14618 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14619 */
14620 static inline long atomic64_add_return(long i, atomic64_t *v)
14621 {
14622 + return i + xadd_check_overflow(&v->counter, i);
14623 +}
14624 +
14625 +/**
14626 + * atomic64_add_return_unchecked - add and return
14627 + * @i: integer value to add
14628 + * @v: pointer to type atomic64_unchecked_t
14629 + *
14630 + * Atomically adds @i to @v and returns @i + @v
14631 + */
14632 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14633 +{
14634 return i + xadd(&v->counter, i);
14635 }
14636
14637 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14638 }
14639
14640 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14641 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14642 +{
14643 + return atomic64_add_return_unchecked(1, v);
14644 +}
14645 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14646
14647 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14648 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14649 return cmpxchg(&v->counter, old, new);
14650 }
14651
14652 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14653 +{
14654 + return cmpxchg(&v->counter, old, new);
14655 +}
14656 +
14657 static inline long atomic64_xchg(atomic64_t *v, long new)
14658 {
14659 return xchg(&v->counter, new);
14660 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14661 */
14662 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14663 {
14664 - long c, old;
14665 + long c, old, new;
14666 c = atomic64_read(v);
14667 for (;;) {
14668 - if (unlikely(c == (u)))
14669 + if (unlikely(c == u))
14670 break;
14671 - old = atomic64_cmpxchg((v), c, c + (a));
14672 +
14673 + asm volatile("add %2,%0\n"
14674 +
14675 +#ifdef CONFIG_PAX_REFCOUNT
14676 + "jno 0f\n"
14677 + "sub %2,%0\n"
14678 + "int $4\n0:\n"
14679 + _ASM_EXTABLE(0b, 0b)
14680 +#endif
14681 +
14682 + : "=r" (new)
14683 + : "0" (c), "ir" (a));
14684 +
14685 + old = atomic64_cmpxchg(v, c, new);
14686 if (likely(old == c))
14687 break;
14688 c = old;
14689 }
14690 - return c != (u);
14691 + return c != u;
14692 }
14693
14694 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14695 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14696 index 41639ce..0bd8c87 100644
14697 --- a/arch/x86/include/asm/bitops.h
14698 +++ b/arch/x86/include/asm/bitops.h
14699 @@ -48,7 +48,7 @@
14700 * a mask operation on a byte.
14701 */
14702 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14703 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14704 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14705 #define CONST_MASK(nr) (1 << ((nr) & 7))
14706
14707 /**
14708 @@ -361,7 +361,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
14709 *
14710 * Undefined if no bit exists, so code should check against 0 first.
14711 */
14712 -static inline unsigned long __ffs(unsigned long word)
14713 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
14714 {
14715 asm("rep; bsf %1,%0"
14716 : "=r" (word)
14717 @@ -375,7 +375,7 @@ static inline unsigned long __ffs(unsigned long word)
14718 *
14719 * Undefined if no zero exists, so code should check against ~0UL first.
14720 */
14721 -static inline unsigned long ffz(unsigned long word)
14722 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
14723 {
14724 asm("rep; bsf %1,%0"
14725 : "=r" (word)
14726 @@ -494,7 +494,7 @@ static inline int fls(int x)
14727 * at position 64.
14728 */
14729 #ifdef CONFIG_X86_64
14730 -static __always_inline int fls64(__u64 x)
14731 +static __always_inline long fls64(__u64 x)
14732 {
14733 int bitpos = -1;
14734 /*
14735 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14736 index 4fa687a..60f2d39 100644
14737 --- a/arch/x86/include/asm/boot.h
14738 +++ b/arch/x86/include/asm/boot.h
14739 @@ -6,10 +6,15 @@
14740 #include <uapi/asm/boot.h>
14741
14742 /* Physical address where kernel should be loaded. */
14743 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14744 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14745 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14746 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14747
14748 +#ifndef __ASSEMBLY__
14749 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14750 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14751 +#endif
14752 +
14753 /* Minimum kernel alignment, as a power of two */
14754 #ifdef CONFIG_X86_64
14755 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14756 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14757 index 48f99f1..d78ebf9 100644
14758 --- a/arch/x86/include/asm/cache.h
14759 +++ b/arch/x86/include/asm/cache.h
14760 @@ -5,12 +5,13 @@
14761
14762 /* L1 cache line size */
14763 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14764 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14765 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14766
14767 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14768 +#define __read_only __attribute__((__section__(".data..read_only")))
14769
14770 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14771 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14772 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14773
14774 #ifdef CONFIG_X86_VSMP
14775 #ifdef CONFIG_SMP
14776 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14777 index 9863ee3..4a1f8e1 100644
14778 --- a/arch/x86/include/asm/cacheflush.h
14779 +++ b/arch/x86/include/asm/cacheflush.h
14780 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14781 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14782
14783 if (pg_flags == _PGMT_DEFAULT)
14784 - return -1;
14785 + return ~0UL;
14786 else if (pg_flags == _PGMT_WC)
14787 return _PAGE_CACHE_WC;
14788 else if (pg_flags == _PGMT_UC_MINUS)
14789 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14790 index f50de69..2b0a458 100644
14791 --- a/arch/x86/include/asm/checksum_32.h
14792 +++ b/arch/x86/include/asm/checksum_32.h
14793 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14794 int len, __wsum sum,
14795 int *src_err_ptr, int *dst_err_ptr);
14796
14797 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14798 + int len, __wsum sum,
14799 + int *src_err_ptr, int *dst_err_ptr);
14800 +
14801 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14802 + int len, __wsum sum,
14803 + int *src_err_ptr, int *dst_err_ptr);
14804 +
14805 /*
14806 * Note: when you get a NULL pointer exception here this means someone
14807 * passed in an incorrect kernel address to one of these functions.
14808 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14809
14810 might_sleep();
14811 stac();
14812 - ret = csum_partial_copy_generic((__force void *)src, dst,
14813 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14814 len, sum, err_ptr, NULL);
14815 clac();
14816
14817 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14818 might_sleep();
14819 if (access_ok(VERIFY_WRITE, dst, len)) {
14820 stac();
14821 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14822 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14823 len, sum, NULL, err_ptr);
14824 clac();
14825 return ret;
14826 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14827 index d47786a..ce1b05d 100644
14828 --- a/arch/x86/include/asm/cmpxchg.h
14829 +++ b/arch/x86/include/asm/cmpxchg.h
14830 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14831 __compiletime_error("Bad argument size for cmpxchg");
14832 extern void __xadd_wrong_size(void)
14833 __compiletime_error("Bad argument size for xadd");
14834 +extern void __xadd_check_overflow_wrong_size(void)
14835 + __compiletime_error("Bad argument size for xadd_check_overflow");
14836 extern void __add_wrong_size(void)
14837 __compiletime_error("Bad argument size for add");
14838 +extern void __add_check_overflow_wrong_size(void)
14839 + __compiletime_error("Bad argument size for add_check_overflow");
14840
14841 /*
14842 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14843 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14844 __ret; \
14845 })
14846
14847 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14848 + ({ \
14849 + __typeof__ (*(ptr)) __ret = (arg); \
14850 + switch (sizeof(*(ptr))) { \
14851 + case __X86_CASE_L: \
14852 + asm volatile (lock #op "l %0, %1\n" \
14853 + "jno 0f\n" \
14854 + "mov %0,%1\n" \
14855 + "int $4\n0:\n" \
14856 + _ASM_EXTABLE(0b, 0b) \
14857 + : "+r" (__ret), "+m" (*(ptr)) \
14858 + : : "memory", "cc"); \
14859 + break; \
14860 + case __X86_CASE_Q: \
14861 + asm volatile (lock #op "q %q0, %1\n" \
14862 + "jno 0f\n" \
14863 + "mov %0,%1\n" \
14864 + "int $4\n0:\n" \
14865 + _ASM_EXTABLE(0b, 0b) \
14866 + : "+r" (__ret), "+m" (*(ptr)) \
14867 + : : "memory", "cc"); \
14868 + break; \
14869 + default: \
14870 + __ ## op ## _check_overflow_wrong_size(); \
14871 + } \
14872 + __ret; \
14873 + })
14874 +
14875 /*
14876 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14877 * Since this is generally used to protect other memory information, we
14878 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14879 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14880 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14881
14882 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14883 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14884 +
14885 #define __add(ptr, inc, lock) \
14886 ({ \
14887 __typeof__ (*(ptr)) __ret = (inc); \
14888 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14889 index 59c6c40..5e0b22c 100644
14890 --- a/arch/x86/include/asm/compat.h
14891 +++ b/arch/x86/include/asm/compat.h
14892 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14893 typedef u32 compat_uint_t;
14894 typedef u32 compat_ulong_t;
14895 typedef u64 __attribute__((aligned(4))) compat_u64;
14896 -typedef u32 compat_uptr_t;
14897 +typedef u32 __user compat_uptr_t;
14898
14899 struct compat_timespec {
14900 compat_time_t tv_sec;
14901 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14902 index 89270b4..f0abf8e 100644
14903 --- a/arch/x86/include/asm/cpufeature.h
14904 +++ b/arch/x86/include/asm/cpufeature.h
14905 @@ -203,7 +203,7 @@
14906 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14907 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14908 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14909 -
14910 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14911
14912 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14913 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14914 @@ -211,7 +211,7 @@
14915 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14916 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14917 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14918 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14919 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14920 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14921 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14922 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14923 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14924 #undef cpu_has_centaur_mcr
14925 #define cpu_has_centaur_mcr 0
14926
14927 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14928 #endif /* CONFIG_X86_64 */
14929
14930 #if __GNUC__ >= 4
14931 @@ -405,7 +406,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14932
14933 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14934 t_warn:
14935 - warn_pre_alternatives();
14936 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14937 + warn_pre_alternatives();
14938 return false;
14939 #endif
14940
14941 @@ -425,7 +427,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14942 ".section .discard,\"aw\",@progbits\n"
14943 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14944 ".previous\n"
14945 - ".section .altinstr_replacement,\"ax\"\n"
14946 + ".section .altinstr_replacement,\"a\"\n"
14947 "3: movb $1,%0\n"
14948 "4:\n"
14949 ".previous\n"
14950 @@ -462,7 +464,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14951 " .byte 2b - 1b\n" /* src len */
14952 " .byte 4f - 3f\n" /* repl len */
14953 ".previous\n"
14954 - ".section .altinstr_replacement,\"ax\"\n"
14955 + ".section .altinstr_replacement,\"a\"\n"
14956 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14957 "4:\n"
14958 ".previous\n"
14959 @@ -495,7 +497,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14960 ".section .discard,\"aw\",@progbits\n"
14961 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14962 ".previous\n"
14963 - ".section .altinstr_replacement,\"ax\"\n"
14964 + ".section .altinstr_replacement,\"a\"\n"
14965 "3: movb $0,%0\n"
14966 "4:\n"
14967 ".previous\n"
14968 @@ -509,7 +511,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14969 ".section .discard,\"aw\",@progbits\n"
14970 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14971 ".previous\n"
14972 - ".section .altinstr_replacement,\"ax\"\n"
14973 + ".section .altinstr_replacement,\"a\"\n"
14974 "5: movb $1,%0\n"
14975 "6:\n"
14976 ".previous\n"
14977 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14978 index b90e5df..b462c91 100644
14979 --- a/arch/x86/include/asm/desc.h
14980 +++ b/arch/x86/include/asm/desc.h
14981 @@ -4,6 +4,7 @@
14982 #include <asm/desc_defs.h>
14983 #include <asm/ldt.h>
14984 #include <asm/mmu.h>
14985 +#include <asm/pgtable.h>
14986
14987 #include <linux/smp.h>
14988 #include <linux/percpu.h>
14989 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14990
14991 desc->type = (info->read_exec_only ^ 1) << 1;
14992 desc->type |= info->contents << 2;
14993 + desc->type |= info->seg_not_present ^ 1;
14994
14995 desc->s = 1;
14996 desc->dpl = 0x3;
14997 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14998 }
14999
15000 extern struct desc_ptr idt_descr;
15001 -extern gate_desc idt_table[];
15002 -extern struct desc_ptr debug_idt_descr;
15003 -extern gate_desc debug_idt_table[];
15004 -
15005 -struct gdt_page {
15006 - struct desc_struct gdt[GDT_ENTRIES];
15007 -} __attribute__((aligned(PAGE_SIZE)));
15008 -
15009 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15010 +extern gate_desc idt_table[IDT_ENTRIES];
15011 +extern const struct desc_ptr debug_idt_descr;
15012 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15013
15014 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15015 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15016 {
15017 - return per_cpu(gdt_page, cpu).gdt;
15018 + return cpu_gdt_table[cpu];
15019 }
15020
15021 #ifdef CONFIG_X86_64
15022 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15023 unsigned long base, unsigned dpl, unsigned flags,
15024 unsigned short seg)
15025 {
15026 - gate->a = (seg << 16) | (base & 0xffff);
15027 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15028 + gate->gate.offset_low = base;
15029 + gate->gate.seg = seg;
15030 + gate->gate.reserved = 0;
15031 + gate->gate.type = type;
15032 + gate->gate.s = 0;
15033 + gate->gate.dpl = dpl;
15034 + gate->gate.p = 1;
15035 + gate->gate.offset_high = base >> 16;
15036 }
15037
15038 #endif
15039 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15040
15041 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15042 {
15043 + pax_open_kernel();
15044 memcpy(&idt[entry], gate, sizeof(*gate));
15045 + pax_close_kernel();
15046 }
15047
15048 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15049 {
15050 + pax_open_kernel();
15051 memcpy(&ldt[entry], desc, 8);
15052 + pax_close_kernel();
15053 }
15054
15055 static inline void
15056 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15057 default: size = sizeof(*gdt); break;
15058 }
15059
15060 + pax_open_kernel();
15061 memcpy(&gdt[entry], desc, size);
15062 + pax_close_kernel();
15063 }
15064
15065 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15066 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15067
15068 static inline void native_load_tr_desc(void)
15069 {
15070 + pax_open_kernel();
15071 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15072 + pax_close_kernel();
15073 }
15074
15075 static inline void native_load_gdt(const struct desc_ptr *dtr)
15076 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15077 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15078 unsigned int i;
15079
15080 + pax_open_kernel();
15081 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15082 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15083 + pax_close_kernel();
15084 }
15085
15086 #define _LDT_empty(info) \
15087 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15088 preempt_enable();
15089 }
15090
15091 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15092 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15093 {
15094 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15095 }
15096 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15097 }
15098
15099 #ifdef CONFIG_X86_64
15100 -static inline void set_nmi_gate(int gate, void *addr)
15101 +static inline void set_nmi_gate(int gate, const void *addr)
15102 {
15103 gate_desc s;
15104
15105 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15106 #endif
15107
15108 #ifdef CONFIG_TRACING
15109 -extern struct desc_ptr trace_idt_descr;
15110 -extern gate_desc trace_idt_table[];
15111 +extern const struct desc_ptr trace_idt_descr;
15112 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15113 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15114 {
15115 write_idt_entry(trace_idt_table, entry, gate);
15116 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15117 }
15118 #endif
15119
15120 -static inline void _set_gate(int gate, unsigned type, void *addr,
15121 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15122 unsigned dpl, unsigned ist, unsigned seg)
15123 {
15124 gate_desc s;
15125 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15126 * Pentium F0 0F bugfix can have resulted in the mapped
15127 * IDT being write-protected.
15128 */
15129 -static inline void set_intr_gate(unsigned int n, void *addr)
15130 +static inline void set_intr_gate(unsigned int n, const void *addr)
15131 {
15132 BUG_ON((unsigned)n > 0xFF);
15133 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15134 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15135 /*
15136 * This routine sets up an interrupt gate at directory privilege level 3.
15137 */
15138 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15139 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15140 {
15141 BUG_ON((unsigned)n > 0xFF);
15142 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15143 }
15144
15145 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15146 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15147 {
15148 BUG_ON((unsigned)n > 0xFF);
15149 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15150 }
15151
15152 -static inline void set_trap_gate(unsigned int n, void *addr)
15153 +static inline void set_trap_gate(unsigned int n, const void *addr)
15154 {
15155 BUG_ON((unsigned)n > 0xFF);
15156 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15157 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15158 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15159 {
15160 BUG_ON((unsigned)n > 0xFF);
15161 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15162 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15163 }
15164
15165 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15166 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15167 {
15168 BUG_ON((unsigned)n > 0xFF);
15169 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15170 }
15171
15172 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15173 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15174 {
15175 BUG_ON((unsigned)n > 0xFF);
15176 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15177 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15178 else
15179 load_idt((const struct desc_ptr *)&idt_descr);
15180 }
15181 +
15182 +#ifdef CONFIG_X86_32
15183 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15184 +{
15185 + struct desc_struct d;
15186 +
15187 + if (likely(limit))
15188 + limit = (limit - 1UL) >> PAGE_SHIFT;
15189 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15190 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15191 +}
15192 +#endif
15193 +
15194 #endif /* _ASM_X86_DESC_H */
15195 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15196 index 278441f..b95a174 100644
15197 --- a/arch/x86/include/asm/desc_defs.h
15198 +++ b/arch/x86/include/asm/desc_defs.h
15199 @@ -31,6 +31,12 @@ struct desc_struct {
15200 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15201 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15202 };
15203 + struct {
15204 + u16 offset_low;
15205 + u16 seg;
15206 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15207 + unsigned offset_high: 16;
15208 + } gate;
15209 };
15210 } __attribute__((packed));
15211
15212 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15213 index ced283a..ffe04cc 100644
15214 --- a/arch/x86/include/asm/div64.h
15215 +++ b/arch/x86/include/asm/div64.h
15216 @@ -39,7 +39,7 @@
15217 __mod; \
15218 })
15219
15220 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15221 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15222 {
15223 union {
15224 u64 v64;
15225 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15226 index 9c999c1..3860cb8 100644
15227 --- a/arch/x86/include/asm/elf.h
15228 +++ b/arch/x86/include/asm/elf.h
15229 @@ -243,7 +243,25 @@ extern int force_personality32;
15230 the loader. We need to make sure that it is out of the way of the program
15231 that it will "exec", and that there is sufficient room for the brk. */
15232
15233 +#ifdef CONFIG_PAX_SEGMEXEC
15234 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15235 +#else
15236 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15237 +#endif
15238 +
15239 +#ifdef CONFIG_PAX_ASLR
15240 +#ifdef CONFIG_X86_32
15241 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15242 +
15243 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15244 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15245 +#else
15246 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15247 +
15248 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15249 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15250 +#endif
15251 +#endif
15252
15253 /* This yields a mask that user programs can use to figure out what
15254 instruction set this CPU supports. This could be done in user space,
15255 @@ -296,16 +314,12 @@ do { \
15256
15257 #define ARCH_DLINFO \
15258 do { \
15259 - if (vdso_enabled) \
15260 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15261 - (unsigned long)current->mm->context.vdso); \
15262 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15263 } while (0)
15264
15265 #define ARCH_DLINFO_X32 \
15266 do { \
15267 - if (vdso_enabled) \
15268 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15269 - (unsigned long)current->mm->context.vdso); \
15270 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15271 } while (0)
15272
15273 #define AT_SYSINFO 32
15274 @@ -320,7 +334,7 @@ else \
15275
15276 #endif /* !CONFIG_X86_32 */
15277
15278 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15279 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15280
15281 #define VDSO_ENTRY \
15282 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15283 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15284 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15285 #define compat_arch_setup_additional_pages syscall32_setup_pages
15286
15287 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15288 -#define arch_randomize_brk arch_randomize_brk
15289 -
15290 /*
15291 * True on X86_32 or when emulating IA32 on X86_64
15292 */
15293 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15294 index 77a99ac..39ff7f5 100644
15295 --- a/arch/x86/include/asm/emergency-restart.h
15296 +++ b/arch/x86/include/asm/emergency-restart.h
15297 @@ -1,6 +1,6 @@
15298 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15299 #define _ASM_X86_EMERGENCY_RESTART_H
15300
15301 -extern void machine_emergency_restart(void);
15302 +extern void machine_emergency_restart(void) __noreturn;
15303
15304 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15305 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15306 index 4d0bda7..221da4d 100644
15307 --- a/arch/x86/include/asm/fpu-internal.h
15308 +++ b/arch/x86/include/asm/fpu-internal.h
15309 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15310 #define user_insn(insn, output, input...) \
15311 ({ \
15312 int err; \
15313 + pax_open_userland(); \
15314 asm volatile(ASM_STAC "\n" \
15315 - "1:" #insn "\n\t" \
15316 + "1:" \
15317 + __copyuser_seg \
15318 + #insn "\n\t" \
15319 "2: " ASM_CLAC "\n" \
15320 ".section .fixup,\"ax\"\n" \
15321 "3: movl $-1,%[err]\n" \
15322 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15323 _ASM_EXTABLE(1b, 3b) \
15324 : [err] "=r" (err), output \
15325 : "0"(0), input); \
15326 + pax_close_userland(); \
15327 err; \
15328 })
15329
15330 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15331 "emms\n\t" /* clear stack tags */
15332 "fildl %P[addr]", /* set F?P to defined value */
15333 X86_FEATURE_FXSAVE_LEAK,
15334 - [addr] "m" (tsk->thread.fpu.has_fpu));
15335 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15336
15337 return fpu_restore_checking(&tsk->thread.fpu);
15338 }
15339 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15340 index be27ba1..04a8801 100644
15341 --- a/arch/x86/include/asm/futex.h
15342 +++ b/arch/x86/include/asm/futex.h
15343 @@ -12,6 +12,7 @@
15344 #include <asm/smap.h>
15345
15346 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15347 + typecheck(u32 __user *, uaddr); \
15348 asm volatile("\t" ASM_STAC "\n" \
15349 "1:\t" insn "\n" \
15350 "2:\t" ASM_CLAC "\n" \
15351 @@ -20,15 +21,16 @@
15352 "\tjmp\t2b\n" \
15353 "\t.previous\n" \
15354 _ASM_EXTABLE(1b, 3b) \
15355 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15356 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15357 : "i" (-EFAULT), "0" (oparg), "1" (0))
15358
15359 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15360 + typecheck(u32 __user *, uaddr); \
15361 asm volatile("\t" ASM_STAC "\n" \
15362 "1:\tmovl %2, %0\n" \
15363 "\tmovl\t%0, %3\n" \
15364 "\t" insn "\n" \
15365 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15366 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15367 "\tjnz\t1b\n" \
15368 "3:\t" ASM_CLAC "\n" \
15369 "\t.section .fixup,\"ax\"\n" \
15370 @@ -38,7 +40,7 @@
15371 _ASM_EXTABLE(1b, 4b) \
15372 _ASM_EXTABLE(2b, 4b) \
15373 : "=&a" (oldval), "=&r" (ret), \
15374 - "+m" (*uaddr), "=&r" (tem) \
15375 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15376 : "r" (oparg), "i" (-EFAULT), "1" (0))
15377
15378 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15379 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15380
15381 pagefault_disable();
15382
15383 + pax_open_userland();
15384 switch (op) {
15385 case FUTEX_OP_SET:
15386 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15387 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15388 break;
15389 case FUTEX_OP_ADD:
15390 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15391 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15392 uaddr, oparg);
15393 break;
15394 case FUTEX_OP_OR:
15395 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15396 default:
15397 ret = -ENOSYS;
15398 }
15399 + pax_close_userland();
15400
15401 pagefault_enable();
15402
15403 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15404 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15405 return -EFAULT;
15406
15407 + pax_open_userland();
15408 asm volatile("\t" ASM_STAC "\n"
15409 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15410 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15411 "2:\t" ASM_CLAC "\n"
15412 "\t.section .fixup, \"ax\"\n"
15413 "3:\tmov %3, %0\n"
15414 "\tjmp 2b\n"
15415 "\t.previous\n"
15416 _ASM_EXTABLE(1b, 3b)
15417 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15418 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15419 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15420 : "memory"
15421 );
15422 + pax_close_userland();
15423
15424 *uval = oldval;
15425 return ret;
15426 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15427 index 92b3bae..3866449 100644
15428 --- a/arch/x86/include/asm/hw_irq.h
15429 +++ b/arch/x86/include/asm/hw_irq.h
15430 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15431 extern void enable_IO_APIC(void);
15432
15433 /* Statistics */
15434 -extern atomic_t irq_err_count;
15435 -extern atomic_t irq_mis_count;
15436 +extern atomic_unchecked_t irq_err_count;
15437 +extern atomic_unchecked_t irq_mis_count;
15438
15439 /* EISA */
15440 extern void eisa_set_level_irq(unsigned int irq);
15441 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15442 index a203659..9889f1c 100644
15443 --- a/arch/x86/include/asm/i8259.h
15444 +++ b/arch/x86/include/asm/i8259.h
15445 @@ -62,7 +62,7 @@ struct legacy_pic {
15446 void (*init)(int auto_eoi);
15447 int (*irq_pending)(unsigned int irq);
15448 void (*make_irq)(unsigned int irq);
15449 -};
15450 +} __do_const;
15451
15452 extern struct legacy_pic *legacy_pic;
15453 extern struct legacy_pic null_legacy_pic;
15454 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15455 index 34f69cb..6d95446 100644
15456 --- a/arch/x86/include/asm/io.h
15457 +++ b/arch/x86/include/asm/io.h
15458 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15459 "m" (*(volatile type __force *)addr) barrier); }
15460
15461 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15462 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15463 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15464 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15465 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15466
15467 build_mmio_read(__readb, "b", unsigned char, "=q", )
15468 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15469 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15470 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15471 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15472
15473 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15474 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15475 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15476 return ioremap_nocache(offset, size);
15477 }
15478
15479 -extern void iounmap(volatile void __iomem *addr);
15480 +extern void iounmap(const volatile void __iomem *addr);
15481
15482 extern void set_iounmap_nonlazy(void);
15483
15484 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15485
15486 #include <linux/vmalloc.h>
15487
15488 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15489 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15490 +{
15491 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15492 +}
15493 +
15494 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15495 +{
15496 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15497 +}
15498 +
15499 /*
15500 * Convert a virtual cached pointer to an uncached pointer
15501 */
15502 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15503 index bba3cf8..06bc8da 100644
15504 --- a/arch/x86/include/asm/irqflags.h
15505 +++ b/arch/x86/include/asm/irqflags.h
15506 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15507 sti; \
15508 sysexit
15509
15510 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15511 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15512 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15513 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15514 +
15515 #else
15516 #define INTERRUPT_RETURN iret
15517 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15518 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15519 index 9454c16..e4100e3 100644
15520 --- a/arch/x86/include/asm/kprobes.h
15521 +++ b/arch/x86/include/asm/kprobes.h
15522 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15523 #define RELATIVEJUMP_SIZE 5
15524 #define RELATIVECALL_OPCODE 0xe8
15525 #define RELATIVE_ADDR_SIZE 4
15526 -#define MAX_STACK_SIZE 64
15527 -#define MIN_STACK_SIZE(ADDR) \
15528 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15529 - THREAD_SIZE - (unsigned long)(ADDR))) \
15530 - ? (MAX_STACK_SIZE) \
15531 - : (((unsigned long)current_thread_info()) + \
15532 - THREAD_SIZE - (unsigned long)(ADDR)))
15533 +#define MAX_STACK_SIZE 64UL
15534 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15535
15536 #define flush_insn_slot(p) do { } while (0)
15537
15538 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15539 index 2d89e39..baee879 100644
15540 --- a/arch/x86/include/asm/local.h
15541 +++ b/arch/x86/include/asm/local.h
15542 @@ -10,33 +10,97 @@ typedef struct {
15543 atomic_long_t a;
15544 } local_t;
15545
15546 +typedef struct {
15547 + atomic_long_unchecked_t a;
15548 +} local_unchecked_t;
15549 +
15550 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15551
15552 #define local_read(l) atomic_long_read(&(l)->a)
15553 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15554 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15555 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15556
15557 static inline void local_inc(local_t *l)
15558 {
15559 - asm volatile(_ASM_INC "%0"
15560 + asm volatile(_ASM_INC "%0\n"
15561 +
15562 +#ifdef CONFIG_PAX_REFCOUNT
15563 + "jno 0f\n"
15564 + _ASM_DEC "%0\n"
15565 + "int $4\n0:\n"
15566 + _ASM_EXTABLE(0b, 0b)
15567 +#endif
15568 +
15569 + : "+m" (l->a.counter));
15570 +}
15571 +
15572 +static inline void local_inc_unchecked(local_unchecked_t *l)
15573 +{
15574 + asm volatile(_ASM_INC "%0\n"
15575 : "+m" (l->a.counter));
15576 }
15577
15578 static inline void local_dec(local_t *l)
15579 {
15580 - asm volatile(_ASM_DEC "%0"
15581 + asm volatile(_ASM_DEC "%0\n"
15582 +
15583 +#ifdef CONFIG_PAX_REFCOUNT
15584 + "jno 0f\n"
15585 + _ASM_INC "%0\n"
15586 + "int $4\n0:\n"
15587 + _ASM_EXTABLE(0b, 0b)
15588 +#endif
15589 +
15590 + : "+m" (l->a.counter));
15591 +}
15592 +
15593 +static inline void local_dec_unchecked(local_unchecked_t *l)
15594 +{
15595 + asm volatile(_ASM_DEC "%0\n"
15596 : "+m" (l->a.counter));
15597 }
15598
15599 static inline void local_add(long i, local_t *l)
15600 {
15601 - asm volatile(_ASM_ADD "%1,%0"
15602 + asm volatile(_ASM_ADD "%1,%0\n"
15603 +
15604 +#ifdef CONFIG_PAX_REFCOUNT
15605 + "jno 0f\n"
15606 + _ASM_SUB "%1,%0\n"
15607 + "int $4\n0:\n"
15608 + _ASM_EXTABLE(0b, 0b)
15609 +#endif
15610 +
15611 + : "+m" (l->a.counter)
15612 + : "ir" (i));
15613 +}
15614 +
15615 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15616 +{
15617 + asm volatile(_ASM_ADD "%1,%0\n"
15618 : "+m" (l->a.counter)
15619 : "ir" (i));
15620 }
15621
15622 static inline void local_sub(long i, local_t *l)
15623 {
15624 - asm volatile(_ASM_SUB "%1,%0"
15625 + asm volatile(_ASM_SUB "%1,%0\n"
15626 +
15627 +#ifdef CONFIG_PAX_REFCOUNT
15628 + "jno 0f\n"
15629 + _ASM_ADD "%1,%0\n"
15630 + "int $4\n0:\n"
15631 + _ASM_EXTABLE(0b, 0b)
15632 +#endif
15633 +
15634 + : "+m" (l->a.counter)
15635 + : "ir" (i));
15636 +}
15637 +
15638 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15639 +{
15640 + asm volatile(_ASM_SUB "%1,%0\n"
15641 : "+m" (l->a.counter)
15642 : "ir" (i));
15643 }
15644 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15645 {
15646 unsigned char c;
15647
15648 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15649 + asm volatile(_ASM_SUB "%2,%0\n"
15650 +
15651 +#ifdef CONFIG_PAX_REFCOUNT
15652 + "jno 0f\n"
15653 + _ASM_ADD "%2,%0\n"
15654 + "int $4\n0:\n"
15655 + _ASM_EXTABLE(0b, 0b)
15656 +#endif
15657 +
15658 + "sete %1\n"
15659 : "+m" (l->a.counter), "=qm" (c)
15660 : "ir" (i) : "memory");
15661 return c;
15662 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15663 {
15664 unsigned char c;
15665
15666 - asm volatile(_ASM_DEC "%0; sete %1"
15667 + asm volatile(_ASM_DEC "%0\n"
15668 +
15669 +#ifdef CONFIG_PAX_REFCOUNT
15670 + "jno 0f\n"
15671 + _ASM_INC "%0\n"
15672 + "int $4\n0:\n"
15673 + _ASM_EXTABLE(0b, 0b)
15674 +#endif
15675 +
15676 + "sete %1\n"
15677 : "+m" (l->a.counter), "=qm" (c)
15678 : : "memory");
15679 return c != 0;
15680 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15681 {
15682 unsigned char c;
15683
15684 - asm volatile(_ASM_INC "%0; sete %1"
15685 + asm volatile(_ASM_INC "%0\n"
15686 +
15687 +#ifdef CONFIG_PAX_REFCOUNT
15688 + "jno 0f\n"
15689 + _ASM_DEC "%0\n"
15690 + "int $4\n0:\n"
15691 + _ASM_EXTABLE(0b, 0b)
15692 +#endif
15693 +
15694 + "sete %1\n"
15695 : "+m" (l->a.counter), "=qm" (c)
15696 : : "memory");
15697 return c != 0;
15698 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15699 {
15700 unsigned char c;
15701
15702 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15703 + asm volatile(_ASM_ADD "%2,%0\n"
15704 +
15705 +#ifdef CONFIG_PAX_REFCOUNT
15706 + "jno 0f\n"
15707 + _ASM_SUB "%2,%0\n"
15708 + "int $4\n0:\n"
15709 + _ASM_EXTABLE(0b, 0b)
15710 +#endif
15711 +
15712 + "sets %1\n"
15713 : "+m" (l->a.counter), "=qm" (c)
15714 : "ir" (i) : "memory");
15715 return c;
15716 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15717 static inline long local_add_return(long i, local_t *l)
15718 {
15719 long __i = i;
15720 + asm volatile(_ASM_XADD "%0, %1\n"
15721 +
15722 +#ifdef CONFIG_PAX_REFCOUNT
15723 + "jno 0f\n"
15724 + _ASM_MOV "%0,%1\n"
15725 + "int $4\n0:\n"
15726 + _ASM_EXTABLE(0b, 0b)
15727 +#endif
15728 +
15729 + : "+r" (i), "+m" (l->a.counter)
15730 + : : "memory");
15731 + return i + __i;
15732 +}
15733 +
15734 +/**
15735 + * local_add_return_unchecked - add and return
15736 + * @i: integer value to add
15737 + * @l: pointer to type local_unchecked_t
15738 + *
15739 + * Atomically adds @i to @l and returns @i + @l
15740 + */
15741 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15742 +{
15743 + long __i = i;
15744 asm volatile(_ASM_XADD "%0, %1;"
15745 : "+r" (i), "+m" (l->a.counter)
15746 : : "memory");
15747 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15748
15749 #define local_cmpxchg(l, o, n) \
15750 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15751 +#define local_cmpxchg_unchecked(l, o, n) \
15752 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15753 /* Always has a lock prefix */
15754 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15755
15756 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15757 new file mode 100644
15758 index 0000000..2bfd3ba
15759 --- /dev/null
15760 +++ b/arch/x86/include/asm/mman.h
15761 @@ -0,0 +1,15 @@
15762 +#ifndef _X86_MMAN_H
15763 +#define _X86_MMAN_H
15764 +
15765 +#include <uapi/asm/mman.h>
15766 +
15767 +#ifdef __KERNEL__
15768 +#ifndef __ASSEMBLY__
15769 +#ifdef CONFIG_X86_32
15770 +#define arch_mmap_check i386_mmap_check
15771 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15772 +#endif
15773 +#endif
15774 +#endif
15775 +
15776 +#endif /* X86_MMAN_H */
15777 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15778 index 5f55e69..e20bfb1 100644
15779 --- a/arch/x86/include/asm/mmu.h
15780 +++ b/arch/x86/include/asm/mmu.h
15781 @@ -9,7 +9,7 @@
15782 * we put the segment information here.
15783 */
15784 typedef struct {
15785 - void *ldt;
15786 + struct desc_struct *ldt;
15787 int size;
15788
15789 #ifdef CONFIG_X86_64
15790 @@ -18,7 +18,19 @@ typedef struct {
15791 #endif
15792
15793 struct mutex lock;
15794 - void *vdso;
15795 + unsigned long vdso;
15796 +
15797 +#ifdef CONFIG_X86_32
15798 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15799 + unsigned long user_cs_base;
15800 + unsigned long user_cs_limit;
15801 +
15802 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15803 + cpumask_t cpu_user_cs_mask;
15804 +#endif
15805 +
15806 +#endif
15807 +#endif
15808 } mm_context_t;
15809
15810 #ifdef CONFIG_SMP
15811 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15812 index be12c53..4d24039 100644
15813 --- a/arch/x86/include/asm/mmu_context.h
15814 +++ b/arch/x86/include/asm/mmu_context.h
15815 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15816
15817 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15818 {
15819 +
15820 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15821 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15822 + unsigned int i;
15823 + pgd_t *pgd;
15824 +
15825 + pax_open_kernel();
15826 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15827 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15828 + set_pgd_batched(pgd+i, native_make_pgd(0));
15829 + pax_close_kernel();
15830 + }
15831 +#endif
15832 +
15833 #ifdef CONFIG_SMP
15834 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15835 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15836 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15837 struct task_struct *tsk)
15838 {
15839 unsigned cpu = smp_processor_id();
15840 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15841 + int tlbstate = TLBSTATE_OK;
15842 +#endif
15843
15844 if (likely(prev != next)) {
15845 #ifdef CONFIG_SMP
15846 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15847 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15848 +#endif
15849 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15850 this_cpu_write(cpu_tlbstate.active_mm, next);
15851 #endif
15852 cpumask_set_cpu(cpu, mm_cpumask(next));
15853
15854 /* Re-load page tables */
15855 +#ifdef CONFIG_PAX_PER_CPU_PGD
15856 + pax_open_kernel();
15857 +
15858 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15859 + if (static_cpu_has(X86_FEATURE_PCID))
15860 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15861 + else
15862 +#endif
15863 +
15864 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15865 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15866 + pax_close_kernel();
15867 + 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));
15868 +
15869 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15870 + if (static_cpu_has(X86_FEATURE_PCID)) {
15871 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15872 + u64 descriptor[2];
15873 + descriptor[0] = PCID_USER;
15874 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15875 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15876 + descriptor[0] = PCID_KERNEL;
15877 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15878 + }
15879 + } else {
15880 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15881 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15882 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15883 + else
15884 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15885 + }
15886 + } else
15887 +#endif
15888 +
15889 + load_cr3(get_cpu_pgd(cpu, kernel));
15890 +#else
15891 load_cr3(next->pgd);
15892 +#endif
15893
15894 /* Stop flush ipis for the previous mm */
15895 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15896 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15897 /* Load the LDT, if the LDT is different: */
15898 if (unlikely(prev->context.ldt != next->context.ldt))
15899 load_LDT_nolock(&next->context);
15900 +
15901 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15902 + if (!(__supported_pte_mask & _PAGE_NX)) {
15903 + smp_mb__before_clear_bit();
15904 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15905 + smp_mb__after_clear_bit();
15906 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15907 + }
15908 +#endif
15909 +
15910 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15911 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15912 + prev->context.user_cs_limit != next->context.user_cs_limit))
15913 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15914 +#ifdef CONFIG_SMP
15915 + else if (unlikely(tlbstate != TLBSTATE_OK))
15916 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15917 +#endif
15918 +#endif
15919 +
15920 }
15921 + else {
15922 +
15923 +#ifdef CONFIG_PAX_PER_CPU_PGD
15924 + pax_open_kernel();
15925 +
15926 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15927 + if (static_cpu_has(X86_FEATURE_PCID))
15928 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15929 + else
15930 +#endif
15931 +
15932 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15933 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15934 + pax_close_kernel();
15935 + 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));
15936 +
15937 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15938 + if (static_cpu_has(X86_FEATURE_PCID)) {
15939 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15940 + u64 descriptor[2];
15941 + descriptor[0] = PCID_USER;
15942 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15943 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15944 + descriptor[0] = PCID_KERNEL;
15945 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15946 + }
15947 + } else {
15948 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15949 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15950 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15951 + else
15952 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15953 + }
15954 + } else
15955 +#endif
15956 +
15957 + load_cr3(get_cpu_pgd(cpu, kernel));
15958 +#endif
15959 +
15960 #ifdef CONFIG_SMP
15961 - else {
15962 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15963 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15964
15965 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15966 * tlb flush IPI delivery. We must reload CR3
15967 * to make sure to use no freed page tables.
15968 */
15969 +
15970 +#ifndef CONFIG_PAX_PER_CPU_PGD
15971 load_cr3(next->pgd);
15972 +#endif
15973 +
15974 load_LDT_nolock(&next->context);
15975 +
15976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15977 + if (!(__supported_pte_mask & _PAGE_NX))
15978 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15979 +#endif
15980 +
15981 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15982 +#ifdef CONFIG_PAX_PAGEEXEC
15983 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15984 +#endif
15985 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15986 +#endif
15987 +
15988 }
15989 +#endif
15990 }
15991 -#endif
15992 }
15993
15994 #define activate_mm(prev, next) \
15995 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15996 index e3b7819..b257c64 100644
15997 --- a/arch/x86/include/asm/module.h
15998 +++ b/arch/x86/include/asm/module.h
15999 @@ -5,6 +5,7 @@
16000
16001 #ifdef CONFIG_X86_64
16002 /* X86_64 does not define MODULE_PROC_FAMILY */
16003 +#define MODULE_PROC_FAMILY ""
16004 #elif defined CONFIG_M486
16005 #define MODULE_PROC_FAMILY "486 "
16006 #elif defined CONFIG_M586
16007 @@ -57,8 +58,20 @@
16008 #error unknown processor family
16009 #endif
16010
16011 -#ifdef CONFIG_X86_32
16012 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16013 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16014 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16015 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16016 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16017 +#else
16018 +#define MODULE_PAX_KERNEXEC ""
16019 #endif
16020
16021 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16022 +#define MODULE_PAX_UDEREF "UDEREF "
16023 +#else
16024 +#define MODULE_PAX_UDEREF ""
16025 +#endif
16026 +
16027 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16028 +
16029 #endif /* _ASM_X86_MODULE_H */
16030 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16031 index 86f9301..b365cda 100644
16032 --- a/arch/x86/include/asm/nmi.h
16033 +++ b/arch/x86/include/asm/nmi.h
16034 @@ -40,11 +40,11 @@ struct nmiaction {
16035 nmi_handler_t handler;
16036 unsigned long flags;
16037 const char *name;
16038 -};
16039 +} __do_const;
16040
16041 #define register_nmi_handler(t, fn, fg, n, init...) \
16042 ({ \
16043 - static struct nmiaction init fn##_na = { \
16044 + static const struct nmiaction init fn##_na = { \
16045 .handler = (fn), \
16046 .name = (n), \
16047 .flags = (fg), \
16048 @@ -52,7 +52,7 @@ struct nmiaction {
16049 __register_nmi_handler((t), &fn##_na); \
16050 })
16051
16052 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16053 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16054
16055 void unregister_nmi_handler(unsigned int, const char *);
16056
16057 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16058 index c878924..21f4889 100644
16059 --- a/arch/x86/include/asm/page.h
16060 +++ b/arch/x86/include/asm/page.h
16061 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16062 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16063
16064 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16065 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16066
16067 #define __boot_va(x) __va(x)
16068 #define __boot_pa(x) __pa(x)
16069 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16070 index 0f1ddee..e2fc3d1 100644
16071 --- a/arch/x86/include/asm/page_64.h
16072 +++ b/arch/x86/include/asm/page_64.h
16073 @@ -7,9 +7,9 @@
16074
16075 /* duplicated to the one in bootmem.h */
16076 extern unsigned long max_pfn;
16077 -extern unsigned long phys_base;
16078 +extern const unsigned long phys_base;
16079
16080 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16081 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16082 {
16083 unsigned long y = x - __START_KERNEL_map;
16084
16085 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16086 index 401f350..dee5d13 100644
16087 --- a/arch/x86/include/asm/paravirt.h
16088 +++ b/arch/x86/include/asm/paravirt.h
16089 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16090 return (pmd_t) { ret };
16091 }
16092
16093 -static inline pmdval_t pmd_val(pmd_t pmd)
16094 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16095 {
16096 pmdval_t ret;
16097
16098 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16099 val);
16100 }
16101
16102 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16103 +{
16104 + pgdval_t val = native_pgd_val(pgd);
16105 +
16106 + if (sizeof(pgdval_t) > sizeof(long))
16107 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16108 + val, (u64)val >> 32);
16109 + else
16110 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16111 + val);
16112 +}
16113 +
16114 static inline void pgd_clear(pgd_t *pgdp)
16115 {
16116 set_pgd(pgdp, __pgd(0));
16117 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16118 pv_mmu_ops.set_fixmap(idx, phys, flags);
16119 }
16120
16121 +#ifdef CONFIG_PAX_KERNEXEC
16122 +static inline unsigned long pax_open_kernel(void)
16123 +{
16124 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16125 +}
16126 +
16127 +static inline unsigned long pax_close_kernel(void)
16128 +{
16129 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16130 +}
16131 +#else
16132 +static inline unsigned long pax_open_kernel(void) { return 0; }
16133 +static inline unsigned long pax_close_kernel(void) { return 0; }
16134 +#endif
16135 +
16136 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16137
16138 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
16139 @@ -906,7 +933,7 @@ extern void default_banner(void);
16140
16141 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16142 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16143 -#define PARA_INDIRECT(addr) *%cs:addr
16144 +#define PARA_INDIRECT(addr) *%ss:addr
16145 #endif
16146
16147 #define INTERRUPT_RETURN \
16148 @@ -981,6 +1008,21 @@ extern void default_banner(void);
16149 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16150 CLBR_NONE, \
16151 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16152 +
16153 +#define GET_CR0_INTO_RDI \
16154 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16155 + mov %rax,%rdi
16156 +
16157 +#define SET_RDI_INTO_CR0 \
16158 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16159 +
16160 +#define GET_CR3_INTO_RDI \
16161 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16162 + mov %rax,%rdi
16163 +
16164 +#define SET_RDI_INTO_CR3 \
16165 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16166 +
16167 #endif /* CONFIG_X86_32 */
16168
16169 #endif /* __ASSEMBLY__ */
16170 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16171 index aab8f67..2531748 100644
16172 --- a/arch/x86/include/asm/paravirt_types.h
16173 +++ b/arch/x86/include/asm/paravirt_types.h
16174 @@ -84,7 +84,7 @@ struct pv_init_ops {
16175 */
16176 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16177 unsigned long addr, unsigned len);
16178 -};
16179 +} __no_const;
16180
16181
16182 struct pv_lazy_ops {
16183 @@ -98,7 +98,7 @@ struct pv_time_ops {
16184 unsigned long long (*sched_clock)(void);
16185 unsigned long long (*steal_clock)(int cpu);
16186 unsigned long (*get_tsc_khz)(void);
16187 -};
16188 +} __no_const;
16189
16190 struct pv_cpu_ops {
16191 /* hooks for various privileged instructions */
16192 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16193
16194 void (*start_context_switch)(struct task_struct *prev);
16195 void (*end_context_switch)(struct task_struct *next);
16196 -};
16197 +} __no_const;
16198
16199 struct pv_irq_ops {
16200 /*
16201 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16202 unsigned long start_eip,
16203 unsigned long start_esp);
16204 #endif
16205 -};
16206 +} __no_const;
16207
16208 struct pv_mmu_ops {
16209 unsigned long (*read_cr2)(void);
16210 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16211 struct paravirt_callee_save make_pud;
16212
16213 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16214 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16215 #endif /* PAGETABLE_LEVELS == 4 */
16216 #endif /* PAGETABLE_LEVELS >= 3 */
16217
16218 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16219 an mfn. We can tell which is which from the index. */
16220 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16221 phys_addr_t phys, pgprot_t flags);
16222 +
16223 +#ifdef CONFIG_PAX_KERNEXEC
16224 + unsigned long (*pax_open_kernel)(void);
16225 + unsigned long (*pax_close_kernel)(void);
16226 +#endif
16227 +
16228 };
16229
16230 struct arch_spinlock;
16231 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16232 index b4389a4..7024269 100644
16233 --- a/arch/x86/include/asm/pgalloc.h
16234 +++ b/arch/x86/include/asm/pgalloc.h
16235 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16236 pmd_t *pmd, pte_t *pte)
16237 {
16238 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16239 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16240 +}
16241 +
16242 +static inline void pmd_populate_user(struct mm_struct *mm,
16243 + pmd_t *pmd, pte_t *pte)
16244 +{
16245 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16246 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16247 }
16248
16249 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16250
16251 #ifdef CONFIG_X86_PAE
16252 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16253 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16254 +{
16255 + pud_populate(mm, pudp, pmd);
16256 +}
16257 #else /* !CONFIG_X86_PAE */
16258 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16259 {
16260 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16261 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16262 }
16263 +
16264 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16265 +{
16266 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16267 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16268 +}
16269 #endif /* CONFIG_X86_PAE */
16270
16271 #if PAGETABLE_LEVELS > 3
16272 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16273 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16274 }
16275
16276 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16277 +{
16278 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16279 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16280 +}
16281 +
16282 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16283 {
16284 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16285 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16286 index 3bf2dd0..23d2a9f 100644
16287 --- a/arch/x86/include/asm/pgtable-2level.h
16288 +++ b/arch/x86/include/asm/pgtable-2level.h
16289 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16290
16291 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16292 {
16293 + pax_open_kernel();
16294 *pmdp = pmd;
16295 + pax_close_kernel();
16296 }
16297
16298 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16299 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16300 index 81bb91b..9392125 100644
16301 --- a/arch/x86/include/asm/pgtable-3level.h
16302 +++ b/arch/x86/include/asm/pgtable-3level.h
16303 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16304
16305 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16306 {
16307 + pax_open_kernel();
16308 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16309 + pax_close_kernel();
16310 }
16311
16312 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16313 {
16314 + pax_open_kernel();
16315 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16316 + pax_close_kernel();
16317 }
16318
16319 /*
16320 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16321 index 3d19994..732a48c 100644
16322 --- a/arch/x86/include/asm/pgtable.h
16323 +++ b/arch/x86/include/asm/pgtable.h
16324 @@ -45,6 +45,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16325
16326 #ifndef __PAGETABLE_PUD_FOLDED
16327 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16328 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16329 #define pgd_clear(pgd) native_pgd_clear(pgd)
16330 #endif
16331
16332 @@ -82,12 +83,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16333
16334 #define arch_end_context_switch(prev) do {} while(0)
16335
16336 +#define pax_open_kernel() native_pax_open_kernel()
16337 +#define pax_close_kernel() native_pax_close_kernel()
16338 #endif /* CONFIG_PARAVIRT */
16339
16340 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16341 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16342 +
16343 +#ifdef CONFIG_PAX_KERNEXEC
16344 +static inline unsigned long native_pax_open_kernel(void)
16345 +{
16346 + unsigned long cr0;
16347 +
16348 + preempt_disable();
16349 + barrier();
16350 + cr0 = read_cr0() ^ X86_CR0_WP;
16351 + BUG_ON(cr0 & X86_CR0_WP);
16352 + write_cr0(cr0);
16353 + return cr0 ^ X86_CR0_WP;
16354 +}
16355 +
16356 +static inline unsigned long native_pax_close_kernel(void)
16357 +{
16358 + unsigned long cr0;
16359 +
16360 + cr0 = read_cr0() ^ X86_CR0_WP;
16361 + BUG_ON(!(cr0 & X86_CR0_WP));
16362 + write_cr0(cr0);
16363 + barrier();
16364 + preempt_enable_no_resched();
16365 + return cr0 ^ X86_CR0_WP;
16366 +}
16367 +#else
16368 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16369 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16370 +#endif
16371 +
16372 /*
16373 * The following only work if pte_present() is true.
16374 * Undefined behaviour if not..
16375 */
16376 +static inline int pte_user(pte_t pte)
16377 +{
16378 + return pte_val(pte) & _PAGE_USER;
16379 +}
16380 +
16381 static inline int pte_dirty(pte_t pte)
16382 {
16383 return pte_flags(pte) & _PAGE_DIRTY;
16384 @@ -148,6 +188,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16385 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16386 }
16387
16388 +static inline unsigned long pgd_pfn(pgd_t pgd)
16389 +{
16390 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16391 +}
16392 +
16393 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16394
16395 static inline int pmd_large(pmd_t pte)
16396 @@ -201,9 +246,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16397 return pte_clear_flags(pte, _PAGE_RW);
16398 }
16399
16400 +static inline pte_t pte_mkread(pte_t pte)
16401 +{
16402 + return __pte(pte_val(pte) | _PAGE_USER);
16403 +}
16404 +
16405 static inline pte_t pte_mkexec(pte_t pte)
16406 {
16407 - return pte_clear_flags(pte, _PAGE_NX);
16408 +#ifdef CONFIG_X86_PAE
16409 + if (__supported_pte_mask & _PAGE_NX)
16410 + return pte_clear_flags(pte, _PAGE_NX);
16411 + else
16412 +#endif
16413 + return pte_set_flags(pte, _PAGE_USER);
16414 +}
16415 +
16416 +static inline pte_t pte_exprotect(pte_t pte)
16417 +{
16418 +#ifdef CONFIG_X86_PAE
16419 + if (__supported_pte_mask & _PAGE_NX)
16420 + return pte_set_flags(pte, _PAGE_NX);
16421 + else
16422 +#endif
16423 + return pte_clear_flags(pte, _PAGE_USER);
16424 }
16425
16426 static inline pte_t pte_mkdirty(pte_t pte)
16427 @@ -430,6 +495,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16428 #endif
16429
16430 #ifndef __ASSEMBLY__
16431 +
16432 +#ifdef CONFIG_PAX_PER_CPU_PGD
16433 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16434 +enum cpu_pgd_type {kernel = 0, user = 1};
16435 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16436 +{
16437 + return cpu_pgd[cpu][type];
16438 +}
16439 +#endif
16440 +
16441 #include <linux/mm_types.h>
16442 #include <linux/mmdebug.h>
16443 #include <linux/log2.h>
16444 @@ -563,7 +638,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16445 * Currently stuck as a macro due to indirect forward reference to
16446 * linux/mmzone.h's __section_mem_map_addr() definition:
16447 */
16448 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16449 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16450
16451 /* Find an entry in the second-level page table.. */
16452 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16453 @@ -603,7 +678,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16454 * Currently stuck as a macro due to indirect forward reference to
16455 * linux/mmzone.h's __section_mem_map_addr() definition:
16456 */
16457 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16458 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16459
16460 /* to find an entry in a page-table-directory. */
16461 static inline unsigned long pud_index(unsigned long address)
16462 @@ -618,7 +693,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16463
16464 static inline int pgd_bad(pgd_t pgd)
16465 {
16466 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16467 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16468 }
16469
16470 static inline int pgd_none(pgd_t pgd)
16471 @@ -641,7 +716,12 @@ static inline int pgd_none(pgd_t pgd)
16472 * pgd_offset() returns a (pgd_t *)
16473 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16474 */
16475 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16476 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16477 +
16478 +#ifdef CONFIG_PAX_PER_CPU_PGD
16479 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16480 +#endif
16481 +
16482 /*
16483 * a shortcut which implies the use of the kernel's pgd, instead
16484 * of a process's
16485 @@ -652,6 +732,23 @@ static inline int pgd_none(pgd_t pgd)
16486 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16487 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16488
16489 +#ifdef CONFIG_X86_32
16490 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16491 +#else
16492 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16493 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16494 +
16495 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16496 +#ifdef __ASSEMBLY__
16497 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16498 +#else
16499 +extern unsigned long pax_user_shadow_base;
16500 +extern pgdval_t clone_pgd_mask;
16501 +#endif
16502 +#endif
16503 +
16504 +#endif
16505 +
16506 #ifndef __ASSEMBLY__
16507
16508 extern int direct_gbpages;
16509 @@ -818,11 +915,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16510 * dst and src can be on the same page, but the range must not overlap,
16511 * and must not cross a page boundary.
16512 */
16513 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16514 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16515 {
16516 - memcpy(dst, src, count * sizeof(pgd_t));
16517 + pax_open_kernel();
16518 + while (count--)
16519 + *dst++ = *src++;
16520 + pax_close_kernel();
16521 }
16522
16523 +#ifdef CONFIG_PAX_PER_CPU_PGD
16524 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16525 +#endif
16526 +
16527 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16528 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16529 +#else
16530 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16531 +#endif
16532 +
16533 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16534 static inline int page_level_shift(enum pg_level level)
16535 {
16536 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16537 index 9ee3221..b979c6b 100644
16538 --- a/arch/x86/include/asm/pgtable_32.h
16539 +++ b/arch/x86/include/asm/pgtable_32.h
16540 @@ -25,9 +25,6 @@
16541 struct mm_struct;
16542 struct vm_area_struct;
16543
16544 -extern pgd_t swapper_pg_dir[1024];
16545 -extern pgd_t initial_page_table[1024];
16546 -
16547 static inline void pgtable_cache_init(void) { }
16548 static inline void check_pgt_cache(void) { }
16549 void paging_init(void);
16550 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16551 # include <asm/pgtable-2level.h>
16552 #endif
16553
16554 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16555 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16556 +#ifdef CONFIG_X86_PAE
16557 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16558 +#endif
16559 +
16560 #if defined(CONFIG_HIGHPTE)
16561 #define pte_offset_map(dir, address) \
16562 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16563 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16564 /* Clear a kernel PTE and flush it from the TLB */
16565 #define kpte_clear_flush(ptep, vaddr) \
16566 do { \
16567 + pax_open_kernel(); \
16568 pte_clear(&init_mm, (vaddr), (ptep)); \
16569 + pax_close_kernel(); \
16570 __flush_tlb_one((vaddr)); \
16571 } while (0)
16572
16573 #endif /* !__ASSEMBLY__ */
16574
16575 +#define HAVE_ARCH_UNMAPPED_AREA
16576 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16577 +
16578 /*
16579 * kern_addr_valid() is (1) for FLATMEM and (0) for
16580 * SPARSEMEM and DISCONTIGMEM
16581 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16582 index ed5903b..c7fe163 100644
16583 --- a/arch/x86/include/asm/pgtable_32_types.h
16584 +++ b/arch/x86/include/asm/pgtable_32_types.h
16585 @@ -8,7 +8,7 @@
16586 */
16587 #ifdef CONFIG_X86_PAE
16588 # include <asm/pgtable-3level_types.h>
16589 -# define PMD_SIZE (1UL << PMD_SHIFT)
16590 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16591 # define PMD_MASK (~(PMD_SIZE - 1))
16592 #else
16593 # include <asm/pgtable-2level_types.h>
16594 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16595 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16596 #endif
16597
16598 +#ifdef CONFIG_PAX_KERNEXEC
16599 +#ifndef __ASSEMBLY__
16600 +extern unsigned char MODULES_EXEC_VADDR[];
16601 +extern unsigned char MODULES_EXEC_END[];
16602 +#endif
16603 +#include <asm/boot.h>
16604 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16605 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16606 +#else
16607 +#define ktla_ktva(addr) (addr)
16608 +#define ktva_ktla(addr) (addr)
16609 +#endif
16610 +
16611 #define MODULES_VADDR VMALLOC_START
16612 #define MODULES_END VMALLOC_END
16613 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16614 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16615 index e22c1db..23a625a 100644
16616 --- a/arch/x86/include/asm/pgtable_64.h
16617 +++ b/arch/x86/include/asm/pgtable_64.h
16618 @@ -16,10 +16,14 @@
16619
16620 extern pud_t level3_kernel_pgt[512];
16621 extern pud_t level3_ident_pgt[512];
16622 +extern pud_t level3_vmalloc_start_pgt[512];
16623 +extern pud_t level3_vmalloc_end_pgt[512];
16624 +extern pud_t level3_vmemmap_pgt[512];
16625 +extern pud_t level2_vmemmap_pgt[512];
16626 extern pmd_t level2_kernel_pgt[512];
16627 extern pmd_t level2_fixmap_pgt[512];
16628 -extern pmd_t level2_ident_pgt[512];
16629 -extern pgd_t init_level4_pgt[];
16630 +extern pmd_t level2_ident_pgt[512*2];
16631 +extern pgd_t init_level4_pgt[512];
16632
16633 #define swapper_pg_dir init_level4_pgt
16634
16635 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16636
16637 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16638 {
16639 + pax_open_kernel();
16640 *pmdp = pmd;
16641 + pax_close_kernel();
16642 }
16643
16644 static inline void native_pmd_clear(pmd_t *pmd)
16645 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16646
16647 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16648 {
16649 + pax_open_kernel();
16650 *pudp = pud;
16651 + pax_close_kernel();
16652 }
16653
16654 static inline void native_pud_clear(pud_t *pud)
16655 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16656
16657 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16658 {
16659 + pax_open_kernel();
16660 + *pgdp = pgd;
16661 + pax_close_kernel();
16662 +}
16663 +
16664 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16665 +{
16666 *pgdp = pgd;
16667 }
16668
16669 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16670 index 2d88344..4679fc3 100644
16671 --- a/arch/x86/include/asm/pgtable_64_types.h
16672 +++ b/arch/x86/include/asm/pgtable_64_types.h
16673 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16674 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16675 #define MODULES_END _AC(0xffffffffff000000, UL)
16676 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16677 +#define MODULES_EXEC_VADDR MODULES_VADDR
16678 +#define MODULES_EXEC_END MODULES_END
16679 +
16680 +#define ktla_ktva(addr) (addr)
16681 +#define ktva_ktla(addr) (addr)
16682
16683 #define EARLY_DYNAMIC_PAGE_TABLES 64
16684
16685 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16686 index 0ecac25..306c276 100644
16687 --- a/arch/x86/include/asm/pgtable_types.h
16688 +++ b/arch/x86/include/asm/pgtable_types.h
16689 @@ -16,13 +16,12 @@
16690 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16691 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16692 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16693 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16694 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16695 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16696 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16697 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16698 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16699 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16700 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16701 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16702 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16703 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16704
16705 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16706 @@ -40,7 +39,6 @@
16707 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16708 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16709 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16710 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16711 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16712 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16713 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16714 @@ -87,8 +85,10 @@
16715
16716 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16717 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16718 -#else
16719 +#elif defined(CONFIG_KMEMCHECK)
16720 #define _PAGE_NX (_AT(pteval_t, 0))
16721 +#else
16722 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16723 #endif
16724
16725 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16726 @@ -146,6 +146,9 @@
16727 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16728 _PAGE_ACCESSED)
16729
16730 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16731 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16732 +
16733 #define __PAGE_KERNEL_EXEC \
16734 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16735 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16736 @@ -156,7 +159,7 @@
16737 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16738 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16739 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16740 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16741 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16742 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16743 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16744 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16745 @@ -218,8 +221,8 @@
16746 * bits are combined, this will alow user to access the high address mapped
16747 * VDSO in the presence of CONFIG_COMPAT_VDSO
16748 */
16749 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16750 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16751 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16752 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16753 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16754 #endif
16755
16756 @@ -257,7 +260,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16757 {
16758 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16759 }
16760 +#endif
16761
16762 +#if PAGETABLE_LEVELS == 3
16763 +#include <asm-generic/pgtable-nopud.h>
16764 +#endif
16765 +
16766 +#if PAGETABLE_LEVELS == 2
16767 +#include <asm-generic/pgtable-nopmd.h>
16768 +#endif
16769 +
16770 +#ifndef __ASSEMBLY__
16771 #if PAGETABLE_LEVELS > 3
16772 typedef struct { pudval_t pud; } pud_t;
16773
16774 @@ -271,8 +284,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16775 return pud.pud;
16776 }
16777 #else
16778 -#include <asm-generic/pgtable-nopud.h>
16779 -
16780 static inline pudval_t native_pud_val(pud_t pud)
16781 {
16782 return native_pgd_val(pud.pgd);
16783 @@ -292,8 +303,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16784 return pmd.pmd;
16785 }
16786 #else
16787 -#include <asm-generic/pgtable-nopmd.h>
16788 -
16789 static inline pmdval_t native_pmd_val(pmd_t pmd)
16790 {
16791 return native_pgd_val(pmd.pud.pgd);
16792 @@ -333,7 +342,6 @@ typedef struct page *pgtable_t;
16793
16794 extern pteval_t __supported_pte_mask;
16795 extern void set_nx(void);
16796 -extern int nx_enabled;
16797
16798 #define pgprot_writecombine pgprot_writecombine
16799 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16800 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16801 index 987c75e..2723054 100644
16802 --- a/arch/x86/include/asm/processor.h
16803 +++ b/arch/x86/include/asm/processor.h
16804 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16805 : "memory");
16806 }
16807
16808 +/* invpcid (%rdx),%rax */
16809 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16810 +
16811 +#define INVPCID_SINGLE_ADDRESS 0UL
16812 +#define INVPCID_SINGLE_CONTEXT 1UL
16813 +#define INVPCID_ALL_GLOBAL 2UL
16814 +#define INVPCID_ALL_MONGLOBAL 3UL
16815 +
16816 +#define PCID_KERNEL 0UL
16817 +#define PCID_USER 1UL
16818 +#define PCID_NOFLUSH (1UL << 63)
16819 +
16820 static inline void load_cr3(pgd_t *pgdir)
16821 {
16822 - write_cr3(__pa(pgdir));
16823 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16824 }
16825
16826 #ifdef CONFIG_X86_32
16827 @@ -283,7 +295,7 @@ struct tss_struct {
16828
16829 } ____cacheline_aligned;
16830
16831 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16832 +extern struct tss_struct init_tss[NR_CPUS];
16833
16834 /*
16835 * Save the original ist values for checking stack pointers during debugging
16836 @@ -453,6 +465,7 @@ struct thread_struct {
16837 unsigned short ds;
16838 unsigned short fsindex;
16839 unsigned short gsindex;
16840 + unsigned short ss;
16841 #endif
16842 #ifdef CONFIG_X86_32
16843 unsigned long ip;
16844 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16845 extern unsigned long mmu_cr4_features;
16846 extern u32 *trampoline_cr4_features;
16847
16848 -static inline void set_in_cr4(unsigned long mask)
16849 -{
16850 - unsigned long cr4;
16851 -
16852 - mmu_cr4_features |= mask;
16853 - if (trampoline_cr4_features)
16854 - *trampoline_cr4_features = mmu_cr4_features;
16855 - cr4 = read_cr4();
16856 - cr4 |= mask;
16857 - write_cr4(cr4);
16858 -}
16859 -
16860 -static inline void clear_in_cr4(unsigned long mask)
16861 -{
16862 - unsigned long cr4;
16863 -
16864 - mmu_cr4_features &= ~mask;
16865 - if (trampoline_cr4_features)
16866 - *trampoline_cr4_features = mmu_cr4_features;
16867 - cr4 = read_cr4();
16868 - cr4 &= ~mask;
16869 - write_cr4(cr4);
16870 -}
16871 +extern void set_in_cr4(unsigned long mask);
16872 +extern void clear_in_cr4(unsigned long mask);
16873
16874 typedef struct {
16875 unsigned long seg;
16876 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16877 */
16878 #define TASK_SIZE PAGE_OFFSET
16879 #define TASK_SIZE_MAX TASK_SIZE
16880 +
16881 +#ifdef CONFIG_PAX_SEGMEXEC
16882 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16883 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16884 +#else
16885 #define STACK_TOP TASK_SIZE
16886 -#define STACK_TOP_MAX STACK_TOP
16887 +#endif
16888 +
16889 +#define STACK_TOP_MAX TASK_SIZE
16890
16891 #define INIT_THREAD { \
16892 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16893 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16894 .vm86_info = NULL, \
16895 .sysenter_cs = __KERNEL_CS, \
16896 .io_bitmap_ptr = NULL, \
16897 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16898 */
16899 #define INIT_TSS { \
16900 .x86_tss = { \
16901 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16902 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16903 .ss0 = __KERNEL_DS, \
16904 .ss1 = __KERNEL_CS, \
16905 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16906 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16907 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16908
16909 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16910 -#define KSTK_TOP(info) \
16911 -({ \
16912 - unsigned long *__ptr = (unsigned long *)(info); \
16913 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16914 -})
16915 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16916
16917 /*
16918 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16919 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16920 #define task_pt_regs(task) \
16921 ({ \
16922 struct pt_regs *__regs__; \
16923 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16924 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16925 __regs__ - 1; \
16926 })
16927
16928 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16929 /*
16930 * User space process size. 47bits minus one guard page.
16931 */
16932 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16933 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16934
16935 /* This decides where the kernel will search for a free chunk of vm
16936 * space during mmap's.
16937 */
16938 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16939 - 0xc0000000 : 0xFFFFe000)
16940 + 0xc0000000 : 0xFFFFf000)
16941
16942 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16943 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16944 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16945 #define STACK_TOP_MAX TASK_SIZE_MAX
16946
16947 #define INIT_THREAD { \
16948 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16949 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16950 }
16951
16952 #define INIT_TSS { \
16953 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16954 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16955 }
16956
16957 /*
16958 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16959 */
16960 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16961
16962 +#ifdef CONFIG_PAX_SEGMEXEC
16963 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16964 +#endif
16965 +
16966 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16967
16968 /* Get/set a process' ability to use the timestamp counter instruction */
16969 @@ -957,7 +956,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
16970 return 0;
16971 }
16972
16973 -extern unsigned long arch_align_stack(unsigned long sp);
16974 +#define arch_align_stack(x) ((x) & ~0xfUL)
16975 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16976
16977 void default_idle(void);
16978 @@ -967,6 +966,6 @@ bool xen_set_default_idle(void);
16979 #define xen_set_default_idle 0
16980 #endif
16981
16982 -void stop_this_cpu(void *dummy);
16983 +void stop_this_cpu(void *dummy) __noreturn;
16984 void df_debug(struct pt_regs *regs, long error_code);
16985 #endif /* _ASM_X86_PROCESSOR_H */
16986 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16987 index 942a086..6c26446 100644
16988 --- a/arch/x86/include/asm/ptrace.h
16989 +++ b/arch/x86/include/asm/ptrace.h
16990 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16991 }
16992
16993 /*
16994 - * user_mode_vm(regs) determines whether a register set came from user mode.
16995 + * user_mode(regs) determines whether a register set came from user mode.
16996 * This is true if V8086 mode was enabled OR if the register set was from
16997 * protected mode with RPL-3 CS value. This tricky test checks that with
16998 * one comparison. Many places in the kernel can bypass this full check
16999 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17000 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17001 + * be used.
17002 */
17003 -static inline int user_mode(struct pt_regs *regs)
17004 +static inline int user_mode_novm(struct pt_regs *regs)
17005 {
17006 #ifdef CONFIG_X86_32
17007 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17008 #else
17009 - return !!(regs->cs & 3);
17010 + return !!(regs->cs & SEGMENT_RPL_MASK);
17011 #endif
17012 }
17013
17014 -static inline int user_mode_vm(struct pt_regs *regs)
17015 +static inline int user_mode(struct pt_regs *regs)
17016 {
17017 #ifdef CONFIG_X86_32
17018 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17019 USER_RPL;
17020 #else
17021 - return user_mode(regs);
17022 + return user_mode_novm(regs);
17023 #endif
17024 }
17025
17026 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17027 #ifdef CONFIG_X86_64
17028 static inline bool user_64bit_mode(struct pt_regs *regs)
17029 {
17030 + unsigned long cs = regs->cs & 0xffff;
17031 #ifndef CONFIG_PARAVIRT
17032 /*
17033 * On non-paravirt systems, this is the only long mode CPL 3
17034 * selector. We do not allow long mode selectors in the LDT.
17035 */
17036 - return regs->cs == __USER_CS;
17037 + return cs == __USER_CS;
17038 #else
17039 /* Headers are too twisted for this to go in paravirt.h. */
17040 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17041 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17042 #endif
17043 }
17044
17045 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17046 * Traps from the kernel do not save sp and ss.
17047 * Use the helper function to retrieve sp.
17048 */
17049 - if (offset == offsetof(struct pt_regs, sp) &&
17050 - regs->cs == __KERNEL_CS)
17051 - return kernel_stack_pointer(regs);
17052 + if (offset == offsetof(struct pt_regs, sp)) {
17053 + unsigned long cs = regs->cs & 0xffff;
17054 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17055 + return kernel_stack_pointer(regs);
17056 + }
17057 #endif
17058 return *(unsigned long *)((unsigned long)regs + offset);
17059 }
17060 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17061 index 9c6b890..5305f53 100644
17062 --- a/arch/x86/include/asm/realmode.h
17063 +++ b/arch/x86/include/asm/realmode.h
17064 @@ -22,16 +22,14 @@ struct real_mode_header {
17065 #endif
17066 /* APM/BIOS reboot */
17067 u32 machine_real_restart_asm;
17068 -#ifdef CONFIG_X86_64
17069 u32 machine_real_restart_seg;
17070 -#endif
17071 };
17072
17073 /* This must match data at trampoline_32/64.S */
17074 struct trampoline_header {
17075 #ifdef CONFIG_X86_32
17076 u32 start;
17077 - u16 gdt_pad;
17078 + u16 boot_cs;
17079 u16 gdt_limit;
17080 u32 gdt_base;
17081 #else
17082 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17083 index a82c4f1..ac45053 100644
17084 --- a/arch/x86/include/asm/reboot.h
17085 +++ b/arch/x86/include/asm/reboot.h
17086 @@ -6,13 +6,13 @@
17087 struct pt_regs;
17088
17089 struct machine_ops {
17090 - void (*restart)(char *cmd);
17091 - void (*halt)(void);
17092 - void (*power_off)(void);
17093 + void (* __noreturn restart)(char *cmd);
17094 + void (* __noreturn halt)(void);
17095 + void (* __noreturn power_off)(void);
17096 void (*shutdown)(void);
17097 void (*crash_shutdown)(struct pt_regs *);
17098 - void (*emergency_restart)(void);
17099 -};
17100 + void (* __noreturn emergency_restart)(void);
17101 +} __no_const;
17102
17103 extern struct machine_ops machine_ops;
17104
17105 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17106 index cad82c9..2e5c5c1 100644
17107 --- a/arch/x86/include/asm/rwsem.h
17108 +++ b/arch/x86/include/asm/rwsem.h
17109 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17110 {
17111 asm volatile("# beginning down_read\n\t"
17112 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17113 +
17114 +#ifdef CONFIG_PAX_REFCOUNT
17115 + "jno 0f\n"
17116 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17117 + "int $4\n0:\n"
17118 + _ASM_EXTABLE(0b, 0b)
17119 +#endif
17120 +
17121 /* adds 0x00000001 */
17122 " jns 1f\n"
17123 " call call_rwsem_down_read_failed\n"
17124 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17125 "1:\n\t"
17126 " mov %1,%2\n\t"
17127 " add %3,%2\n\t"
17128 +
17129 +#ifdef CONFIG_PAX_REFCOUNT
17130 + "jno 0f\n"
17131 + "sub %3,%2\n"
17132 + "int $4\n0:\n"
17133 + _ASM_EXTABLE(0b, 0b)
17134 +#endif
17135 +
17136 " jle 2f\n\t"
17137 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17138 " jnz 1b\n\t"
17139 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17140 long tmp;
17141 asm volatile("# beginning down_write\n\t"
17142 LOCK_PREFIX " xadd %1,(%2)\n\t"
17143 +
17144 +#ifdef CONFIG_PAX_REFCOUNT
17145 + "jno 0f\n"
17146 + "mov %1,(%2)\n"
17147 + "int $4\n0:\n"
17148 + _ASM_EXTABLE(0b, 0b)
17149 +#endif
17150 +
17151 /* adds 0xffff0001, returns the old value */
17152 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17153 /* was the active mask 0 before? */
17154 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17155 long tmp;
17156 asm volatile("# beginning __up_read\n\t"
17157 LOCK_PREFIX " xadd %1,(%2)\n\t"
17158 +
17159 +#ifdef CONFIG_PAX_REFCOUNT
17160 + "jno 0f\n"
17161 + "mov %1,(%2)\n"
17162 + "int $4\n0:\n"
17163 + _ASM_EXTABLE(0b, 0b)
17164 +#endif
17165 +
17166 /* subtracts 1, returns the old value */
17167 " jns 1f\n\t"
17168 " call call_rwsem_wake\n" /* expects old value in %edx */
17169 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17170 long tmp;
17171 asm volatile("# beginning __up_write\n\t"
17172 LOCK_PREFIX " xadd %1,(%2)\n\t"
17173 +
17174 +#ifdef CONFIG_PAX_REFCOUNT
17175 + "jno 0f\n"
17176 + "mov %1,(%2)\n"
17177 + "int $4\n0:\n"
17178 + _ASM_EXTABLE(0b, 0b)
17179 +#endif
17180 +
17181 /* subtracts 0xffff0001, returns the old value */
17182 " jns 1f\n\t"
17183 " call call_rwsem_wake\n" /* expects old value in %edx */
17184 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17185 {
17186 asm volatile("# beginning __downgrade_write\n\t"
17187 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17188 +
17189 +#ifdef CONFIG_PAX_REFCOUNT
17190 + "jno 0f\n"
17191 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17192 + "int $4\n0:\n"
17193 + _ASM_EXTABLE(0b, 0b)
17194 +#endif
17195 +
17196 /*
17197 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17198 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17199 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17200 */
17201 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17202 {
17203 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17204 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17205 +
17206 +#ifdef CONFIG_PAX_REFCOUNT
17207 + "jno 0f\n"
17208 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17209 + "int $4\n0:\n"
17210 + _ASM_EXTABLE(0b, 0b)
17211 +#endif
17212 +
17213 : "+m" (sem->count)
17214 : "er" (delta));
17215 }
17216 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17217 */
17218 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17219 {
17220 - return delta + xadd(&sem->count, delta);
17221 + return delta + xadd_check_overflow(&sem->count, delta);
17222 }
17223
17224 #endif /* __KERNEL__ */
17225 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17226 index c48a950..bc40804 100644
17227 --- a/arch/x86/include/asm/segment.h
17228 +++ b/arch/x86/include/asm/segment.h
17229 @@ -64,10 +64,15 @@
17230 * 26 - ESPFIX small SS
17231 * 27 - per-cpu [ offset to per-cpu data area ]
17232 * 28 - stack_canary-20 [ for stack protector ]
17233 - * 29 - unused
17234 - * 30 - unused
17235 + * 29 - PCI BIOS CS
17236 + * 30 - PCI BIOS DS
17237 * 31 - TSS for double fault handler
17238 */
17239 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17240 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17241 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17242 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17243 +
17244 #define GDT_ENTRY_TLS_MIN 6
17245 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17246
17247 @@ -79,6 +84,8 @@
17248
17249 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17250
17251 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17252 +
17253 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17254
17255 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17256 @@ -104,6 +111,12 @@
17257 #define __KERNEL_STACK_CANARY 0
17258 #endif
17259
17260 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17261 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17262 +
17263 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17264 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17265 +
17266 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17267
17268 /*
17269 @@ -141,7 +154,7 @@
17270 */
17271
17272 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17273 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17274 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17275
17276
17277 #else
17278 @@ -165,6 +178,8 @@
17279 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17280 #define __USER32_DS __USER_DS
17281
17282 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17283 +
17284 #define GDT_ENTRY_TSS 8 /* needs two entries */
17285 #define GDT_ENTRY_LDT 10 /* needs two entries */
17286 #define GDT_ENTRY_TLS_MIN 12
17287 @@ -173,6 +188,8 @@
17288 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17289 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17290
17291 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17292 +
17293 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17294 #define FS_TLS 0
17295 #define GS_TLS 1
17296 @@ -180,12 +197,14 @@
17297 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17298 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17299
17300 -#define GDT_ENTRIES 16
17301 +#define GDT_ENTRIES 17
17302
17303 #endif
17304
17305 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17306 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17307 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17308 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17309 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17310 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17311 #ifndef CONFIG_PARAVIRT
17312 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17313 {
17314 unsigned long __limit;
17315 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17316 - return __limit + 1;
17317 + return __limit;
17318 }
17319
17320 #endif /* !__ASSEMBLY__ */
17321 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17322 index 8d3120f..352b440 100644
17323 --- a/arch/x86/include/asm/smap.h
17324 +++ b/arch/x86/include/asm/smap.h
17325 @@ -25,11 +25,40 @@
17326
17327 #include <asm/alternative-asm.h>
17328
17329 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17330 +#define ASM_PAX_OPEN_USERLAND \
17331 + 661: jmp 663f; \
17332 + .pushsection .altinstr_replacement, "a" ; \
17333 + 662: pushq %rax; nop; \
17334 + .popsection ; \
17335 + .pushsection .altinstructions, "a" ; \
17336 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17337 + .popsection ; \
17338 + call __pax_open_userland; \
17339 + popq %rax; \
17340 + 663:
17341 +
17342 +#define ASM_PAX_CLOSE_USERLAND \
17343 + 661: jmp 663f; \
17344 + .pushsection .altinstr_replacement, "a" ; \
17345 + 662: pushq %rax; nop; \
17346 + .popsection; \
17347 + .pushsection .altinstructions, "a" ; \
17348 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17349 + .popsection; \
17350 + call __pax_close_userland; \
17351 + popq %rax; \
17352 + 663:
17353 +#else
17354 +#define ASM_PAX_OPEN_USERLAND
17355 +#define ASM_PAX_CLOSE_USERLAND
17356 +#endif
17357 +
17358 #ifdef CONFIG_X86_SMAP
17359
17360 #define ASM_CLAC \
17361 661: ASM_NOP3 ; \
17362 - .pushsection .altinstr_replacement, "ax" ; \
17363 + .pushsection .altinstr_replacement, "a" ; \
17364 662: __ASM_CLAC ; \
17365 .popsection ; \
17366 .pushsection .altinstructions, "a" ; \
17367 @@ -38,7 +67,7 @@
17368
17369 #define ASM_STAC \
17370 661: ASM_NOP3 ; \
17371 - .pushsection .altinstr_replacement, "ax" ; \
17372 + .pushsection .altinstr_replacement, "a" ; \
17373 662: __ASM_STAC ; \
17374 .popsection ; \
17375 .pushsection .altinstructions, "a" ; \
17376 @@ -56,6 +85,37 @@
17377
17378 #include <asm/alternative.h>
17379
17380 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17381 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17382 +
17383 +extern void __pax_open_userland(void);
17384 +static __always_inline unsigned long pax_open_userland(void)
17385 +{
17386 +
17387 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17388 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17389 + :
17390 + : [open] "i" (__pax_open_userland)
17391 + : "memory", "rax");
17392 +#endif
17393 +
17394 + return 0;
17395 +}
17396 +
17397 +extern void __pax_close_userland(void);
17398 +static __always_inline unsigned long pax_close_userland(void)
17399 +{
17400 +
17401 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17402 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17403 + :
17404 + : [close] "i" (__pax_close_userland)
17405 + : "memory", "rax");
17406 +#endif
17407 +
17408 + return 0;
17409 +}
17410 +
17411 #ifdef CONFIG_X86_SMAP
17412
17413 static __always_inline void clac(void)
17414 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17415 index 4137890..03fa172 100644
17416 --- a/arch/x86/include/asm/smp.h
17417 +++ b/arch/x86/include/asm/smp.h
17418 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17419 /* cpus sharing the last level cache: */
17420 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17421 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17422 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17423 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17424
17425 static inline struct cpumask *cpu_sibling_mask(int cpu)
17426 {
17427 @@ -79,7 +79,7 @@ struct smp_ops {
17428
17429 void (*send_call_func_ipi)(const struct cpumask *mask);
17430 void (*send_call_func_single_ipi)(int cpu);
17431 -};
17432 +} __no_const;
17433
17434 /* Globals due to paravirt */
17435 extern void set_cpu_sibling_map(int cpu);
17436 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17437 extern int safe_smp_processor_id(void);
17438
17439 #elif defined(CONFIG_X86_64_SMP)
17440 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17441 -
17442 -#define stack_smp_processor_id() \
17443 -({ \
17444 - struct thread_info *ti; \
17445 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17446 - ti->cpu; \
17447 -})
17448 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17449 +#define stack_smp_processor_id() raw_smp_processor_id()
17450 #define safe_smp_processor_id() smp_processor_id()
17451
17452 #endif
17453 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17454 index bf156de..1a782ab 100644
17455 --- a/arch/x86/include/asm/spinlock.h
17456 +++ b/arch/x86/include/asm/spinlock.h
17457 @@ -223,6 +223,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17458 static inline void arch_read_lock(arch_rwlock_t *rw)
17459 {
17460 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17461 +
17462 +#ifdef CONFIG_PAX_REFCOUNT
17463 + "jno 0f\n"
17464 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17465 + "int $4\n0:\n"
17466 + _ASM_EXTABLE(0b, 0b)
17467 +#endif
17468 +
17469 "jns 1f\n"
17470 "call __read_lock_failed\n\t"
17471 "1:\n"
17472 @@ -232,6 +240,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17473 static inline void arch_write_lock(arch_rwlock_t *rw)
17474 {
17475 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17476 +
17477 +#ifdef CONFIG_PAX_REFCOUNT
17478 + "jno 0f\n"
17479 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17480 + "int $4\n0:\n"
17481 + _ASM_EXTABLE(0b, 0b)
17482 +#endif
17483 +
17484 "jz 1f\n"
17485 "call __write_lock_failed\n\t"
17486 "1:\n"
17487 @@ -261,13 +277,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17488
17489 static inline void arch_read_unlock(arch_rwlock_t *rw)
17490 {
17491 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17492 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17493 +
17494 +#ifdef CONFIG_PAX_REFCOUNT
17495 + "jno 0f\n"
17496 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17497 + "int $4\n0:\n"
17498 + _ASM_EXTABLE(0b, 0b)
17499 +#endif
17500 +
17501 :"+m" (rw->lock) : : "memory");
17502 }
17503
17504 static inline void arch_write_unlock(arch_rwlock_t *rw)
17505 {
17506 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17507 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17508 +
17509 +#ifdef CONFIG_PAX_REFCOUNT
17510 + "jno 0f\n"
17511 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17512 + "int $4\n0:\n"
17513 + _ASM_EXTABLE(0b, 0b)
17514 +#endif
17515 +
17516 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17517 }
17518
17519 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17520 index 6a99859..03cb807 100644
17521 --- a/arch/x86/include/asm/stackprotector.h
17522 +++ b/arch/x86/include/asm/stackprotector.h
17523 @@ -47,7 +47,7 @@
17524 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17525 */
17526 #define GDT_STACK_CANARY_INIT \
17527 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17528 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17529
17530 /*
17531 * Initialize the stackprotector canary value.
17532 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17533
17534 static inline void load_stack_canary_segment(void)
17535 {
17536 -#ifdef CONFIG_X86_32
17537 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17538 asm volatile ("mov %0, %%gs" : : "r" (0));
17539 #endif
17540 }
17541 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17542 index 70bbe39..4ae2bd4 100644
17543 --- a/arch/x86/include/asm/stacktrace.h
17544 +++ b/arch/x86/include/asm/stacktrace.h
17545 @@ -11,28 +11,20 @@
17546
17547 extern int kstack_depth_to_print;
17548
17549 -struct thread_info;
17550 +struct task_struct;
17551 struct stacktrace_ops;
17552
17553 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17554 - unsigned long *stack,
17555 - unsigned long bp,
17556 - const struct stacktrace_ops *ops,
17557 - void *data,
17558 - unsigned long *end,
17559 - int *graph);
17560 +typedef unsigned long walk_stack_t(struct task_struct *task,
17561 + void *stack_start,
17562 + unsigned long *stack,
17563 + unsigned long bp,
17564 + const struct stacktrace_ops *ops,
17565 + void *data,
17566 + unsigned long *end,
17567 + int *graph);
17568
17569 -extern unsigned long
17570 -print_context_stack(struct thread_info *tinfo,
17571 - unsigned long *stack, unsigned long bp,
17572 - const struct stacktrace_ops *ops, void *data,
17573 - unsigned long *end, int *graph);
17574 -
17575 -extern unsigned long
17576 -print_context_stack_bp(struct thread_info *tinfo,
17577 - unsigned long *stack, unsigned long bp,
17578 - const struct stacktrace_ops *ops, void *data,
17579 - unsigned long *end, int *graph);
17580 +extern walk_stack_t print_context_stack;
17581 +extern walk_stack_t print_context_stack_bp;
17582
17583 /* Generic stack tracer with callbacks */
17584
17585 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17586 void (*address)(void *data, unsigned long address, int reliable);
17587 /* On negative return stop dumping */
17588 int (*stack)(void *data, char *name);
17589 - walk_stack_t walk_stack;
17590 + walk_stack_t *walk_stack;
17591 };
17592
17593 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17594 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17595 index d7f3b3b..3cc39f1 100644
17596 --- a/arch/x86/include/asm/switch_to.h
17597 +++ b/arch/x86/include/asm/switch_to.h
17598 @@ -108,7 +108,7 @@ do { \
17599 "call __switch_to\n\t" \
17600 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17601 __switch_canary \
17602 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17603 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17604 "movq %%rax,%%rdi\n\t" \
17605 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17606 "jnz ret_from_fork\n\t" \
17607 @@ -119,7 +119,7 @@ do { \
17608 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17609 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17610 [_tif_fork] "i" (_TIF_FORK), \
17611 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17612 + [thread_info] "m" (current_tinfo), \
17613 [current_task] "m" (current_task) \
17614 __switch_canary_iparam \
17615 : "memory", "cc" __EXTRA_CLOBBER)
17616 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17617 index 2781119..618b59b 100644
17618 --- a/arch/x86/include/asm/thread_info.h
17619 +++ b/arch/x86/include/asm/thread_info.h
17620 @@ -10,6 +10,7 @@
17621 #include <linux/compiler.h>
17622 #include <asm/page.h>
17623 #include <asm/types.h>
17624 +#include <asm/percpu.h>
17625
17626 /*
17627 * low level task data that entry.S needs immediate access to
17628 @@ -23,7 +24,6 @@ struct exec_domain;
17629 #include <linux/atomic.h>
17630
17631 struct thread_info {
17632 - struct task_struct *task; /* main task structure */
17633 struct exec_domain *exec_domain; /* execution domain */
17634 __u32 flags; /* low level flags */
17635 __u32 status; /* thread synchronous flags */
17636 @@ -33,19 +33,13 @@ struct thread_info {
17637 mm_segment_t addr_limit;
17638 struct restart_block restart_block;
17639 void __user *sysenter_return;
17640 -#ifdef CONFIG_X86_32
17641 - unsigned long previous_esp; /* ESP of the previous stack in
17642 - case of nested (IRQ) stacks
17643 - */
17644 - __u8 supervisor_stack[0];
17645 -#endif
17646 + unsigned long lowest_stack;
17647 unsigned int sig_on_uaccess_error:1;
17648 unsigned int uaccess_err:1; /* uaccess failed */
17649 };
17650
17651 -#define INIT_THREAD_INFO(tsk) \
17652 +#define INIT_THREAD_INFO \
17653 { \
17654 - .task = &tsk, \
17655 .exec_domain = &default_exec_domain, \
17656 .flags = 0, \
17657 .cpu = 0, \
17658 @@ -56,7 +50,7 @@ struct thread_info {
17659 }, \
17660 }
17661
17662 -#define init_thread_info (init_thread_union.thread_info)
17663 +#define init_thread_info (init_thread_union.stack)
17664 #define init_stack (init_thread_union.stack)
17665
17666 #else /* !__ASSEMBLY__ */
17667 @@ -96,6 +90,7 @@ struct thread_info {
17668 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17669 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17670 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17671 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17672
17673 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17674 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17675 @@ -119,17 +114,18 @@ struct thread_info {
17676 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17677 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17678 #define _TIF_X32 (1 << TIF_X32)
17679 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17680
17681 /* work to do in syscall_trace_enter() */
17682 #define _TIF_WORK_SYSCALL_ENTRY \
17683 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17684 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17685 - _TIF_NOHZ)
17686 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17687
17688 /* work to do in syscall_trace_leave() */
17689 #define _TIF_WORK_SYSCALL_EXIT \
17690 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17691 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17692 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17693
17694 /* work to do on interrupt/exception return */
17695 #define _TIF_WORK_MASK \
17696 @@ -140,7 +136,7 @@ struct thread_info {
17697 /* work to do on any return to user space */
17698 #define _TIF_ALLWORK_MASK \
17699 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17700 - _TIF_NOHZ)
17701 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17702
17703 /* Only used for 64 bit */
17704 #define _TIF_DO_NOTIFY_MASK \
17705 @@ -156,45 +152,40 @@ struct thread_info {
17706
17707 #define PREEMPT_ACTIVE 0x10000000
17708
17709 -#ifdef CONFIG_X86_32
17710 -
17711 -#define STACK_WARN (THREAD_SIZE/8)
17712 -/*
17713 - * macros/functions for gaining access to the thread information structure
17714 - *
17715 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17716 - */
17717 -#ifndef __ASSEMBLY__
17718 -
17719 -
17720 -/* how to get the current stack pointer from C */
17721 -register unsigned long current_stack_pointer asm("esp") __used;
17722 -
17723 -/* how to get the thread information struct from C */
17724 -static inline struct thread_info *current_thread_info(void)
17725 -{
17726 - return (struct thread_info *)
17727 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17728 -}
17729 -
17730 -#else /* !__ASSEMBLY__ */
17731 -
17732 +#ifdef __ASSEMBLY__
17733 /* how to get the thread information struct from ASM */
17734 #define GET_THREAD_INFO(reg) \
17735 - movl $-THREAD_SIZE, reg; \
17736 - andl %esp, reg
17737 + mov PER_CPU_VAR(current_tinfo), reg
17738
17739 /* use this one if reg already contains %esp */
17740 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17741 - andl $-THREAD_SIZE, reg
17742 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17743 +#else
17744 +/* how to get the thread information struct from C */
17745 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17746 +
17747 +static __always_inline struct thread_info *current_thread_info(void)
17748 +{
17749 + return this_cpu_read_stable(current_tinfo);
17750 +}
17751 +#endif
17752 +
17753 +#ifdef CONFIG_X86_32
17754 +
17755 +#define STACK_WARN (THREAD_SIZE/8)
17756 +/*
17757 + * macros/functions for gaining access to the thread information structure
17758 + *
17759 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17760 + */
17761 +#ifndef __ASSEMBLY__
17762 +
17763 +/* how to get the current stack pointer from C */
17764 +register unsigned long current_stack_pointer asm("esp") __used;
17765
17766 #endif
17767
17768 #else /* X86_32 */
17769
17770 -#include <asm/percpu.h>
17771 -#define KERNEL_STACK_OFFSET (5*8)
17772 -
17773 /*
17774 * macros/functions for gaining access to the thread information structure
17775 * preempt_count needs to be 1 initially, until the scheduler is functional.
17776 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17777 #ifndef __ASSEMBLY__
17778 DECLARE_PER_CPU(unsigned long, kernel_stack);
17779
17780 -static inline struct thread_info *current_thread_info(void)
17781 -{
17782 - struct thread_info *ti;
17783 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17784 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17785 - return ti;
17786 -}
17787 -
17788 -#else /* !__ASSEMBLY__ */
17789 -
17790 -/* how to get the thread information struct from ASM */
17791 -#define GET_THREAD_INFO(reg) \
17792 - movq PER_CPU_VAR(kernel_stack),reg ; \
17793 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17794 -
17795 -/*
17796 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17797 - * a certain register (to be used in assembler memory operands).
17798 - */
17799 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17800 -
17801 +/* how to get the current stack pointer from C */
17802 +register unsigned long current_stack_pointer asm("rsp") __used;
17803 #endif
17804
17805 #endif /* !X86_32 */
17806 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17807 extern void arch_task_cache_init(void);
17808 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17809 extern void arch_release_task_struct(struct task_struct *tsk);
17810 +
17811 +#define __HAVE_THREAD_FUNCTIONS
17812 +#define task_thread_info(task) (&(task)->tinfo)
17813 +#define task_stack_page(task) ((task)->stack)
17814 +#define setup_thread_stack(p, org) do {} while (0)
17815 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17816 +
17817 #endif
17818 #endif /* _ASM_X86_THREAD_INFO_H */
17819 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17820 index e6d90ba..0897f44 100644
17821 --- a/arch/x86/include/asm/tlbflush.h
17822 +++ b/arch/x86/include/asm/tlbflush.h
17823 @@ -17,18 +17,44 @@
17824
17825 static inline void __native_flush_tlb(void)
17826 {
17827 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17828 + u64 descriptor[2];
17829 +
17830 + descriptor[0] = PCID_KERNEL;
17831 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17832 + return;
17833 + }
17834 +
17835 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17836 + if (static_cpu_has(X86_FEATURE_PCID)) {
17837 + unsigned int cpu = raw_get_cpu();
17838 +
17839 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17840 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17841 + raw_put_cpu_no_resched();
17842 + return;
17843 + }
17844 +#endif
17845 +
17846 native_write_cr3(native_read_cr3());
17847 }
17848
17849 static inline void __native_flush_tlb_global_irq_disabled(void)
17850 {
17851 - unsigned long cr4;
17852 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17853 + u64 descriptor[2];
17854
17855 - cr4 = native_read_cr4();
17856 - /* clear PGE */
17857 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17858 - /* write old PGE again and flush TLBs */
17859 - native_write_cr4(cr4);
17860 + descriptor[0] = PCID_KERNEL;
17861 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17862 + } else {
17863 + unsigned long cr4;
17864 +
17865 + cr4 = native_read_cr4();
17866 + /* clear PGE */
17867 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17868 + /* write old PGE again and flush TLBs */
17869 + native_write_cr4(cr4);
17870 + }
17871 }
17872
17873 static inline void __native_flush_tlb_global(void)
17874 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17875
17876 static inline void __native_flush_tlb_single(unsigned long addr)
17877 {
17878 +
17879 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17880 + u64 descriptor[2];
17881 +
17882 + descriptor[0] = PCID_KERNEL;
17883 + descriptor[1] = addr;
17884 +
17885 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17886 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17887 + if (addr < TASK_SIZE_MAX)
17888 + descriptor[1] += pax_user_shadow_base;
17889 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17890 + }
17891 +
17892 + descriptor[0] = PCID_USER;
17893 + descriptor[1] = addr;
17894 +#endif
17895 +
17896 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17897 + return;
17898 + }
17899 +
17900 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17901 + if (static_cpu_has(X86_FEATURE_PCID)) {
17902 + unsigned int cpu = raw_get_cpu();
17903 +
17904 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17905 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17906 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17907 + raw_put_cpu_no_resched();
17908 +
17909 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17910 + addr += pax_user_shadow_base;
17911 + }
17912 +#endif
17913 +
17914 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17915 }
17916
17917 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17918 index 5838fa9..f7ae572 100644
17919 --- a/arch/x86/include/asm/uaccess.h
17920 +++ b/arch/x86/include/asm/uaccess.h
17921 @@ -7,6 +7,7 @@
17922 #include <linux/compiler.h>
17923 #include <linux/thread_info.h>
17924 #include <linux/string.h>
17925 +#include <linux/sched.h>
17926 #include <asm/asm.h>
17927 #include <asm/page.h>
17928 #include <asm/smap.h>
17929 @@ -29,7 +30,12 @@
17930
17931 #define get_ds() (KERNEL_DS)
17932 #define get_fs() (current_thread_info()->addr_limit)
17933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17934 +void __set_fs(mm_segment_t x);
17935 +void set_fs(mm_segment_t x);
17936 +#else
17937 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17938 +#endif
17939
17940 #define segment_eq(a, b) ((a).seg == (b).seg)
17941
17942 @@ -77,8 +83,33 @@
17943 * checks that the pointer is in the user space range - after calling
17944 * this function, memory access functions may still return -EFAULT.
17945 */
17946 -#define access_ok(type, addr, size) \
17947 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17948 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17949 +#define access_ok(type, addr, size) \
17950 +({ \
17951 + long __size = size; \
17952 + unsigned long __addr = (unsigned long)addr; \
17953 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17954 + unsigned long __end_ao = __addr + __size - 1; \
17955 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17956 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17957 + while(__addr_ao <= __end_ao) { \
17958 + char __c_ao; \
17959 + __addr_ao += PAGE_SIZE; \
17960 + if (__size > PAGE_SIZE) \
17961 + cond_resched(); \
17962 + if (__get_user(__c_ao, (char __user *)__addr)) \
17963 + break; \
17964 + if (type != VERIFY_WRITE) { \
17965 + __addr = __addr_ao; \
17966 + continue; \
17967 + } \
17968 + if (__put_user(__c_ao, (char __user *)__addr)) \
17969 + break; \
17970 + __addr = __addr_ao; \
17971 + } \
17972 + } \
17973 + __ret_ao; \
17974 +})
17975
17976 /*
17977 * The exception table consists of pairs of addresses relative to the
17978 @@ -168,10 +199,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17979 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
17980 __chk_user_ptr(ptr); \
17981 might_fault(); \
17982 + pax_open_userland(); \
17983 asm volatile("call __get_user_%P3" \
17984 : "=a" (__ret_gu), "=r" (__val_gu) \
17985 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17986 (x) = (__typeof__(*(ptr))) __val_gu; \
17987 + pax_close_userland(); \
17988 __ret_gu; \
17989 })
17990
17991 @@ -179,13 +212,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17992 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17993 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17994
17995 -
17996 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17997 +#define __copyuser_seg "gs;"
17998 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17999 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18000 +#else
18001 +#define __copyuser_seg
18002 +#define __COPYUSER_SET_ES
18003 +#define __COPYUSER_RESTORE_ES
18004 +#endif
18005
18006 #ifdef CONFIG_X86_32
18007 #define __put_user_asm_u64(x, addr, err, errret) \
18008 asm volatile(ASM_STAC "\n" \
18009 - "1: movl %%eax,0(%2)\n" \
18010 - "2: movl %%edx,4(%2)\n" \
18011 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18012 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18013 "3: " ASM_CLAC "\n" \
18014 ".section .fixup,\"ax\"\n" \
18015 "4: movl %3,%0\n" \
18016 @@ -198,8 +239,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18017
18018 #define __put_user_asm_ex_u64(x, addr) \
18019 asm volatile(ASM_STAC "\n" \
18020 - "1: movl %%eax,0(%1)\n" \
18021 - "2: movl %%edx,4(%1)\n" \
18022 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18023 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18024 "3: " ASM_CLAC "\n" \
18025 _ASM_EXTABLE_EX(1b, 2b) \
18026 _ASM_EXTABLE_EX(2b, 3b) \
18027 @@ -249,7 +290,8 @@ extern void __put_user_8(void);
18028 __typeof__(*(ptr)) __pu_val; \
18029 __chk_user_ptr(ptr); \
18030 might_fault(); \
18031 - __pu_val = x; \
18032 + __pu_val = (x); \
18033 + pax_open_userland(); \
18034 switch (sizeof(*(ptr))) { \
18035 case 1: \
18036 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18037 @@ -267,6 +309,7 @@ extern void __put_user_8(void);
18038 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18039 break; \
18040 } \
18041 + pax_close_userland(); \
18042 __ret_pu; \
18043 })
18044
18045 @@ -347,8 +390,10 @@ do { \
18046 } while (0)
18047
18048 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18049 +do { \
18050 + pax_open_userland(); \
18051 asm volatile(ASM_STAC "\n" \
18052 - "1: mov"itype" %2,%"rtype"1\n" \
18053 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18054 "2: " ASM_CLAC "\n" \
18055 ".section .fixup,\"ax\"\n" \
18056 "3: mov %3,%0\n" \
18057 @@ -356,8 +401,10 @@ do { \
18058 " jmp 2b\n" \
18059 ".previous\n" \
18060 _ASM_EXTABLE(1b, 3b) \
18061 - : "=r" (err), ltype(x) \
18062 - : "m" (__m(addr)), "i" (errret), "0" (err))
18063 + : "=r" (err), ltype (x) \
18064 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18065 + pax_close_userland(); \
18066 +} while (0)
18067
18068 #define __get_user_size_ex(x, ptr, size) \
18069 do { \
18070 @@ -381,7 +428,7 @@ do { \
18071 } while (0)
18072
18073 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18074 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18075 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18076 "2:\n" \
18077 _ASM_EXTABLE_EX(1b, 2b) \
18078 : ltype(x) : "m" (__m(addr)))
18079 @@ -398,13 +445,24 @@ do { \
18080 int __gu_err; \
18081 unsigned long __gu_val; \
18082 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18083 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18084 + (x) = (__typeof__(*(ptr)))__gu_val; \
18085 __gu_err; \
18086 })
18087
18088 /* FIXME: this hack is definitely wrong -AK */
18089 struct __large_struct { unsigned long buf[100]; };
18090 -#define __m(x) (*(struct __large_struct __user *)(x))
18091 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18092 +#define ____m(x) \
18093 +({ \
18094 + unsigned long ____x = (unsigned long)(x); \
18095 + if (____x < pax_user_shadow_base) \
18096 + ____x += pax_user_shadow_base; \
18097 + (typeof(x))____x; \
18098 +})
18099 +#else
18100 +#define ____m(x) (x)
18101 +#endif
18102 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18103
18104 /*
18105 * Tell gcc we read from memory instead of writing: this is because
18106 @@ -412,8 +470,10 @@ struct __large_struct { unsigned long buf[100]; };
18107 * aliasing issues.
18108 */
18109 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18110 +do { \
18111 + pax_open_userland(); \
18112 asm volatile(ASM_STAC "\n" \
18113 - "1: mov"itype" %"rtype"1,%2\n" \
18114 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18115 "2: " ASM_CLAC "\n" \
18116 ".section .fixup,\"ax\"\n" \
18117 "3: mov %3,%0\n" \
18118 @@ -421,10 +481,12 @@ struct __large_struct { unsigned long buf[100]; };
18119 ".previous\n" \
18120 _ASM_EXTABLE(1b, 3b) \
18121 : "=r"(err) \
18122 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18123 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18124 + pax_close_userland(); \
18125 +} while (0)
18126
18127 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18128 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18129 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18130 "2:\n" \
18131 _ASM_EXTABLE_EX(1b, 2b) \
18132 : : ltype(x), "m" (__m(addr)))
18133 @@ -434,11 +496,13 @@ struct __large_struct { unsigned long buf[100]; };
18134 */
18135 #define uaccess_try do { \
18136 current_thread_info()->uaccess_err = 0; \
18137 + pax_open_userland(); \
18138 stac(); \
18139 barrier();
18140
18141 #define uaccess_catch(err) \
18142 clac(); \
18143 + pax_close_userland(); \
18144 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18145 } while (0)
18146
18147 @@ -463,8 +527,12 @@ struct __large_struct { unsigned long buf[100]; };
18148 * On error, the variable @x is set to zero.
18149 */
18150
18151 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18152 +#define __get_user(x, ptr) get_user((x), (ptr))
18153 +#else
18154 #define __get_user(x, ptr) \
18155 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18156 +#endif
18157
18158 /**
18159 * __put_user: - Write a simple value into user space, with less checking.
18160 @@ -486,8 +554,12 @@ struct __large_struct { unsigned long buf[100]; };
18161 * Returns zero on success, or -EFAULT on error.
18162 */
18163
18164 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18165 +#define __put_user(x, ptr) put_user((x), (ptr))
18166 +#else
18167 #define __put_user(x, ptr) \
18168 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18169 +#endif
18170
18171 #define __get_user_unaligned __get_user
18172 #define __put_user_unaligned __put_user
18173 @@ -505,7 +577,7 @@ struct __large_struct { unsigned long buf[100]; };
18174 #define get_user_ex(x, ptr) do { \
18175 unsigned long __gue_val; \
18176 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18177 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18178 + (x) = (__typeof__(*(ptr)))__gue_val; \
18179 } while (0)
18180
18181 #define put_user_try uaccess_try
18182 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18183 index 7f760a9..b596b9a 100644
18184 --- a/arch/x86/include/asm/uaccess_32.h
18185 +++ b/arch/x86/include/asm/uaccess_32.h
18186 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18187 static __always_inline unsigned long __must_check
18188 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18189 {
18190 + if ((long)n < 0)
18191 + return n;
18192 +
18193 + check_object_size(from, n, true);
18194 +
18195 if (__builtin_constant_p(n)) {
18196 unsigned long ret;
18197
18198 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18199 __copy_to_user(void __user *to, const void *from, unsigned long n)
18200 {
18201 might_fault();
18202 +
18203 return __copy_to_user_inatomic(to, from, n);
18204 }
18205
18206 static __always_inline unsigned long
18207 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18208 {
18209 + if ((long)n < 0)
18210 + return n;
18211 +
18212 /* Avoid zeroing the tail if the copy fails..
18213 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18214 * but as the zeroing behaviour is only significant when n is not
18215 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18216 __copy_from_user(void *to, const void __user *from, unsigned long n)
18217 {
18218 might_fault();
18219 +
18220 + if ((long)n < 0)
18221 + return n;
18222 +
18223 + check_object_size(to, n, false);
18224 +
18225 if (__builtin_constant_p(n)) {
18226 unsigned long ret;
18227
18228 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18229 const void __user *from, unsigned long n)
18230 {
18231 might_fault();
18232 +
18233 + if ((long)n < 0)
18234 + return n;
18235 +
18236 if (__builtin_constant_p(n)) {
18237 unsigned long ret;
18238
18239 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18240 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18241 unsigned long n)
18242 {
18243 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18244 + if ((long)n < 0)
18245 + return n;
18246 +
18247 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18248 }
18249
18250 -unsigned long __must_check copy_to_user(void __user *to,
18251 - const void *from, unsigned long n);
18252 -unsigned long __must_check _copy_from_user(void *to,
18253 - const void __user *from,
18254 - unsigned long n);
18255 -
18256 +extern void copy_to_user_overflow(void)
18257 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18258 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18259 +#else
18260 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18261 +#endif
18262 +;
18263
18264 extern void copy_from_user_overflow(void)
18265 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18266 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18267 #endif
18268 ;
18269
18270 -static inline unsigned long __must_check copy_from_user(void *to,
18271 - const void __user *from,
18272 - unsigned long n)
18273 +/**
18274 + * copy_to_user: - Copy a block of data into user space.
18275 + * @to: Destination address, in user space.
18276 + * @from: Source address, in kernel space.
18277 + * @n: Number of bytes to copy.
18278 + *
18279 + * Context: User context only. This function may sleep.
18280 + *
18281 + * Copy data from kernel space to user space.
18282 + *
18283 + * Returns number of bytes that could not be copied.
18284 + * On success, this will be zero.
18285 + */
18286 +static inline unsigned long __must_check
18287 +copy_to_user(void __user *to, const void *from, unsigned long n)
18288 {
18289 - int sz = __compiletime_object_size(to);
18290 + size_t sz = __compiletime_object_size(from);
18291
18292 - if (likely(sz == -1 || sz >= n))
18293 - n = _copy_from_user(to, from, n);
18294 - else
18295 + if (unlikely(sz != (size_t)-1 && sz < n))
18296 + copy_to_user_overflow();
18297 + else if (access_ok(VERIFY_WRITE, to, n))
18298 + n = __copy_to_user(to, from, n);
18299 + return n;
18300 +}
18301 +
18302 +/**
18303 + * copy_from_user: - Copy a block of data from user space.
18304 + * @to: Destination address, in kernel space.
18305 + * @from: Source address, in user space.
18306 + * @n: Number of bytes to copy.
18307 + *
18308 + * Context: User context only. This function may sleep.
18309 + *
18310 + * Copy data from user space to kernel space.
18311 + *
18312 + * Returns number of bytes that could not be copied.
18313 + * On success, this will be zero.
18314 + *
18315 + * If some data could not be copied, this function will pad the copied
18316 + * data to the requested size using zero bytes.
18317 + */
18318 +static inline unsigned long __must_check
18319 +copy_from_user(void *to, const void __user *from, unsigned long n)
18320 +{
18321 + size_t sz = __compiletime_object_size(to);
18322 +
18323 + check_object_size(to, n, false);
18324 +
18325 + if (unlikely(sz != (size_t)-1 && sz < n))
18326 copy_from_user_overflow();
18327 -
18328 + else if (access_ok(VERIFY_READ, from, n))
18329 + n = __copy_from_user(to, from, n);
18330 + else if ((long)n > 0)
18331 + memset(to, 0, n);
18332 return n;
18333 }
18334
18335 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18336 index 4f7923d..201b58d 100644
18337 --- a/arch/x86/include/asm/uaccess_64.h
18338 +++ b/arch/x86/include/asm/uaccess_64.h
18339 @@ -10,6 +10,9 @@
18340 #include <asm/alternative.h>
18341 #include <asm/cpufeature.h>
18342 #include <asm/page.h>
18343 +#include <asm/pgtable.h>
18344 +
18345 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18346
18347 /*
18348 * Copy To/From Userspace
18349 @@ -17,14 +20,14 @@
18350
18351 /* Handles exceptions in both to and from, but doesn't do access_ok */
18352 __must_check unsigned long
18353 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18354 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18355 __must_check unsigned long
18356 -copy_user_generic_string(void *to, const void *from, unsigned len);
18357 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18358 __must_check unsigned long
18359 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18360 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18361
18362 -static __always_inline __must_check unsigned long
18363 -copy_user_generic(void *to, const void *from, unsigned len)
18364 +static __always_inline __must_check unsigned long
18365 +copy_user_generic(void *to, const void *from, unsigned long len)
18366 {
18367 unsigned ret;
18368
18369 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18370 return ret;
18371 }
18372
18373 +static __always_inline __must_check unsigned long
18374 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18375 +static __always_inline __must_check unsigned long
18376 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18377 __must_check unsigned long
18378 -_copy_to_user(void __user *to, const void *from, unsigned len);
18379 -__must_check unsigned long
18380 -_copy_from_user(void *to, const void __user *from, unsigned len);
18381 -__must_check unsigned long
18382 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18383 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18384 +
18385 +extern void copy_to_user_overflow(void)
18386 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18387 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18388 +#else
18389 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18390 +#endif
18391 +;
18392 +
18393 +extern void copy_from_user_overflow(void)
18394 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18395 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18396 +#else
18397 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18398 +#endif
18399 +;
18400
18401 static inline unsigned long __must_check copy_from_user(void *to,
18402 const void __user *from,
18403 unsigned long n)
18404 {
18405 - int sz = __compiletime_object_size(to);
18406 -
18407 might_fault();
18408 - if (likely(sz == -1 || sz >= n))
18409 - n = _copy_from_user(to, from, n);
18410 -#ifdef CONFIG_DEBUG_VM
18411 - else
18412 - WARN(1, "Buffer overflow detected!\n");
18413 -#endif
18414 +
18415 + check_object_size(to, n, false);
18416 +
18417 + if (access_ok(VERIFY_READ, from, n))
18418 + n = __copy_from_user(to, from, n);
18419 + else if (n < INT_MAX)
18420 + memset(to, 0, n);
18421 return n;
18422 }
18423
18424 static __always_inline __must_check
18425 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18426 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18427 {
18428 might_fault();
18429
18430 - return _copy_to_user(dst, src, size);
18431 + if (access_ok(VERIFY_WRITE, dst, size))
18432 + size = __copy_to_user(dst, src, size);
18433 + return size;
18434 }
18435
18436 static __always_inline __must_check
18437 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18438 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18439 {
18440 - int ret = 0;
18441 + size_t sz = __compiletime_object_size(dst);
18442 + unsigned ret = 0;
18443
18444 might_fault();
18445 +
18446 + if (size > INT_MAX)
18447 + return size;
18448 +
18449 + check_object_size(dst, size, false);
18450 +
18451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18452 + if (!__access_ok(VERIFY_READ, src, size))
18453 + return size;
18454 +#endif
18455 +
18456 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18457 + copy_from_user_overflow();
18458 + return size;
18459 + }
18460 +
18461 if (!__builtin_constant_p(size))
18462 - return copy_user_generic(dst, (__force void *)src, size);
18463 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18464 switch (size) {
18465 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18466 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18467 ret, "b", "b", "=q", 1);
18468 return ret;
18469 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18470 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18471 ret, "w", "w", "=r", 2);
18472 return ret;
18473 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18474 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18475 ret, "l", "k", "=r", 4);
18476 return ret;
18477 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18478 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18479 ret, "q", "", "=r", 8);
18480 return ret;
18481 case 10:
18482 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18483 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18484 ret, "q", "", "=r", 10);
18485 if (unlikely(ret))
18486 return ret;
18487 __get_user_asm(*(u16 *)(8 + (char *)dst),
18488 - (u16 __user *)(8 + (char __user *)src),
18489 + (const u16 __user *)(8 + (const char __user *)src),
18490 ret, "w", "w", "=r", 2);
18491 return ret;
18492 case 16:
18493 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18494 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18495 ret, "q", "", "=r", 16);
18496 if (unlikely(ret))
18497 return ret;
18498 __get_user_asm(*(u64 *)(8 + (char *)dst),
18499 - (u64 __user *)(8 + (char __user *)src),
18500 + (const u64 __user *)(8 + (const char __user *)src),
18501 ret, "q", "", "=r", 8);
18502 return ret;
18503 default:
18504 - return copy_user_generic(dst, (__force void *)src, size);
18505 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18506 }
18507 }
18508
18509 static __always_inline __must_check
18510 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18511 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18512 {
18513 - int ret = 0;
18514 + size_t sz = __compiletime_object_size(src);
18515 + unsigned ret = 0;
18516
18517 might_fault();
18518 +
18519 + if (size > INT_MAX)
18520 + return size;
18521 +
18522 + check_object_size(src, size, true);
18523 +
18524 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18525 + if (!__access_ok(VERIFY_WRITE, dst, size))
18526 + return size;
18527 +#endif
18528 +
18529 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18530 + copy_to_user_overflow();
18531 + return size;
18532 + }
18533 +
18534 if (!__builtin_constant_p(size))
18535 - return copy_user_generic((__force void *)dst, src, size);
18536 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18537 switch (size) {
18538 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18539 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18540 ret, "b", "b", "iq", 1);
18541 return ret;
18542 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18543 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18544 ret, "w", "w", "ir", 2);
18545 return ret;
18546 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18547 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18548 ret, "l", "k", "ir", 4);
18549 return ret;
18550 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18551 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18552 ret, "q", "", "er", 8);
18553 return ret;
18554 case 10:
18555 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18556 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18557 ret, "q", "", "er", 10);
18558 if (unlikely(ret))
18559 return ret;
18560 asm("":::"memory");
18561 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18562 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18563 ret, "w", "w", "ir", 2);
18564 return ret;
18565 case 16:
18566 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18567 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18568 ret, "q", "", "er", 16);
18569 if (unlikely(ret))
18570 return ret;
18571 asm("":::"memory");
18572 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18573 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18574 ret, "q", "", "er", 8);
18575 return ret;
18576 default:
18577 - return copy_user_generic((__force void *)dst, src, size);
18578 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18579 }
18580 }
18581
18582 static __always_inline __must_check
18583 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18584 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18585 {
18586 - int ret = 0;
18587 + unsigned ret = 0;
18588
18589 might_fault();
18590 +
18591 + if (size > INT_MAX)
18592 + return size;
18593 +
18594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18595 + if (!__access_ok(VERIFY_READ, src, size))
18596 + return size;
18597 + if (!__access_ok(VERIFY_WRITE, dst, size))
18598 + return size;
18599 +#endif
18600 +
18601 if (!__builtin_constant_p(size))
18602 - return copy_user_generic((__force void *)dst,
18603 - (__force void *)src, size);
18604 + return copy_user_generic((__force_kernel void *)____m(dst),
18605 + (__force_kernel const void *)____m(src), size);
18606 switch (size) {
18607 case 1: {
18608 u8 tmp;
18609 - __get_user_asm(tmp, (u8 __user *)src,
18610 + __get_user_asm(tmp, (const u8 __user *)src,
18611 ret, "b", "b", "=q", 1);
18612 if (likely(!ret))
18613 __put_user_asm(tmp, (u8 __user *)dst,
18614 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18615 }
18616 case 2: {
18617 u16 tmp;
18618 - __get_user_asm(tmp, (u16 __user *)src,
18619 + __get_user_asm(tmp, (const u16 __user *)src,
18620 ret, "w", "w", "=r", 2);
18621 if (likely(!ret))
18622 __put_user_asm(tmp, (u16 __user *)dst,
18623 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18624
18625 case 4: {
18626 u32 tmp;
18627 - __get_user_asm(tmp, (u32 __user *)src,
18628 + __get_user_asm(tmp, (const u32 __user *)src,
18629 ret, "l", "k", "=r", 4);
18630 if (likely(!ret))
18631 __put_user_asm(tmp, (u32 __user *)dst,
18632 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18633 }
18634 case 8: {
18635 u64 tmp;
18636 - __get_user_asm(tmp, (u64 __user *)src,
18637 + __get_user_asm(tmp, (const u64 __user *)src,
18638 ret, "q", "", "=r", 8);
18639 if (likely(!ret))
18640 __put_user_asm(tmp, (u64 __user *)dst,
18641 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18642 return ret;
18643 }
18644 default:
18645 - return copy_user_generic((__force void *)dst,
18646 - (__force void *)src, size);
18647 + return copy_user_generic((__force_kernel void *)____m(dst),
18648 + (__force_kernel const void *)____m(src), size);
18649 }
18650 }
18651
18652 -static __must_check __always_inline int
18653 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18654 +static __must_check __always_inline unsigned long
18655 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18656 {
18657 - return copy_user_generic(dst, (__force const void *)src, size);
18658 + if (size > INT_MAX)
18659 + return size;
18660 +
18661 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18662 + if (!__access_ok(VERIFY_READ, src, size))
18663 + return size;
18664 +#endif
18665 +
18666 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18667 }
18668
18669 -static __must_check __always_inline int
18670 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18671 +static __must_check __always_inline unsigned long
18672 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18673 {
18674 - return copy_user_generic((__force void *)dst, src, size);
18675 + if (size > INT_MAX)
18676 + return size;
18677 +
18678 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18679 + if (!__access_ok(VERIFY_WRITE, dst, size))
18680 + return size;
18681 +#endif
18682 +
18683 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18684 }
18685
18686 -extern long __copy_user_nocache(void *dst, const void __user *src,
18687 - unsigned size, int zerorest);
18688 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18689 + unsigned long size, int zerorest);
18690
18691 -static inline int
18692 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18693 +static inline unsigned long
18694 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18695 {
18696 might_fault();
18697 +
18698 + if (size > INT_MAX)
18699 + return size;
18700 +
18701 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18702 + if (!__access_ok(VERIFY_READ, src, size))
18703 + return size;
18704 +#endif
18705 +
18706 return __copy_user_nocache(dst, src, size, 1);
18707 }
18708
18709 -static inline int
18710 +static inline unsigned long
18711 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18712 - unsigned size)
18713 + unsigned long size)
18714 {
18715 + if (size > INT_MAX)
18716 + return size;
18717 +
18718 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18719 + if (!__access_ok(VERIFY_READ, src, size))
18720 + return size;
18721 +#endif
18722 +
18723 return __copy_user_nocache(dst, src, size, 0);
18724 }
18725
18726 unsigned long
18727 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18728 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18729
18730 #endif /* _ASM_X86_UACCESS_64_H */
18731 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18732 index 5b238981..77fdd78 100644
18733 --- a/arch/x86/include/asm/word-at-a-time.h
18734 +++ b/arch/x86/include/asm/word-at-a-time.h
18735 @@ -11,7 +11,7 @@
18736 * and shift, for example.
18737 */
18738 struct word_at_a_time {
18739 - const unsigned long one_bits, high_bits;
18740 + unsigned long one_bits, high_bits;
18741 };
18742
18743 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18744 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18745 index 828a156..650e625 100644
18746 --- a/arch/x86/include/asm/x86_init.h
18747 +++ b/arch/x86/include/asm/x86_init.h
18748 @@ -129,7 +129,7 @@ struct x86_init_ops {
18749 struct x86_init_timers timers;
18750 struct x86_init_iommu iommu;
18751 struct x86_init_pci pci;
18752 -};
18753 +} __no_const;
18754
18755 /**
18756 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18757 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18758 void (*setup_percpu_clockev)(void);
18759 void (*early_percpu_clock_init)(void);
18760 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18761 -};
18762 +} __no_const;
18763
18764 struct timespec;
18765
18766 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18767 void (*save_sched_clock_state)(void);
18768 void (*restore_sched_clock_state)(void);
18769 void (*apic_post_init)(void);
18770 -};
18771 +} __no_const;
18772
18773 struct pci_dev;
18774 struct msi_msg;
18775 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18776 void (*teardown_msi_irqs)(struct pci_dev *dev);
18777 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18778 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18779 -};
18780 +} __no_const;
18781
18782 struct IO_APIC_route_entry;
18783 struct io_apic_irq_attr;
18784 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18785 unsigned int destination, int vector,
18786 struct io_apic_irq_attr *attr);
18787 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18788 -};
18789 +} __no_const;
18790
18791 extern struct x86_init_ops x86_init;
18792 extern struct x86_cpuinit_ops x86_cpuinit;
18793 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
18794 index b913915..4f5a581 100644
18795 --- a/arch/x86/include/asm/xen/page.h
18796 +++ b/arch/x86/include/asm/xen/page.h
18797 @@ -56,7 +56,7 @@ extern int m2p_remove_override(struct page *page,
18798 extern struct page *m2p_find_override(unsigned long mfn);
18799 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
18800
18801 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
18802 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
18803 {
18804 unsigned long mfn;
18805
18806 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18807 index 0415cda..3b22adc 100644
18808 --- a/arch/x86/include/asm/xsave.h
18809 +++ b/arch/x86/include/asm/xsave.h
18810 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18811 if (unlikely(err))
18812 return -EFAULT;
18813
18814 + pax_open_userland();
18815 __asm__ __volatile__(ASM_STAC "\n"
18816 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18817 + "1:"
18818 + __copyuser_seg
18819 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18820 "2: " ASM_CLAC "\n"
18821 ".section .fixup,\"ax\"\n"
18822 "3: movl $-1,%[err]\n"
18823 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18824 : [err] "=r" (err)
18825 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18826 : "memory");
18827 + pax_close_userland();
18828 return err;
18829 }
18830
18831 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18832 {
18833 int err;
18834 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18835 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18836 u32 lmask = mask;
18837 u32 hmask = mask >> 32;
18838
18839 + pax_open_userland();
18840 __asm__ __volatile__(ASM_STAC "\n"
18841 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18842 + "1:"
18843 + __copyuser_seg
18844 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18845 "2: " ASM_CLAC "\n"
18846 ".section .fixup,\"ax\"\n"
18847 "3: movl $-1,%[err]\n"
18848 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18849 : [err] "=r" (err)
18850 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18851 : "memory"); /* memory required? */
18852 + pax_close_userland();
18853 return err;
18854 }
18855
18856 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18857 index bbae024..e1528f9 100644
18858 --- a/arch/x86/include/uapi/asm/e820.h
18859 +++ b/arch/x86/include/uapi/asm/e820.h
18860 @@ -63,7 +63,7 @@ struct e820map {
18861 #define ISA_START_ADDRESS 0xa0000
18862 #define ISA_END_ADDRESS 0x100000
18863
18864 -#define BIOS_BEGIN 0x000a0000
18865 +#define BIOS_BEGIN 0x000c0000
18866 #define BIOS_END 0x00100000
18867
18868 #define BIOS_ROM_BASE 0xffe00000
18869 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18870 index a5408b9..5133813 100644
18871 --- a/arch/x86/kernel/Makefile
18872 +++ b/arch/x86/kernel/Makefile
18873 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18874 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18875 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18876 obj-y += probe_roms.o
18877 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18878 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18879 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18880 obj-y += syscall_$(BITS).o
18881 obj-$(CONFIG_X86_64) += vsyscall_64.o
18882 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18883 index 40c7660..f709f4b 100644
18884 --- a/arch/x86/kernel/acpi/boot.c
18885 +++ b/arch/x86/kernel/acpi/boot.c
18886 @@ -1365,7 +1365,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18887 * If your system is blacklisted here, but you find that acpi=force
18888 * works for you, please contact linux-acpi@vger.kernel.org
18889 */
18890 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18891 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18892 /*
18893 * Boxes that need ACPI disabled
18894 */
18895 @@ -1440,7 +1440,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18896 };
18897
18898 /* second table for DMI checks that should run after early-quirks */
18899 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18900 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18901 /*
18902 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18903 * which includes some code which overrides all temperature
18904 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18905 index 3312010..a65ca7b 100644
18906 --- a/arch/x86/kernel/acpi/sleep.c
18907 +++ b/arch/x86/kernel/acpi/sleep.c
18908 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18909 #else /* CONFIG_64BIT */
18910 #ifdef CONFIG_SMP
18911 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18912 +
18913 + pax_open_kernel();
18914 early_gdt_descr.address =
18915 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18916 + pax_close_kernel();
18917 +
18918 initial_gs = per_cpu_offset(smp_processor_id());
18919 #endif
18920 initial_code = (unsigned long)wakeup_long64;
18921 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18922 index d1daa66..59fecba 100644
18923 --- a/arch/x86/kernel/acpi/wakeup_32.S
18924 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18925 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18926 # and restore the stack ... but you need gdt for this to work
18927 movl saved_context_esp, %esp
18928
18929 - movl %cs:saved_magic, %eax
18930 - cmpl $0x12345678, %eax
18931 + cmpl $0x12345678, saved_magic
18932 jne bogus_magic
18933
18934 # jump to place where we left off
18935 - movl saved_eip, %eax
18936 - jmp *%eax
18937 + jmp *(saved_eip)
18938
18939 bogus_magic:
18940 jmp bogus_magic
18941 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18942 index 15e8563..323cbe1 100644
18943 --- a/arch/x86/kernel/alternative.c
18944 +++ b/arch/x86/kernel/alternative.c
18945 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18946 */
18947 for (a = start; a < end; a++) {
18948 instr = (u8 *)&a->instr_offset + a->instr_offset;
18949 +
18950 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18951 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18952 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18953 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18954 +#endif
18955 +
18956 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18957 BUG_ON(a->replacementlen > a->instrlen);
18958 BUG_ON(a->instrlen > sizeof(insnbuf));
18959 @@ -300,10 +307,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18960 for (poff = start; poff < end; poff++) {
18961 u8 *ptr = (u8 *)poff + *poff;
18962
18963 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18964 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18965 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18966 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18967 +#endif
18968 +
18969 if (!*poff || ptr < text || ptr >= text_end)
18970 continue;
18971 /* turn DS segment override prefix into lock prefix */
18972 - if (*ptr == 0x3e)
18973 + if (*ktla_ktva(ptr) == 0x3e)
18974 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18975 }
18976 mutex_unlock(&text_mutex);
18977 @@ -318,10 +331,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18978 for (poff = start; poff < end; poff++) {
18979 u8 *ptr = (u8 *)poff + *poff;
18980
18981 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18982 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18983 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18984 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18985 +#endif
18986 +
18987 if (!*poff || ptr < text || ptr >= text_end)
18988 continue;
18989 /* turn lock prefix into DS segment override prefix */
18990 - if (*ptr == 0xf0)
18991 + if (*ktla_ktva(ptr) == 0xf0)
18992 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18993 }
18994 mutex_unlock(&text_mutex);
18995 @@ -469,7 +488,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18996
18997 BUG_ON(p->len > MAX_PATCH_LEN);
18998 /* prep the buffer with the original instructions */
18999 - memcpy(insnbuf, p->instr, p->len);
19000 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19001 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19002 (unsigned long)p->instr, p->len);
19003
19004 @@ -516,7 +535,7 @@ void __init alternative_instructions(void)
19005 if (!uniproc_patched || num_possible_cpus() == 1)
19006 free_init_pages("SMP alternatives",
19007 (unsigned long)__smp_locks,
19008 - (unsigned long)__smp_locks_end);
19009 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19010 #endif
19011
19012 apply_paravirt(__parainstructions, __parainstructions_end);
19013 @@ -536,13 +555,17 @@ void __init alternative_instructions(void)
19014 * instructions. And on the local CPU you need to be protected again NMI or MCE
19015 * handlers seeing an inconsistent instruction while you patch.
19016 */
19017 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19018 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19019 size_t len)
19020 {
19021 unsigned long flags;
19022 local_irq_save(flags);
19023 - memcpy(addr, opcode, len);
19024 +
19025 + pax_open_kernel();
19026 + memcpy(ktla_ktva(addr), opcode, len);
19027 sync_core();
19028 + pax_close_kernel();
19029 +
19030 local_irq_restore(flags);
19031 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19032 that causes hangs on some VIA CPUs. */
19033 @@ -564,36 +587,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19034 */
19035 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19036 {
19037 - unsigned long flags;
19038 - char *vaddr;
19039 + unsigned char *vaddr = ktla_ktva(addr);
19040 struct page *pages[2];
19041 - int i;
19042 + size_t i;
19043
19044 if (!core_kernel_text((unsigned long)addr)) {
19045 - pages[0] = vmalloc_to_page(addr);
19046 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19047 + pages[0] = vmalloc_to_page(vaddr);
19048 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19049 } else {
19050 - pages[0] = virt_to_page(addr);
19051 + pages[0] = virt_to_page(vaddr);
19052 WARN_ON(!PageReserved(pages[0]));
19053 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19054 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19055 }
19056 BUG_ON(!pages[0]);
19057 - local_irq_save(flags);
19058 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19059 - if (pages[1])
19060 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19061 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19062 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19063 - clear_fixmap(FIX_TEXT_POKE0);
19064 - if (pages[1])
19065 - clear_fixmap(FIX_TEXT_POKE1);
19066 - local_flush_tlb();
19067 - sync_core();
19068 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19069 - that causes hangs on some VIA CPUs. */
19070 + text_poke_early(addr, opcode, len);
19071 for (i = 0; i < len; i++)
19072 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19073 - local_irq_restore(flags);
19074 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19075 return addr;
19076 }
19077
19078 @@ -613,7 +622,7 @@ int poke_int3_handler(struct pt_regs *regs)
19079 if (likely(!bp_patching_in_progress))
19080 return 0;
19081
19082 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
19083 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
19084 return 0;
19085
19086 /* set up the specified breakpoint handler */
19087 @@ -647,7 +656,7 @@ int poke_int3_handler(struct pt_regs *regs)
19088 */
19089 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
19090 {
19091 - unsigned char int3 = 0xcc;
19092 + const unsigned char int3 = 0xcc;
19093
19094 bp_int3_handler = handler;
19095 bp_int3_addr = (u8 *)addr + sizeof(int3);
19096 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19097 index a7eb82d..f6e52d4 100644
19098 --- a/arch/x86/kernel/apic/apic.c
19099 +++ b/arch/x86/kernel/apic/apic.c
19100 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19101 /*
19102 * Debug level, exported for io_apic.c
19103 */
19104 -unsigned int apic_verbosity;
19105 +int apic_verbosity;
19106
19107 int pic_mode;
19108
19109 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19110 apic_write(APIC_ESR, 0);
19111 v1 = apic_read(APIC_ESR);
19112 ack_APIC_irq();
19113 - atomic_inc(&irq_err_count);
19114 + atomic_inc_unchecked(&irq_err_count);
19115
19116 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19117 smp_processor_id(), v0 , v1);
19118 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19119 index 00c77cf..2dc6a2d 100644
19120 --- a/arch/x86/kernel/apic/apic_flat_64.c
19121 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19122 @@ -157,7 +157,7 @@ static int flat_probe(void)
19123 return 1;
19124 }
19125
19126 -static struct apic apic_flat = {
19127 +static struct apic apic_flat __read_only = {
19128 .name = "flat",
19129 .probe = flat_probe,
19130 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19131 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19132 return 0;
19133 }
19134
19135 -static struct apic apic_physflat = {
19136 +static struct apic apic_physflat __read_only = {
19137
19138 .name = "physical flat",
19139 .probe = physflat_probe,
19140 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19141 index e145f28..2752888 100644
19142 --- a/arch/x86/kernel/apic/apic_noop.c
19143 +++ b/arch/x86/kernel/apic/apic_noop.c
19144 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19145 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19146 }
19147
19148 -struct apic apic_noop = {
19149 +struct apic apic_noop __read_only = {
19150 .name = "noop",
19151 .probe = noop_probe,
19152 .acpi_madt_oem_check = NULL,
19153 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19154 index d50e364..543bee3 100644
19155 --- a/arch/x86/kernel/apic/bigsmp_32.c
19156 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19157 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19158 return dmi_bigsmp;
19159 }
19160
19161 -static struct apic apic_bigsmp = {
19162 +static struct apic apic_bigsmp __read_only = {
19163
19164 .name = "bigsmp",
19165 .probe = probe_bigsmp,
19166 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19167 index c552247..587a316 100644
19168 --- a/arch/x86/kernel/apic/es7000_32.c
19169 +++ b/arch/x86/kernel/apic/es7000_32.c
19170 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19171 return ret && es7000_apic_is_cluster();
19172 }
19173
19174 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19175 -static struct apic __refdata apic_es7000_cluster = {
19176 +static struct apic apic_es7000_cluster __read_only = {
19177
19178 .name = "es7000",
19179 .probe = probe_es7000,
19180 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19181 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19182 };
19183
19184 -static struct apic __refdata apic_es7000 = {
19185 +static struct apic apic_es7000 __read_only = {
19186
19187 .name = "es7000",
19188 .probe = probe_es7000,
19189 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19190 index e63a5bd..c0babf8 100644
19191 --- a/arch/x86/kernel/apic/io_apic.c
19192 +++ b/arch/x86/kernel/apic/io_apic.c
19193 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19194 }
19195 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19196
19197 -void lock_vector_lock(void)
19198 +void lock_vector_lock(void) __acquires(vector_lock)
19199 {
19200 /* Used to the online set of cpus does not change
19201 * during assign_irq_vector.
19202 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19203 raw_spin_lock(&vector_lock);
19204 }
19205
19206 -void unlock_vector_lock(void)
19207 +void unlock_vector_lock(void) __releases(vector_lock)
19208 {
19209 raw_spin_unlock(&vector_lock);
19210 }
19211 @@ -2367,7 +2367,7 @@ static void ack_apic_edge(struct irq_data *data)
19212 ack_APIC_irq();
19213 }
19214
19215 -atomic_t irq_mis_count;
19216 +atomic_unchecked_t irq_mis_count;
19217
19218 #ifdef CONFIG_GENERIC_PENDING_IRQ
19219 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19220 @@ -2508,7 +2508,7 @@ static void ack_apic_level(struct irq_data *data)
19221 * at the cpu.
19222 */
19223 if (!(v & (1 << (i & 0x1f)))) {
19224 - atomic_inc(&irq_mis_count);
19225 + atomic_inc_unchecked(&irq_mis_count);
19226
19227 eoi_ioapic_irq(irq, cfg);
19228 }
19229 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19230 index 1e42e8f..daacf44 100644
19231 --- a/arch/x86/kernel/apic/numaq_32.c
19232 +++ b/arch/x86/kernel/apic/numaq_32.c
19233 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19234 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19235 }
19236
19237 -/* Use __refdata to keep false positive warning calm. */
19238 -static struct apic __refdata apic_numaq = {
19239 +static struct apic apic_numaq __read_only = {
19240
19241 .name = "NUMAQ",
19242 .probe = probe_numaq,
19243 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19244 index eb35ef9..f184a21 100644
19245 --- a/arch/x86/kernel/apic/probe_32.c
19246 +++ b/arch/x86/kernel/apic/probe_32.c
19247 @@ -72,7 +72,7 @@ static int probe_default(void)
19248 return 1;
19249 }
19250
19251 -static struct apic apic_default = {
19252 +static struct apic apic_default __read_only = {
19253
19254 .name = "default",
19255 .probe = probe_default,
19256 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19257 index 77c95c0..434f8a4 100644
19258 --- a/arch/x86/kernel/apic/summit_32.c
19259 +++ b/arch/x86/kernel/apic/summit_32.c
19260 @@ -486,7 +486,7 @@ void setup_summit(void)
19261 }
19262 #endif
19263
19264 -static struct apic apic_summit = {
19265 +static struct apic apic_summit __read_only = {
19266
19267 .name = "summit",
19268 .probe = probe_summit,
19269 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19270 index 140e29d..d88bc95 100644
19271 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19272 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19273 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19274 return notifier_from_errno(err);
19275 }
19276
19277 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19278 +static struct notifier_block x2apic_cpu_notifier = {
19279 .notifier_call = update_clusterinfo,
19280 };
19281
19282 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19283 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19284 }
19285
19286 -static struct apic apic_x2apic_cluster = {
19287 +static struct apic apic_x2apic_cluster __read_only = {
19288
19289 .name = "cluster x2apic",
19290 .probe = x2apic_cluster_probe,
19291 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19292 index 562a76d..a003c0f 100644
19293 --- a/arch/x86/kernel/apic/x2apic_phys.c
19294 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19295 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19296 return apic == &apic_x2apic_phys;
19297 }
19298
19299 -static struct apic apic_x2apic_phys = {
19300 +static struct apic apic_x2apic_phys __read_only = {
19301
19302 .name = "physical x2apic",
19303 .probe = x2apic_phys_probe,
19304 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19305 index a419814..1dd34a0 100644
19306 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19307 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19308 @@ -357,7 +357,7 @@ static int uv_probe(void)
19309 return apic == &apic_x2apic_uv_x;
19310 }
19311
19312 -static struct apic __refdata apic_x2apic_uv_x = {
19313 +static struct apic apic_x2apic_uv_x __read_only = {
19314
19315 .name = "UV large system",
19316 .probe = uv_probe,
19317 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19318 index 3ab0343..814c4787 100644
19319 --- a/arch/x86/kernel/apm_32.c
19320 +++ b/arch/x86/kernel/apm_32.c
19321 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19322 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19323 * even though they are called in protected mode.
19324 */
19325 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19326 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19327 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19328
19329 static const char driver_version[] = "1.16ac"; /* no spaces */
19330 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19331 BUG_ON(cpu != 0);
19332 gdt = get_cpu_gdt_table(cpu);
19333 save_desc_40 = gdt[0x40 / 8];
19334 +
19335 + pax_open_kernel();
19336 gdt[0x40 / 8] = bad_bios_desc;
19337 + pax_close_kernel();
19338
19339 apm_irq_save(flags);
19340 APM_DO_SAVE_SEGS;
19341 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19342 &call->esi);
19343 APM_DO_RESTORE_SEGS;
19344 apm_irq_restore(flags);
19345 +
19346 + pax_open_kernel();
19347 gdt[0x40 / 8] = save_desc_40;
19348 + pax_close_kernel();
19349 +
19350 put_cpu();
19351
19352 return call->eax & 0xff;
19353 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19354 BUG_ON(cpu != 0);
19355 gdt = get_cpu_gdt_table(cpu);
19356 save_desc_40 = gdt[0x40 / 8];
19357 +
19358 + pax_open_kernel();
19359 gdt[0x40 / 8] = bad_bios_desc;
19360 + pax_close_kernel();
19361
19362 apm_irq_save(flags);
19363 APM_DO_SAVE_SEGS;
19364 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19365 &call->eax);
19366 APM_DO_RESTORE_SEGS;
19367 apm_irq_restore(flags);
19368 +
19369 + pax_open_kernel();
19370 gdt[0x40 / 8] = save_desc_40;
19371 + pax_close_kernel();
19372 +
19373 put_cpu();
19374 return error;
19375 }
19376 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19377 * code to that CPU.
19378 */
19379 gdt = get_cpu_gdt_table(0);
19380 +
19381 + pax_open_kernel();
19382 set_desc_base(&gdt[APM_CS >> 3],
19383 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19384 set_desc_base(&gdt[APM_CS_16 >> 3],
19385 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19386 set_desc_base(&gdt[APM_DS >> 3],
19387 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19388 + pax_close_kernel();
19389
19390 proc_create("apm", 0, NULL, &apm_file_ops);
19391
19392 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19393 index 2861082..6d4718e 100644
19394 --- a/arch/x86/kernel/asm-offsets.c
19395 +++ b/arch/x86/kernel/asm-offsets.c
19396 @@ -33,6 +33,8 @@ void common(void) {
19397 OFFSET(TI_status, thread_info, status);
19398 OFFSET(TI_addr_limit, thread_info, addr_limit);
19399 OFFSET(TI_preempt_count, thread_info, preempt_count);
19400 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19401 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19402
19403 BLANK();
19404 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19405 @@ -53,8 +55,26 @@ void common(void) {
19406 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19407 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19408 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19409 +
19410 +#ifdef CONFIG_PAX_KERNEXEC
19411 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19412 #endif
19413
19414 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19415 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19416 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19417 +#ifdef CONFIG_X86_64
19418 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19419 +#endif
19420 +#endif
19421 +
19422 +#endif
19423 +
19424 + BLANK();
19425 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19426 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19427 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19428 +
19429 #ifdef CONFIG_XEN
19430 BLANK();
19431 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19432 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19433 index e7c798b..2b2019b 100644
19434 --- a/arch/x86/kernel/asm-offsets_64.c
19435 +++ b/arch/x86/kernel/asm-offsets_64.c
19436 @@ -77,6 +77,7 @@ int main(void)
19437 BLANK();
19438 #undef ENTRY
19439
19440 + DEFINE(TSS_size, sizeof(struct tss_struct));
19441 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19442 BLANK();
19443
19444 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19445 index 47b56a7..efc2bc6 100644
19446 --- a/arch/x86/kernel/cpu/Makefile
19447 +++ b/arch/x86/kernel/cpu/Makefile
19448 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19449 CFLAGS_REMOVE_perf_event.o = -pg
19450 endif
19451
19452 -# Make sure load_percpu_segment has no stackprotector
19453 -nostackp := $(call cc-option, -fno-stack-protector)
19454 -CFLAGS_common.o := $(nostackp)
19455 -
19456 obj-y := intel_cacheinfo.o scattered.o topology.o
19457 obj-y += proc.o capflags.o powerflags.o common.o
19458 obj-y += rdrand.o
19459 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19460 index 903a264..fc955f3 100644
19461 --- a/arch/x86/kernel/cpu/amd.c
19462 +++ b/arch/x86/kernel/cpu/amd.c
19463 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19464 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19465 {
19466 /* AMD errata T13 (order #21922) */
19467 - if ((c->x86 == 6)) {
19468 + if (c->x86 == 6) {
19469 /* Duron Rev A0 */
19470 if (c->x86_model == 3 && c->x86_mask == 0)
19471 size = 64;
19472 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19473 index 2793d1f..5c04a30 100644
19474 --- a/arch/x86/kernel/cpu/common.c
19475 +++ b/arch/x86/kernel/cpu/common.c
19476 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19477
19478 static const struct cpu_dev *this_cpu = &default_cpu;
19479
19480 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19481 -#ifdef CONFIG_X86_64
19482 - /*
19483 - * We need valid kernel segments for data and code in long mode too
19484 - * IRET will check the segment types kkeil 2000/10/28
19485 - * Also sysret mandates a special GDT layout
19486 - *
19487 - * TLS descriptors are currently at a different place compared to i386.
19488 - * Hopefully nobody expects them at a fixed place (Wine?)
19489 - */
19490 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19491 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19492 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19493 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19494 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19495 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19496 -#else
19497 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19498 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19499 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19500 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19501 - /*
19502 - * Segments used for calling PnP BIOS have byte granularity.
19503 - * They code segments and data segments have fixed 64k limits,
19504 - * the transfer segment sizes are set at run time.
19505 - */
19506 - /* 32-bit code */
19507 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19508 - /* 16-bit code */
19509 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19510 - /* 16-bit data */
19511 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19512 - /* 16-bit data */
19513 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19514 - /* 16-bit data */
19515 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19516 - /*
19517 - * The APM segments have byte granularity and their bases
19518 - * are set at run time. All have 64k limits.
19519 - */
19520 - /* 32-bit code */
19521 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19522 - /* 16-bit code */
19523 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19524 - /* data */
19525 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19526 -
19527 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19528 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19529 - GDT_STACK_CANARY_INIT
19530 -#endif
19531 -} };
19532 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19533 -
19534 static int __init x86_xsave_setup(char *s)
19535 {
19536 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19537 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19538 set_in_cr4(X86_CR4_SMAP);
19539 }
19540
19541 +#ifdef CONFIG_X86_64
19542 +static __init int setup_disable_pcid(char *arg)
19543 +{
19544 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19545 +
19546 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19547 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19548 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19549 +#endif
19550 +
19551 + return 1;
19552 +}
19553 +__setup("nopcid", setup_disable_pcid);
19554 +
19555 +static void setup_pcid(struct cpuinfo_x86 *c)
19556 +{
19557 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19558 +
19559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19560 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19561 + pax_open_kernel();
19562 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19563 + pax_close_kernel();
19564 + printk("PAX: slow and weak UDEREF enabled\n");
19565 + } else
19566 + printk("PAX: UDEREF disabled\n");
19567 +#endif
19568 +
19569 + return;
19570 + }
19571 +
19572 + printk("PAX: PCID detected\n");
19573 + set_in_cr4(X86_CR4_PCIDE);
19574 +
19575 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19576 + pax_open_kernel();
19577 + clone_pgd_mask = ~(pgdval_t)0UL;
19578 + pax_close_kernel();
19579 + if (pax_user_shadow_base)
19580 + printk("PAX: weak UDEREF enabled\n");
19581 + else {
19582 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19583 + printk("PAX: strong UDEREF enabled\n");
19584 + }
19585 +#endif
19586 +
19587 + if (cpu_has(c, X86_FEATURE_INVPCID))
19588 + printk("PAX: INVPCID detected\n");
19589 +}
19590 +#endif
19591 +
19592 /*
19593 * Some CPU features depend on higher CPUID levels, which may not always
19594 * be available due to CPUID level capping or broken virtualization
19595 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19596 {
19597 struct desc_ptr gdt_descr;
19598
19599 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19600 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19601 gdt_descr.size = GDT_SIZE - 1;
19602 load_gdt(&gdt_descr);
19603 /* Reload the per-cpu base */
19604 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19605 setup_smep(c);
19606 setup_smap(c);
19607
19608 +#ifdef CONFIG_X86_64
19609 + setup_pcid(c);
19610 +#endif
19611 +
19612 /*
19613 * The vendor-specific functions might have changed features.
19614 * Now we do "generic changes."
19615 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19616 /* Filter out anything that depends on CPUID levels we don't have */
19617 filter_cpuid_features(c, true);
19618
19619 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19620 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19621 +#endif
19622 +
19623 /* If the model name is still unset, do table lookup. */
19624 if (!c->x86_model_id[0]) {
19625 const char *p;
19626 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19627 }
19628 __setup("clearcpuid=", setup_disablecpuid);
19629
19630 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19631 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19632 +
19633 #ifdef CONFIG_X86_64
19634 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19635 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19636 - (unsigned long) debug_idt_table };
19637 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19638 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19639
19640 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19641 irq_stack_union) __aligned(PAGE_SIZE) __visible;
19642 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19643 EXPORT_PER_CPU_SYMBOL(current_task);
19644
19645 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19646 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19647 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19648 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19649
19650 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19651 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19652 load_ucode_ap();
19653
19654 cpu = stack_smp_processor_id();
19655 - t = &per_cpu(init_tss, cpu);
19656 + t = init_tss + cpu;
19657 oist = &per_cpu(orig_ist, cpu);
19658
19659 #ifdef CONFIG_NUMA
19660 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19661 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19662 barrier();
19663
19664 - x86_configure_nx();
19665 enable_x2apic();
19666
19667 /*
19668 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19669 {
19670 int cpu = smp_processor_id();
19671 struct task_struct *curr = current;
19672 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19673 + struct tss_struct *t = init_tss + cpu;
19674 struct thread_struct *thread = &curr->thread;
19675
19676 show_ucode_info_early();
19677 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19678 index 1414c90..1159406 100644
19679 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19680 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19681 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19682 };
19683
19684 #ifdef CONFIG_AMD_NB
19685 +static struct attribute *default_attrs_amd_nb[] = {
19686 + &type.attr,
19687 + &level.attr,
19688 + &coherency_line_size.attr,
19689 + &physical_line_partition.attr,
19690 + &ways_of_associativity.attr,
19691 + &number_of_sets.attr,
19692 + &size.attr,
19693 + &shared_cpu_map.attr,
19694 + &shared_cpu_list.attr,
19695 + NULL,
19696 + NULL,
19697 + NULL,
19698 + NULL
19699 +};
19700 +
19701 static struct attribute **amd_l3_attrs(void)
19702 {
19703 static struct attribute **attrs;
19704 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19705
19706 n = ARRAY_SIZE(default_attrs);
19707
19708 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19709 - n += 2;
19710 -
19711 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19712 - n += 1;
19713 -
19714 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19715 - if (attrs == NULL)
19716 - return attrs = default_attrs;
19717 -
19718 - for (n = 0; default_attrs[n]; n++)
19719 - attrs[n] = default_attrs[n];
19720 + attrs = default_attrs_amd_nb;
19721
19722 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19723 attrs[n++] = &cache_disable_0.attr;
19724 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19725 .default_attrs = default_attrs,
19726 };
19727
19728 +#ifdef CONFIG_AMD_NB
19729 +static struct kobj_type ktype_cache_amd_nb = {
19730 + .sysfs_ops = &sysfs_ops,
19731 + .default_attrs = default_attrs_amd_nb,
19732 +};
19733 +#endif
19734 +
19735 static struct kobj_type ktype_percpu_entry = {
19736 .sysfs_ops = &sysfs_ops,
19737 };
19738 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19739 return retval;
19740 }
19741
19742 +#ifdef CONFIG_AMD_NB
19743 + amd_l3_attrs();
19744 +#endif
19745 +
19746 for (i = 0; i < num_cache_leaves; i++) {
19747 + struct kobj_type *ktype;
19748 +
19749 this_object = INDEX_KOBJECT_PTR(cpu, i);
19750 this_object->cpu = cpu;
19751 this_object->index = i;
19752
19753 this_leaf = CPUID4_INFO_IDX(cpu, i);
19754
19755 - ktype_cache.default_attrs = default_attrs;
19756 + ktype = &ktype_cache;
19757 #ifdef CONFIG_AMD_NB
19758 if (this_leaf->base.nb)
19759 - ktype_cache.default_attrs = amd_l3_attrs();
19760 + ktype = &ktype_cache_amd_nb;
19761 #endif
19762 retval = kobject_init_and_add(&(this_object->kobj),
19763 - &ktype_cache,
19764 + ktype,
19765 per_cpu(ici_cache_kobject, cpu),
19766 "index%1lu", i);
19767 if (unlikely(retval)) {
19768 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19769 index b3218cd..99a75de 100644
19770 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19771 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19772 @@ -45,6 +45,7 @@
19773 #include <asm/processor.h>
19774 #include <asm/mce.h>
19775 #include <asm/msr.h>
19776 +#include <asm/local.h>
19777
19778 #include "mce-internal.h"
19779
19780 @@ -258,7 +259,7 @@ static void print_mce(struct mce *m)
19781 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19782 m->cs, m->ip);
19783
19784 - if (m->cs == __KERNEL_CS)
19785 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19786 print_symbol("{%s}", m->ip);
19787 pr_cont("\n");
19788 }
19789 @@ -291,10 +292,10 @@ static void print_mce(struct mce *m)
19790
19791 #define PANIC_TIMEOUT 5 /* 5 seconds */
19792
19793 -static atomic_t mce_paniced;
19794 +static atomic_unchecked_t mce_paniced;
19795
19796 static int fake_panic;
19797 -static atomic_t mce_fake_paniced;
19798 +static atomic_unchecked_t mce_fake_paniced;
19799
19800 /* Panic in progress. Enable interrupts and wait for final IPI */
19801 static void wait_for_panic(void)
19802 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19803 /*
19804 * Make sure only one CPU runs in machine check panic
19805 */
19806 - if (atomic_inc_return(&mce_paniced) > 1)
19807 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19808 wait_for_panic();
19809 barrier();
19810
19811 @@ -326,7 +327,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19812 console_verbose();
19813 } else {
19814 /* Don't log too much for fake panic */
19815 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19816 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19817 return;
19818 }
19819 /* First print corrected ones that are still unlogged */
19820 @@ -365,7 +366,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19821 if (!fake_panic) {
19822 if (panic_timeout == 0)
19823 panic_timeout = mca_cfg.panic_timeout;
19824 - panic(msg);
19825 + panic("%s", msg);
19826 } else
19827 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19828 }
19829 @@ -695,7 +696,7 @@ static int mce_timed_out(u64 *t)
19830 * might have been modified by someone else.
19831 */
19832 rmb();
19833 - if (atomic_read(&mce_paniced))
19834 + if (atomic_read_unchecked(&mce_paniced))
19835 wait_for_panic();
19836 if (!mca_cfg.monarch_timeout)
19837 goto out;
19838 @@ -1666,7 +1667,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19839 }
19840
19841 /* Call the installed machine check handler for this CPU setup. */
19842 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19843 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19844 unexpected_machine_check;
19845
19846 /*
19847 @@ -1689,7 +1690,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19848 return;
19849 }
19850
19851 + pax_open_kernel();
19852 machine_check_vector = do_machine_check;
19853 + pax_close_kernel();
19854
19855 __mcheck_cpu_init_generic();
19856 __mcheck_cpu_init_vendor(c);
19857 @@ -1703,7 +1706,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19858 */
19859
19860 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19861 -static int mce_chrdev_open_count; /* #times opened */
19862 +static local_t mce_chrdev_open_count; /* #times opened */
19863 static int mce_chrdev_open_exclu; /* already open exclusive? */
19864
19865 static int mce_chrdev_open(struct inode *inode, struct file *file)
19866 @@ -1711,7 +1714,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19867 spin_lock(&mce_chrdev_state_lock);
19868
19869 if (mce_chrdev_open_exclu ||
19870 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19871 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19872 spin_unlock(&mce_chrdev_state_lock);
19873
19874 return -EBUSY;
19875 @@ -1719,7 +1722,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19876
19877 if (file->f_flags & O_EXCL)
19878 mce_chrdev_open_exclu = 1;
19879 - mce_chrdev_open_count++;
19880 + local_inc(&mce_chrdev_open_count);
19881
19882 spin_unlock(&mce_chrdev_state_lock);
19883
19884 @@ -1730,7 +1733,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19885 {
19886 spin_lock(&mce_chrdev_state_lock);
19887
19888 - mce_chrdev_open_count--;
19889 + local_dec(&mce_chrdev_open_count);
19890 mce_chrdev_open_exclu = 0;
19891
19892 spin_unlock(&mce_chrdev_state_lock);
19893 @@ -2404,7 +2407,7 @@ static __init void mce_init_banks(void)
19894
19895 for (i = 0; i < mca_cfg.banks; i++) {
19896 struct mce_bank *b = &mce_banks[i];
19897 - struct device_attribute *a = &b->attr;
19898 + device_attribute_no_const *a = &b->attr;
19899
19900 sysfs_attr_init(&a->attr);
19901 a->attr.name = b->attrname;
19902 @@ -2472,7 +2475,7 @@ struct dentry *mce_get_debugfs_dir(void)
19903 static void mce_reset(void)
19904 {
19905 cpu_missing = 0;
19906 - atomic_set(&mce_fake_paniced, 0);
19907 + atomic_set_unchecked(&mce_fake_paniced, 0);
19908 atomic_set(&mce_executing, 0);
19909 atomic_set(&mce_callin, 0);
19910 atomic_set(&global_nwo, 0);
19911 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19912 index 1c044b1..37a2a43 100644
19913 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19914 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19915 @@ -11,6 +11,7 @@
19916 #include <asm/processor.h>
19917 #include <asm/mce.h>
19918 #include <asm/msr.h>
19919 +#include <asm/pgtable.h>
19920
19921 /* By default disabled */
19922 int mce_p5_enabled __read_mostly;
19923 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19924 if (!cpu_has(c, X86_FEATURE_MCE))
19925 return;
19926
19927 + pax_open_kernel();
19928 machine_check_vector = pentium_machine_check;
19929 + pax_close_kernel();
19930 /* Make sure the vector pointer is visible before we enable MCEs: */
19931 wmb();
19932
19933 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19934 index e9a701a..35317d6 100644
19935 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19936 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19937 @@ -10,6 +10,7 @@
19938 #include <asm/processor.h>
19939 #include <asm/mce.h>
19940 #include <asm/msr.h>
19941 +#include <asm/pgtable.h>
19942
19943 /* Machine check handler for WinChip C6: */
19944 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19945 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19946 {
19947 u32 lo, hi;
19948
19949 + pax_open_kernel();
19950 machine_check_vector = winchip_machine_check;
19951 + pax_close_kernel();
19952 /* Make sure the vector pointer is visible before we enable MCEs: */
19953 wmb();
19954
19955 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19956 index f961de9..8a9d332 100644
19957 --- a/arch/x86/kernel/cpu/mtrr/main.c
19958 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19959 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19960 u64 size_or_mask, size_and_mask;
19961 static bool mtrr_aps_delayed_init;
19962
19963 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19964 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19965
19966 const struct mtrr_ops *mtrr_if;
19967
19968 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19969 index df5e41f..816c719 100644
19970 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19971 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19972 @@ -25,7 +25,7 @@ struct mtrr_ops {
19973 int (*validate_add_page)(unsigned long base, unsigned long size,
19974 unsigned int type);
19975 int (*have_wrcomb)(void);
19976 -};
19977 +} __do_const;
19978
19979 extern int generic_get_free_region(unsigned long base, unsigned long size,
19980 int replace_reg);
19981 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19982 index 8a87a32..682a22a 100644
19983 --- a/arch/x86/kernel/cpu/perf_event.c
19984 +++ b/arch/x86/kernel/cpu/perf_event.c
19985 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19986 pr_info("no hardware sampling interrupt available.\n");
19987 }
19988
19989 -static struct attribute_group x86_pmu_format_group = {
19990 +static attribute_group_no_const x86_pmu_format_group = {
19991 .name = "format",
19992 .attrs = NULL,
19993 };
19994 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19995 NULL,
19996 };
19997
19998 -static struct attribute_group x86_pmu_events_group = {
19999 +static attribute_group_no_const x86_pmu_events_group = {
20000 .name = "events",
20001 .attrs = events_attr,
20002 };
20003 @@ -1958,7 +1958,7 @@ static unsigned long get_segment_base(unsigned int segment)
20004 if (idx > GDT_ENTRIES)
20005 return 0;
20006
20007 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20008 + desc = get_cpu_gdt_table(smp_processor_id());
20009 }
20010
20011 return get_desc_base(desc + idx);
20012 @@ -2048,7 +2048,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20013 break;
20014
20015 perf_callchain_store(entry, frame.return_address);
20016 - fp = frame.next_frame;
20017 + fp = (const void __force_user *)frame.next_frame;
20018 }
20019 }
20020
20021 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20022 index 639d128..e92d7e5 100644
20023 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20024 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20025 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20026 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20027 {
20028 struct attribute **attrs;
20029 - struct attribute_group *attr_group;
20030 + attribute_group_no_const *attr_group;
20031 int i = 0, j;
20032
20033 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20034 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20035 index f31a165..7b46cd8 100644
20036 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20037 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20038 @@ -2247,10 +2247,10 @@ __init int intel_pmu_init(void)
20039 * v2 and above have a perf capabilities MSR
20040 */
20041 if (version > 1) {
20042 - u64 capabilities;
20043 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20044
20045 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20046 - x86_pmu.intel_cap.capabilities = capabilities;
20047 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20048 + x86_pmu.intel_cap.capabilities = capabilities;
20049 }
20050
20051 intel_ds_init();
20052 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20053 index 4118f9f..f91d0ab 100644
20054 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20055 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20056 @@ -3204,7 +3204,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20057 static int __init uncore_type_init(struct intel_uncore_type *type)
20058 {
20059 struct intel_uncore_pmu *pmus;
20060 - struct attribute_group *attr_group;
20061 + attribute_group_no_const *attr_group;
20062 struct attribute **attrs;
20063 int i, j;
20064
20065 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20066 index a80ab71..4089da5 100644
20067 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20068 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20069 @@ -498,7 +498,7 @@ struct intel_uncore_box {
20070 struct uncore_event_desc {
20071 struct kobj_attribute attr;
20072 const char *config;
20073 -};
20074 +} __do_const;
20075
20076 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20077 { \
20078 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20079 index 7d9481c..99c7e4b 100644
20080 --- a/arch/x86/kernel/cpuid.c
20081 +++ b/arch/x86/kernel/cpuid.c
20082 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20083 return notifier_from_errno(err);
20084 }
20085
20086 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20087 +static struct notifier_block cpuid_class_cpu_notifier =
20088 {
20089 .notifier_call = cpuid_class_cpu_callback,
20090 };
20091 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20092 index e0e0841..da37e6f 100644
20093 --- a/arch/x86/kernel/crash.c
20094 +++ b/arch/x86/kernel/crash.c
20095 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20096 {
20097 #ifdef CONFIG_X86_32
20098 struct pt_regs fixed_regs;
20099 -#endif
20100
20101 -#ifdef CONFIG_X86_32
20102 - if (!user_mode_vm(regs)) {
20103 + if (!user_mode(regs)) {
20104 crash_fixup_ss_esp(&fixed_regs, regs);
20105 regs = &fixed_regs;
20106 }
20107 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20108 index afa64ad..dce67dd 100644
20109 --- a/arch/x86/kernel/crash_dump_64.c
20110 +++ b/arch/x86/kernel/crash_dump_64.c
20111 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20112 return -ENOMEM;
20113
20114 if (userbuf) {
20115 - if (copy_to_user(buf, vaddr + offset, csize)) {
20116 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20117 iounmap(vaddr);
20118 return -EFAULT;
20119 }
20120 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20121 index 5d3fe8d..02e1429 100644
20122 --- a/arch/x86/kernel/doublefault.c
20123 +++ b/arch/x86/kernel/doublefault.c
20124 @@ -13,7 +13,7 @@
20125
20126 #define DOUBLEFAULT_STACKSIZE (1024)
20127 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20128 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20129 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20130
20131 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20132
20133 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20134 unsigned long gdt, tss;
20135
20136 native_store_gdt(&gdt_desc);
20137 - gdt = gdt_desc.address;
20138 + gdt = (unsigned long)gdt_desc.address;
20139
20140 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20141
20142 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20143 /* 0x2 bit is always set */
20144 .flags = X86_EFLAGS_SF | 0x2,
20145 .sp = STACK_START,
20146 - .es = __USER_DS,
20147 + .es = __KERNEL_DS,
20148 .cs = __KERNEL_CS,
20149 .ss = __KERNEL_DS,
20150 - .ds = __USER_DS,
20151 + .ds = __KERNEL_DS,
20152 .fs = __KERNEL_PERCPU,
20153
20154 .__cr3 = __pa_nodebug(swapper_pg_dir),
20155 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20156 index deb6421..76bbc12 100644
20157 --- a/arch/x86/kernel/dumpstack.c
20158 +++ b/arch/x86/kernel/dumpstack.c
20159 @@ -2,6 +2,9 @@
20160 * Copyright (C) 1991, 1992 Linus Torvalds
20161 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20162 */
20163 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20164 +#define __INCLUDED_BY_HIDESYM 1
20165 +#endif
20166 #include <linux/kallsyms.h>
20167 #include <linux/kprobes.h>
20168 #include <linux/uaccess.h>
20169 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20170 static void
20171 print_ftrace_graph_addr(unsigned long addr, void *data,
20172 const struct stacktrace_ops *ops,
20173 - struct thread_info *tinfo, int *graph)
20174 + struct task_struct *task, int *graph)
20175 {
20176 - struct task_struct *task;
20177 unsigned long ret_addr;
20178 int index;
20179
20180 if (addr != (unsigned long)return_to_handler)
20181 return;
20182
20183 - task = tinfo->task;
20184 index = task->curr_ret_stack;
20185
20186 if (!task->ret_stack || index < *graph)
20187 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20188 static inline void
20189 print_ftrace_graph_addr(unsigned long addr, void *data,
20190 const struct stacktrace_ops *ops,
20191 - struct thread_info *tinfo, int *graph)
20192 + struct task_struct *task, int *graph)
20193 { }
20194 #endif
20195
20196 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20197 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20198 */
20199
20200 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20201 - void *p, unsigned int size, void *end)
20202 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20203 {
20204 - void *t = tinfo;
20205 if (end) {
20206 if (p < end && p >= (end-THREAD_SIZE))
20207 return 1;
20208 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20209 }
20210
20211 unsigned long
20212 -print_context_stack(struct thread_info *tinfo,
20213 +print_context_stack(struct task_struct *task, void *stack_start,
20214 unsigned long *stack, unsigned long bp,
20215 const struct stacktrace_ops *ops, void *data,
20216 unsigned long *end, int *graph)
20217 {
20218 struct stack_frame *frame = (struct stack_frame *)bp;
20219
20220 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20221 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20222 unsigned long addr;
20223
20224 addr = *stack;
20225 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20226 } else {
20227 ops->address(data, addr, 0);
20228 }
20229 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20230 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20231 }
20232 stack++;
20233 }
20234 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20235 EXPORT_SYMBOL_GPL(print_context_stack);
20236
20237 unsigned long
20238 -print_context_stack_bp(struct thread_info *tinfo,
20239 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20240 unsigned long *stack, unsigned long bp,
20241 const struct stacktrace_ops *ops, void *data,
20242 unsigned long *end, int *graph)
20243 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20244 struct stack_frame *frame = (struct stack_frame *)bp;
20245 unsigned long *ret_addr = &frame->return_address;
20246
20247 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20248 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20249 unsigned long addr = *ret_addr;
20250
20251 if (!__kernel_text_address(addr))
20252 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20253 ops->address(data, addr, 1);
20254 frame = frame->next_frame;
20255 ret_addr = &frame->return_address;
20256 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20257 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20258 }
20259
20260 return (unsigned long)frame;
20261 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20262 static void print_trace_address(void *data, unsigned long addr, int reliable)
20263 {
20264 touch_nmi_watchdog();
20265 - printk(data);
20266 + printk("%s", (char *)data);
20267 printk_address(addr, reliable);
20268 }
20269
20270 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20271 }
20272 EXPORT_SYMBOL_GPL(oops_begin);
20273
20274 +extern void gr_handle_kernel_exploit(void);
20275 +
20276 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20277 {
20278 if (regs && kexec_should_crash(current))
20279 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20280 panic("Fatal exception in interrupt");
20281 if (panic_on_oops)
20282 panic("Fatal exception");
20283 - do_exit(signr);
20284 +
20285 + gr_handle_kernel_exploit();
20286 +
20287 + do_group_exit(signr);
20288 }
20289
20290 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20291 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20292 print_modules();
20293 show_regs(regs);
20294 #ifdef CONFIG_X86_32
20295 - if (user_mode_vm(regs)) {
20296 + if (user_mode(regs)) {
20297 sp = regs->sp;
20298 ss = regs->ss & 0xffff;
20299 } else {
20300 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20301 unsigned long flags = oops_begin();
20302 int sig = SIGSEGV;
20303
20304 - if (!user_mode_vm(regs))
20305 + if (!user_mode(regs))
20306 report_bug(regs->ip, regs);
20307
20308 if (__die(str, regs, err))
20309 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20310 index f2a1770..540657f 100644
20311 --- a/arch/x86/kernel/dumpstack_32.c
20312 +++ b/arch/x86/kernel/dumpstack_32.c
20313 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20314 bp = stack_frame(task, regs);
20315
20316 for (;;) {
20317 - struct thread_info *context;
20318 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20319
20320 - context = (struct thread_info *)
20321 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20322 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20323 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20324
20325 - stack = (unsigned long *)context->previous_esp;
20326 - if (!stack)
20327 + if (stack_start == task_stack_page(task))
20328 break;
20329 + stack = *(unsigned long **)stack_start;
20330 if (ops->stack(data, "IRQ") < 0)
20331 break;
20332 touch_nmi_watchdog();
20333 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20334 int i;
20335
20336 show_regs_print_info(KERN_EMERG);
20337 - __show_regs(regs, !user_mode_vm(regs));
20338 + __show_regs(regs, !user_mode(regs));
20339
20340 /*
20341 * When in-kernel, we also print out the stack and code at the
20342 * time of the fault..
20343 */
20344 - if (!user_mode_vm(regs)) {
20345 + if (!user_mode(regs)) {
20346 unsigned int code_prologue = code_bytes * 43 / 64;
20347 unsigned int code_len = code_bytes;
20348 unsigned char c;
20349 u8 *ip;
20350 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20351
20352 pr_emerg("Stack:\n");
20353 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20354
20355 pr_emerg("Code:");
20356
20357 - ip = (u8 *)regs->ip - code_prologue;
20358 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20359 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20360 /* try starting at IP */
20361 - ip = (u8 *)regs->ip;
20362 + ip = (u8 *)regs->ip + cs_base;
20363 code_len = code_len - code_prologue + 1;
20364 }
20365 for (i = 0; i < code_len; i++, ip++) {
20366 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20367 pr_cont(" Bad EIP value.");
20368 break;
20369 }
20370 - if (ip == (u8 *)regs->ip)
20371 + if (ip == (u8 *)regs->ip + cs_base)
20372 pr_cont(" <%02x>", c);
20373 else
20374 pr_cont(" %02x", c);
20375 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20376 {
20377 unsigned short ud2;
20378
20379 + ip = ktla_ktva(ip);
20380 if (ip < PAGE_OFFSET)
20381 return 0;
20382 if (probe_kernel_address((unsigned short *)ip, ud2))
20383 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20384
20385 return ud2 == 0x0b0f;
20386 }
20387 +
20388 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20389 +void pax_check_alloca(unsigned long size)
20390 +{
20391 + unsigned long sp = (unsigned long)&sp, stack_left;
20392 +
20393 + /* all kernel stacks are of the same size */
20394 + stack_left = sp & (THREAD_SIZE - 1);
20395 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20396 +}
20397 +EXPORT_SYMBOL(pax_check_alloca);
20398 +#endif
20399 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20400 index addb207..99635fa 100644
20401 --- a/arch/x86/kernel/dumpstack_64.c
20402 +++ b/arch/x86/kernel/dumpstack_64.c
20403 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20404 unsigned long *irq_stack_end =
20405 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20406 unsigned used = 0;
20407 - struct thread_info *tinfo;
20408 int graph = 0;
20409 unsigned long dummy;
20410 + void *stack_start;
20411
20412 if (!task)
20413 task = current;
20414 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20415 * current stack address. If the stacks consist of nested
20416 * exceptions
20417 */
20418 - tinfo = task_thread_info(task);
20419 for (;;) {
20420 char *id;
20421 unsigned long *estack_end;
20422 +
20423 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20424 &used, &id);
20425
20426 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20427 if (ops->stack(data, id) < 0)
20428 break;
20429
20430 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20431 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20432 data, estack_end, &graph);
20433 ops->stack(data, "<EOE>");
20434 /*
20435 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20436 * second-to-last pointer (index -2 to end) in the
20437 * exception stack:
20438 */
20439 + if ((u16)estack_end[-1] != __KERNEL_DS)
20440 + goto out;
20441 stack = (unsigned long *) estack_end[-2];
20442 continue;
20443 }
20444 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20445 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20446 if (ops->stack(data, "IRQ") < 0)
20447 break;
20448 - bp = ops->walk_stack(tinfo, stack, bp,
20449 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20450 ops, data, irq_stack_end, &graph);
20451 /*
20452 * We link to the next stack (which would be
20453 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20454 /*
20455 * This handles the process stack:
20456 */
20457 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20458 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20459 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20460 +out:
20461 put_cpu();
20462 }
20463 EXPORT_SYMBOL(dump_trace);
20464 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20465
20466 return ud2 == 0x0b0f;
20467 }
20468 +
20469 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20470 +void pax_check_alloca(unsigned long size)
20471 +{
20472 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20473 + unsigned cpu, used;
20474 + char *id;
20475 +
20476 + /* check the process stack first */
20477 + stack_start = (unsigned long)task_stack_page(current);
20478 + stack_end = stack_start + THREAD_SIZE;
20479 + if (likely(stack_start <= sp && sp < stack_end)) {
20480 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20481 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20482 + return;
20483 + }
20484 +
20485 + cpu = get_cpu();
20486 +
20487 + /* check the irq stacks */
20488 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20489 + stack_start = stack_end - IRQ_STACK_SIZE;
20490 + if (stack_start <= sp && sp < stack_end) {
20491 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20492 + put_cpu();
20493 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20494 + return;
20495 + }
20496 +
20497 + /* check the exception stacks */
20498 + used = 0;
20499 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20500 + stack_start = stack_end - EXCEPTION_STKSZ;
20501 + if (stack_end && stack_start <= sp && sp < stack_end) {
20502 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20503 + put_cpu();
20504 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20505 + return;
20506 + }
20507 +
20508 + put_cpu();
20509 +
20510 + /* unknown stack */
20511 + BUG();
20512 +}
20513 +EXPORT_SYMBOL(pax_check_alloca);
20514 +#endif
20515 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20516 index 174da5f..5e55606 100644
20517 --- a/arch/x86/kernel/e820.c
20518 +++ b/arch/x86/kernel/e820.c
20519 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20520
20521 static void early_panic(char *msg)
20522 {
20523 - early_printk(msg);
20524 - panic(msg);
20525 + early_printk("%s", msg);
20526 + panic("%s", msg);
20527 }
20528
20529 static int userdef __initdata;
20530 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20531 index d15f575..d692043 100644
20532 --- a/arch/x86/kernel/early_printk.c
20533 +++ b/arch/x86/kernel/early_printk.c
20534 @@ -7,6 +7,7 @@
20535 #include <linux/pci_regs.h>
20536 #include <linux/pci_ids.h>
20537 #include <linux/errno.h>
20538 +#include <linux/sched.h>
20539 #include <asm/io.h>
20540 #include <asm/processor.h>
20541 #include <asm/fcntl.h>
20542 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20543 index f0dcb0c..9f39b80 100644
20544 --- a/arch/x86/kernel/entry_32.S
20545 +++ b/arch/x86/kernel/entry_32.S
20546 @@ -177,13 +177,153 @@
20547 /*CFI_REL_OFFSET gs, PT_GS*/
20548 .endm
20549 .macro SET_KERNEL_GS reg
20550 +
20551 +#ifdef CONFIG_CC_STACKPROTECTOR
20552 movl $(__KERNEL_STACK_CANARY), \reg
20553 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20554 + movl $(__USER_DS), \reg
20555 +#else
20556 + xorl \reg, \reg
20557 +#endif
20558 +
20559 movl \reg, %gs
20560 .endm
20561
20562 #endif /* CONFIG_X86_32_LAZY_GS */
20563
20564 -.macro SAVE_ALL
20565 +.macro pax_enter_kernel
20566 +#ifdef CONFIG_PAX_KERNEXEC
20567 + call pax_enter_kernel
20568 +#endif
20569 +.endm
20570 +
20571 +.macro pax_exit_kernel
20572 +#ifdef CONFIG_PAX_KERNEXEC
20573 + call pax_exit_kernel
20574 +#endif
20575 +.endm
20576 +
20577 +#ifdef CONFIG_PAX_KERNEXEC
20578 +ENTRY(pax_enter_kernel)
20579 +#ifdef CONFIG_PARAVIRT
20580 + pushl %eax
20581 + pushl %ecx
20582 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20583 + mov %eax, %esi
20584 +#else
20585 + mov %cr0, %esi
20586 +#endif
20587 + bts $16, %esi
20588 + jnc 1f
20589 + mov %cs, %esi
20590 + cmp $__KERNEL_CS, %esi
20591 + jz 3f
20592 + ljmp $__KERNEL_CS, $3f
20593 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20594 +2:
20595 +#ifdef CONFIG_PARAVIRT
20596 + mov %esi, %eax
20597 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20598 +#else
20599 + mov %esi, %cr0
20600 +#endif
20601 +3:
20602 +#ifdef CONFIG_PARAVIRT
20603 + popl %ecx
20604 + popl %eax
20605 +#endif
20606 + ret
20607 +ENDPROC(pax_enter_kernel)
20608 +
20609 +ENTRY(pax_exit_kernel)
20610 +#ifdef CONFIG_PARAVIRT
20611 + pushl %eax
20612 + pushl %ecx
20613 +#endif
20614 + mov %cs, %esi
20615 + cmp $__KERNEXEC_KERNEL_CS, %esi
20616 + jnz 2f
20617 +#ifdef CONFIG_PARAVIRT
20618 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20619 + mov %eax, %esi
20620 +#else
20621 + mov %cr0, %esi
20622 +#endif
20623 + btr $16, %esi
20624 + ljmp $__KERNEL_CS, $1f
20625 +1:
20626 +#ifdef CONFIG_PARAVIRT
20627 + mov %esi, %eax
20628 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20629 +#else
20630 + mov %esi, %cr0
20631 +#endif
20632 +2:
20633 +#ifdef CONFIG_PARAVIRT
20634 + popl %ecx
20635 + popl %eax
20636 +#endif
20637 + ret
20638 +ENDPROC(pax_exit_kernel)
20639 +#endif
20640 +
20641 + .macro pax_erase_kstack
20642 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20643 + call pax_erase_kstack
20644 +#endif
20645 + .endm
20646 +
20647 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20648 +/*
20649 + * ebp: thread_info
20650 + */
20651 +ENTRY(pax_erase_kstack)
20652 + pushl %edi
20653 + pushl %ecx
20654 + pushl %eax
20655 +
20656 + mov TI_lowest_stack(%ebp), %edi
20657 + mov $-0xBEEF, %eax
20658 + std
20659 +
20660 +1: mov %edi, %ecx
20661 + and $THREAD_SIZE_asm - 1, %ecx
20662 + shr $2, %ecx
20663 + repne scasl
20664 + jecxz 2f
20665 +
20666 + cmp $2*16, %ecx
20667 + jc 2f
20668 +
20669 + mov $2*16, %ecx
20670 + repe scasl
20671 + jecxz 2f
20672 + jne 1b
20673 +
20674 +2: cld
20675 + mov %esp, %ecx
20676 + sub %edi, %ecx
20677 +
20678 + cmp $THREAD_SIZE_asm, %ecx
20679 + jb 3f
20680 + ud2
20681 +3:
20682 +
20683 + shr $2, %ecx
20684 + rep stosl
20685 +
20686 + mov TI_task_thread_sp0(%ebp), %edi
20687 + sub $128, %edi
20688 + mov %edi, TI_lowest_stack(%ebp)
20689 +
20690 + popl %eax
20691 + popl %ecx
20692 + popl %edi
20693 + ret
20694 +ENDPROC(pax_erase_kstack)
20695 +#endif
20696 +
20697 +.macro __SAVE_ALL _DS
20698 cld
20699 PUSH_GS
20700 pushl_cfi %fs
20701 @@ -206,7 +346,7 @@
20702 CFI_REL_OFFSET ecx, 0
20703 pushl_cfi %ebx
20704 CFI_REL_OFFSET ebx, 0
20705 - movl $(__USER_DS), %edx
20706 + movl $\_DS, %edx
20707 movl %edx, %ds
20708 movl %edx, %es
20709 movl $(__KERNEL_PERCPU), %edx
20710 @@ -214,6 +354,15 @@
20711 SET_KERNEL_GS %edx
20712 .endm
20713
20714 +.macro SAVE_ALL
20715 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20716 + __SAVE_ALL __KERNEL_DS
20717 + pax_enter_kernel
20718 +#else
20719 + __SAVE_ALL __USER_DS
20720 +#endif
20721 +.endm
20722 +
20723 .macro RESTORE_INT_REGS
20724 popl_cfi %ebx
20725 CFI_RESTORE ebx
20726 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20727 popfl_cfi
20728 jmp syscall_exit
20729 CFI_ENDPROC
20730 -END(ret_from_fork)
20731 +ENDPROC(ret_from_fork)
20732
20733 ENTRY(ret_from_kernel_thread)
20734 CFI_STARTPROC
20735 @@ -344,7 +493,15 @@ ret_from_intr:
20736 andl $SEGMENT_RPL_MASK, %eax
20737 #endif
20738 cmpl $USER_RPL, %eax
20739 +
20740 +#ifdef CONFIG_PAX_KERNEXEC
20741 + jae resume_userspace
20742 +
20743 + pax_exit_kernel
20744 + jmp resume_kernel
20745 +#else
20746 jb resume_kernel # not returning to v8086 or userspace
20747 +#endif
20748
20749 ENTRY(resume_userspace)
20750 LOCKDEP_SYS_EXIT
20751 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20752 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20753 # int/exception return?
20754 jne work_pending
20755 - jmp restore_all
20756 -END(ret_from_exception)
20757 + jmp restore_all_pax
20758 +ENDPROC(ret_from_exception)
20759
20760 #ifdef CONFIG_PREEMPT
20761 ENTRY(resume_kernel)
20762 @@ -372,7 +529,7 @@ need_resched:
20763 jz restore_all
20764 call preempt_schedule_irq
20765 jmp need_resched
20766 -END(resume_kernel)
20767 +ENDPROC(resume_kernel)
20768 #endif
20769 CFI_ENDPROC
20770 /*
20771 @@ -406,30 +563,45 @@ sysenter_past_esp:
20772 /*CFI_REL_OFFSET cs, 0*/
20773 /*
20774 * Push current_thread_info()->sysenter_return to the stack.
20775 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20776 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20777 */
20778 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20779 + pushl_cfi $0
20780 CFI_REL_OFFSET eip, 0
20781
20782 pushl_cfi %eax
20783 SAVE_ALL
20784 + GET_THREAD_INFO(%ebp)
20785 + movl TI_sysenter_return(%ebp),%ebp
20786 + movl %ebp,PT_EIP(%esp)
20787 ENABLE_INTERRUPTS(CLBR_NONE)
20788
20789 /*
20790 * Load the potential sixth argument from user stack.
20791 * Careful about security.
20792 */
20793 + movl PT_OLDESP(%esp),%ebp
20794 +
20795 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20796 + mov PT_OLDSS(%esp),%ds
20797 +1: movl %ds:(%ebp),%ebp
20798 + push %ss
20799 + pop %ds
20800 +#else
20801 cmpl $__PAGE_OFFSET-3,%ebp
20802 jae syscall_fault
20803 ASM_STAC
20804 1: movl (%ebp),%ebp
20805 ASM_CLAC
20806 +#endif
20807 +
20808 movl %ebp,PT_EBP(%esp)
20809 _ASM_EXTABLE(1b,syscall_fault)
20810
20811 GET_THREAD_INFO(%ebp)
20812
20813 +#ifdef CONFIG_PAX_RANDKSTACK
20814 + pax_erase_kstack
20815 +#endif
20816 +
20817 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20818 jnz sysenter_audit
20819 sysenter_do_call:
20820 @@ -444,12 +616,24 @@ sysenter_do_call:
20821 testl $_TIF_ALLWORK_MASK, %ecx
20822 jne sysexit_audit
20823 sysenter_exit:
20824 +
20825 +#ifdef CONFIG_PAX_RANDKSTACK
20826 + pushl_cfi %eax
20827 + movl %esp, %eax
20828 + call pax_randomize_kstack
20829 + popl_cfi %eax
20830 +#endif
20831 +
20832 + pax_erase_kstack
20833 +
20834 /* if something modifies registers it must also disable sysexit */
20835 movl PT_EIP(%esp), %edx
20836 movl PT_OLDESP(%esp), %ecx
20837 xorl %ebp,%ebp
20838 TRACE_IRQS_ON
20839 1: mov PT_FS(%esp), %fs
20840 +2: mov PT_DS(%esp), %ds
20841 +3: mov PT_ES(%esp), %es
20842 PTGS_TO_GS
20843 ENABLE_INTERRUPTS_SYSEXIT
20844
20845 @@ -466,6 +650,9 @@ sysenter_audit:
20846 movl %eax,%edx /* 2nd arg: syscall number */
20847 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20848 call __audit_syscall_entry
20849 +
20850 + pax_erase_kstack
20851 +
20852 pushl_cfi %ebx
20853 movl PT_EAX(%esp),%eax /* reload syscall number */
20854 jmp sysenter_do_call
20855 @@ -491,10 +678,16 @@ sysexit_audit:
20856
20857 CFI_ENDPROC
20858 .pushsection .fixup,"ax"
20859 -2: movl $0,PT_FS(%esp)
20860 +4: movl $0,PT_FS(%esp)
20861 + jmp 1b
20862 +5: movl $0,PT_DS(%esp)
20863 + jmp 1b
20864 +6: movl $0,PT_ES(%esp)
20865 jmp 1b
20866 .popsection
20867 - _ASM_EXTABLE(1b,2b)
20868 + _ASM_EXTABLE(1b,4b)
20869 + _ASM_EXTABLE(2b,5b)
20870 + _ASM_EXTABLE(3b,6b)
20871 PTGS_TO_GS_EX
20872 ENDPROC(ia32_sysenter_target)
20873
20874 @@ -509,6 +702,11 @@ ENTRY(system_call)
20875 pushl_cfi %eax # save orig_eax
20876 SAVE_ALL
20877 GET_THREAD_INFO(%ebp)
20878 +
20879 +#ifdef CONFIG_PAX_RANDKSTACK
20880 + pax_erase_kstack
20881 +#endif
20882 +
20883 # system call tracing in operation / emulation
20884 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20885 jnz syscall_trace_entry
20886 @@ -527,6 +725,15 @@ syscall_exit:
20887 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20888 jne syscall_exit_work
20889
20890 +restore_all_pax:
20891 +
20892 +#ifdef CONFIG_PAX_RANDKSTACK
20893 + movl %esp, %eax
20894 + call pax_randomize_kstack
20895 +#endif
20896 +
20897 + pax_erase_kstack
20898 +
20899 restore_all:
20900 TRACE_IRQS_IRET
20901 restore_all_notrace:
20902 @@ -583,14 +790,34 @@ ldt_ss:
20903 * compensating for the offset by changing to the ESPFIX segment with
20904 * a base address that matches for the difference.
20905 */
20906 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20907 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20908 mov %esp, %edx /* load kernel esp */
20909 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20910 mov %dx, %ax /* eax: new kernel esp */
20911 sub %eax, %edx /* offset (low word is 0) */
20912 +#ifdef CONFIG_SMP
20913 + movl PER_CPU_VAR(cpu_number), %ebx
20914 + shll $PAGE_SHIFT_asm, %ebx
20915 + addl $cpu_gdt_table, %ebx
20916 +#else
20917 + movl $cpu_gdt_table, %ebx
20918 +#endif
20919 shr $16, %edx
20920 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20921 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20922 +
20923 +#ifdef CONFIG_PAX_KERNEXEC
20924 + mov %cr0, %esi
20925 + btr $16, %esi
20926 + mov %esi, %cr0
20927 +#endif
20928 +
20929 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20930 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20931 +
20932 +#ifdef CONFIG_PAX_KERNEXEC
20933 + bts $16, %esi
20934 + mov %esi, %cr0
20935 +#endif
20936 +
20937 pushl_cfi $__ESPFIX_SS
20938 pushl_cfi %eax /* new kernel esp */
20939 /* Disable interrupts, but do not irqtrace this section: we
20940 @@ -619,20 +846,18 @@ work_resched:
20941 movl TI_flags(%ebp), %ecx
20942 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20943 # than syscall tracing?
20944 - jz restore_all
20945 + jz restore_all_pax
20946 testb $_TIF_NEED_RESCHED, %cl
20947 jnz work_resched
20948
20949 work_notifysig: # deal with pending signals and
20950 # notify-resume requests
20951 + movl %esp, %eax
20952 #ifdef CONFIG_VM86
20953 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20954 - movl %esp, %eax
20955 jne work_notifysig_v86 # returning to kernel-space or
20956 # vm86-space
20957 1:
20958 -#else
20959 - movl %esp, %eax
20960 #endif
20961 TRACE_IRQS_ON
20962 ENABLE_INTERRUPTS(CLBR_NONE)
20963 @@ -653,7 +878,7 @@ work_notifysig_v86:
20964 movl %eax, %esp
20965 jmp 1b
20966 #endif
20967 -END(work_pending)
20968 +ENDPROC(work_pending)
20969
20970 # perform syscall exit tracing
20971 ALIGN
20972 @@ -661,11 +886,14 @@ syscall_trace_entry:
20973 movl $-ENOSYS,PT_EAX(%esp)
20974 movl %esp, %eax
20975 call syscall_trace_enter
20976 +
20977 + pax_erase_kstack
20978 +
20979 /* What it returned is what we'll actually use. */
20980 cmpl $(NR_syscalls), %eax
20981 jnae syscall_call
20982 jmp syscall_exit
20983 -END(syscall_trace_entry)
20984 +ENDPROC(syscall_trace_entry)
20985
20986 # perform syscall exit tracing
20987 ALIGN
20988 @@ -678,21 +906,25 @@ syscall_exit_work:
20989 movl %esp, %eax
20990 call syscall_trace_leave
20991 jmp resume_userspace
20992 -END(syscall_exit_work)
20993 +ENDPROC(syscall_exit_work)
20994 CFI_ENDPROC
20995
20996 RING0_INT_FRAME # can't unwind into user space anyway
20997 syscall_fault:
20998 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20999 + push %ss
21000 + pop %ds
21001 +#endif
21002 ASM_CLAC
21003 GET_THREAD_INFO(%ebp)
21004 movl $-EFAULT,PT_EAX(%esp)
21005 jmp resume_userspace
21006 -END(syscall_fault)
21007 +ENDPROC(syscall_fault)
21008
21009 syscall_badsys:
21010 movl $-ENOSYS,PT_EAX(%esp)
21011 jmp resume_userspace
21012 -END(syscall_badsys)
21013 +ENDPROC(syscall_badsys)
21014 CFI_ENDPROC
21015 /*
21016 * End of kprobes section
21017 @@ -708,8 +940,15 @@ END(syscall_badsys)
21018 * normal stack and adjusts ESP with the matching offset.
21019 */
21020 /* fixup the stack */
21021 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21022 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21023 +#ifdef CONFIG_SMP
21024 + movl PER_CPU_VAR(cpu_number), %ebx
21025 + shll $PAGE_SHIFT_asm, %ebx
21026 + addl $cpu_gdt_table, %ebx
21027 +#else
21028 + movl $cpu_gdt_table, %ebx
21029 +#endif
21030 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21031 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21032 shl $16, %eax
21033 addl %esp, %eax /* the adjusted stack pointer */
21034 pushl_cfi $__KERNEL_DS
21035 @@ -762,7 +1001,7 @@ vector=vector+1
21036 .endr
21037 2: jmp common_interrupt
21038 .endr
21039 -END(irq_entries_start)
21040 +ENDPROC(irq_entries_start)
21041
21042 .previous
21043 END(interrupt)
21044 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21045 pushl_cfi $do_coprocessor_error
21046 jmp error_code
21047 CFI_ENDPROC
21048 -END(coprocessor_error)
21049 +ENDPROC(coprocessor_error)
21050
21051 ENTRY(simd_coprocessor_error)
21052 RING0_INT_FRAME
21053 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21054 .section .altinstructions,"a"
21055 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21056 .previous
21057 -.section .altinstr_replacement,"ax"
21058 +.section .altinstr_replacement,"a"
21059 663: pushl $do_simd_coprocessor_error
21060 664:
21061 .previous
21062 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21063 #endif
21064 jmp error_code
21065 CFI_ENDPROC
21066 -END(simd_coprocessor_error)
21067 +ENDPROC(simd_coprocessor_error)
21068
21069 ENTRY(device_not_available)
21070 RING0_INT_FRAME
21071 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21072 pushl_cfi $do_device_not_available
21073 jmp error_code
21074 CFI_ENDPROC
21075 -END(device_not_available)
21076 +ENDPROC(device_not_available)
21077
21078 #ifdef CONFIG_PARAVIRT
21079 ENTRY(native_iret)
21080 iret
21081 _ASM_EXTABLE(native_iret, iret_exc)
21082 -END(native_iret)
21083 +ENDPROC(native_iret)
21084
21085 ENTRY(native_irq_enable_sysexit)
21086 sti
21087 sysexit
21088 -END(native_irq_enable_sysexit)
21089 +ENDPROC(native_irq_enable_sysexit)
21090 #endif
21091
21092 ENTRY(overflow)
21093 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21094 pushl_cfi $do_overflow
21095 jmp error_code
21096 CFI_ENDPROC
21097 -END(overflow)
21098 +ENDPROC(overflow)
21099
21100 ENTRY(bounds)
21101 RING0_INT_FRAME
21102 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21103 pushl_cfi $do_bounds
21104 jmp error_code
21105 CFI_ENDPROC
21106 -END(bounds)
21107 +ENDPROC(bounds)
21108
21109 ENTRY(invalid_op)
21110 RING0_INT_FRAME
21111 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21112 pushl_cfi $do_invalid_op
21113 jmp error_code
21114 CFI_ENDPROC
21115 -END(invalid_op)
21116 +ENDPROC(invalid_op)
21117
21118 ENTRY(coprocessor_segment_overrun)
21119 RING0_INT_FRAME
21120 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21121 pushl_cfi $do_coprocessor_segment_overrun
21122 jmp error_code
21123 CFI_ENDPROC
21124 -END(coprocessor_segment_overrun)
21125 +ENDPROC(coprocessor_segment_overrun)
21126
21127 ENTRY(invalid_TSS)
21128 RING0_EC_FRAME
21129 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21130 pushl_cfi $do_invalid_TSS
21131 jmp error_code
21132 CFI_ENDPROC
21133 -END(invalid_TSS)
21134 +ENDPROC(invalid_TSS)
21135
21136 ENTRY(segment_not_present)
21137 RING0_EC_FRAME
21138 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21139 pushl_cfi $do_segment_not_present
21140 jmp error_code
21141 CFI_ENDPROC
21142 -END(segment_not_present)
21143 +ENDPROC(segment_not_present)
21144
21145 ENTRY(stack_segment)
21146 RING0_EC_FRAME
21147 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21148 pushl_cfi $do_stack_segment
21149 jmp error_code
21150 CFI_ENDPROC
21151 -END(stack_segment)
21152 +ENDPROC(stack_segment)
21153
21154 ENTRY(alignment_check)
21155 RING0_EC_FRAME
21156 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21157 pushl_cfi $do_alignment_check
21158 jmp error_code
21159 CFI_ENDPROC
21160 -END(alignment_check)
21161 +ENDPROC(alignment_check)
21162
21163 ENTRY(divide_error)
21164 RING0_INT_FRAME
21165 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21166 pushl_cfi $do_divide_error
21167 jmp error_code
21168 CFI_ENDPROC
21169 -END(divide_error)
21170 +ENDPROC(divide_error)
21171
21172 #ifdef CONFIG_X86_MCE
21173 ENTRY(machine_check)
21174 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21175 pushl_cfi machine_check_vector
21176 jmp error_code
21177 CFI_ENDPROC
21178 -END(machine_check)
21179 +ENDPROC(machine_check)
21180 #endif
21181
21182 ENTRY(spurious_interrupt_bug)
21183 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21184 pushl_cfi $do_spurious_interrupt_bug
21185 jmp error_code
21186 CFI_ENDPROC
21187 -END(spurious_interrupt_bug)
21188 +ENDPROC(spurious_interrupt_bug)
21189 /*
21190 * End of kprobes section
21191 */
21192 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21193
21194 ENTRY(mcount)
21195 ret
21196 -END(mcount)
21197 +ENDPROC(mcount)
21198
21199 ENTRY(ftrace_caller)
21200 cmpl $0, function_trace_stop
21201 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21202 .globl ftrace_stub
21203 ftrace_stub:
21204 ret
21205 -END(ftrace_caller)
21206 +ENDPROC(ftrace_caller)
21207
21208 ENTRY(ftrace_regs_caller)
21209 pushf /* push flags before compare (in cs location) */
21210 @@ -1210,7 +1449,7 @@ trace:
21211 popl %ecx
21212 popl %eax
21213 jmp ftrace_stub
21214 -END(mcount)
21215 +ENDPROC(mcount)
21216 #endif /* CONFIG_DYNAMIC_FTRACE */
21217 #endif /* CONFIG_FUNCTION_TRACER */
21218
21219 @@ -1228,7 +1467,7 @@ ENTRY(ftrace_graph_caller)
21220 popl %ecx
21221 popl %eax
21222 ret
21223 -END(ftrace_graph_caller)
21224 +ENDPROC(ftrace_graph_caller)
21225
21226 .globl return_to_handler
21227 return_to_handler:
21228 @@ -1284,15 +1523,18 @@ error_code:
21229 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21230 REG_TO_PTGS %ecx
21231 SET_KERNEL_GS %ecx
21232 - movl $(__USER_DS), %ecx
21233 + movl $(__KERNEL_DS), %ecx
21234 movl %ecx, %ds
21235 movl %ecx, %es
21236 +
21237 + pax_enter_kernel
21238 +
21239 TRACE_IRQS_OFF
21240 movl %esp,%eax # pt_regs pointer
21241 call *%edi
21242 jmp ret_from_exception
21243 CFI_ENDPROC
21244 -END(page_fault)
21245 +ENDPROC(page_fault)
21246
21247 /*
21248 * Debug traps and NMI can happen at the one SYSENTER instruction
21249 @@ -1335,7 +1577,7 @@ debug_stack_correct:
21250 call do_debug
21251 jmp ret_from_exception
21252 CFI_ENDPROC
21253 -END(debug)
21254 +ENDPROC(debug)
21255
21256 /*
21257 * NMI is doubly nasty. It can happen _while_ we're handling
21258 @@ -1373,6 +1615,9 @@ nmi_stack_correct:
21259 xorl %edx,%edx # zero error code
21260 movl %esp,%eax # pt_regs pointer
21261 call do_nmi
21262 +
21263 + pax_exit_kernel
21264 +
21265 jmp restore_all_notrace
21266 CFI_ENDPROC
21267
21268 @@ -1409,12 +1654,15 @@ nmi_espfix_stack:
21269 FIXUP_ESPFIX_STACK # %eax == %esp
21270 xorl %edx,%edx # zero error code
21271 call do_nmi
21272 +
21273 + pax_exit_kernel
21274 +
21275 RESTORE_REGS
21276 lss 12+4(%esp), %esp # back to espfix stack
21277 CFI_ADJUST_CFA_OFFSET -24
21278 jmp irq_return
21279 CFI_ENDPROC
21280 -END(nmi)
21281 +ENDPROC(nmi)
21282
21283 ENTRY(int3)
21284 RING0_INT_FRAME
21285 @@ -1427,14 +1675,14 @@ ENTRY(int3)
21286 call do_int3
21287 jmp ret_from_exception
21288 CFI_ENDPROC
21289 -END(int3)
21290 +ENDPROC(int3)
21291
21292 ENTRY(general_protection)
21293 RING0_EC_FRAME
21294 pushl_cfi $do_general_protection
21295 jmp error_code
21296 CFI_ENDPROC
21297 -END(general_protection)
21298 +ENDPROC(general_protection)
21299
21300 #ifdef CONFIG_KVM_GUEST
21301 ENTRY(async_page_fault)
21302 @@ -1443,7 +1691,7 @@ ENTRY(async_page_fault)
21303 pushl_cfi $do_async_page_fault
21304 jmp error_code
21305 CFI_ENDPROC
21306 -END(async_page_fault)
21307 +ENDPROC(async_page_fault)
21308 #endif
21309
21310 /*
21311 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21312 index b077f4c..feb26c1 100644
21313 --- a/arch/x86/kernel/entry_64.S
21314 +++ b/arch/x86/kernel/entry_64.S
21315 @@ -59,6 +59,8 @@
21316 #include <asm/context_tracking.h>
21317 #include <asm/smap.h>
21318 #include <linux/err.h>
21319 +#include <asm/pgtable.h>
21320 +#include <asm/alternative-asm.h>
21321
21322 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21323 #include <linux/elf-em.h>
21324 @@ -80,8 +82,9 @@
21325 #ifdef CONFIG_DYNAMIC_FTRACE
21326
21327 ENTRY(function_hook)
21328 + pax_force_retaddr
21329 retq
21330 -END(function_hook)
21331 +ENDPROC(function_hook)
21332
21333 /* skip is set if stack has been adjusted */
21334 .macro ftrace_caller_setup skip=0
21335 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21336 #endif
21337
21338 GLOBAL(ftrace_stub)
21339 + pax_force_retaddr
21340 retq
21341 -END(ftrace_caller)
21342 +ENDPROC(ftrace_caller)
21343
21344 ENTRY(ftrace_regs_caller)
21345 /* Save the current flags before compare (in SS location)*/
21346 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21347 popfq
21348 jmp ftrace_stub
21349
21350 -END(ftrace_regs_caller)
21351 +ENDPROC(ftrace_regs_caller)
21352
21353
21354 #else /* ! CONFIG_DYNAMIC_FTRACE */
21355 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21356 #endif
21357
21358 GLOBAL(ftrace_stub)
21359 + pax_force_retaddr
21360 retq
21361
21362 trace:
21363 @@ -225,12 +230,13 @@ trace:
21364 #endif
21365 subq $MCOUNT_INSN_SIZE, %rdi
21366
21367 + pax_force_fptr ftrace_trace_function
21368 call *ftrace_trace_function
21369
21370 MCOUNT_RESTORE_FRAME
21371
21372 jmp ftrace_stub
21373 -END(function_hook)
21374 +ENDPROC(function_hook)
21375 #endif /* CONFIG_DYNAMIC_FTRACE */
21376 #endif /* CONFIG_FUNCTION_TRACER */
21377
21378 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21379
21380 MCOUNT_RESTORE_FRAME
21381
21382 + pax_force_retaddr
21383 retq
21384 -END(ftrace_graph_caller)
21385 +ENDPROC(ftrace_graph_caller)
21386
21387 GLOBAL(return_to_handler)
21388 subq $24, %rsp
21389 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21390 movq 8(%rsp), %rdx
21391 movq (%rsp), %rax
21392 addq $24, %rsp
21393 + pax_force_fptr %rdi
21394 jmp *%rdi
21395 +ENDPROC(return_to_handler)
21396 #endif
21397
21398
21399 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21400 ENDPROC(native_usergs_sysret64)
21401 #endif /* CONFIG_PARAVIRT */
21402
21403 + .macro ljmpq sel, off
21404 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21405 + .byte 0x48; ljmp *1234f(%rip)
21406 + .pushsection .rodata
21407 + .align 16
21408 + 1234: .quad \off; .word \sel
21409 + .popsection
21410 +#else
21411 + pushq $\sel
21412 + pushq $\off
21413 + lretq
21414 +#endif
21415 + .endm
21416 +
21417 + .macro pax_enter_kernel
21418 + pax_set_fptr_mask
21419 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21420 + call pax_enter_kernel
21421 +#endif
21422 + .endm
21423 +
21424 + .macro pax_exit_kernel
21425 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21426 + call pax_exit_kernel
21427 +#endif
21428 +
21429 + .endm
21430 +
21431 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21432 +ENTRY(pax_enter_kernel)
21433 + pushq %rdi
21434 +
21435 +#ifdef CONFIG_PARAVIRT
21436 + PV_SAVE_REGS(CLBR_RDI)
21437 +#endif
21438 +
21439 +#ifdef CONFIG_PAX_KERNEXEC
21440 + GET_CR0_INTO_RDI
21441 + bts $16,%rdi
21442 + jnc 3f
21443 + mov %cs,%edi
21444 + cmp $__KERNEL_CS,%edi
21445 + jnz 2f
21446 +1:
21447 +#endif
21448 +
21449 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21450 + 661: jmp 111f
21451 + .pushsection .altinstr_replacement, "a"
21452 + 662: ASM_NOP2
21453 + .popsection
21454 + .pushsection .altinstructions, "a"
21455 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21456 + .popsection
21457 + GET_CR3_INTO_RDI
21458 + cmp $0,%dil
21459 + jnz 112f
21460 + mov $__KERNEL_DS,%edi
21461 + mov %edi,%ss
21462 + jmp 111f
21463 +112: cmp $1,%dil
21464 + jz 113f
21465 + ud2
21466 +113: sub $4097,%rdi
21467 + bts $63,%rdi
21468 + SET_RDI_INTO_CR3
21469 + mov $__UDEREF_KERNEL_DS,%edi
21470 + mov %edi,%ss
21471 +111:
21472 +#endif
21473 +
21474 +#ifdef CONFIG_PARAVIRT
21475 + PV_RESTORE_REGS(CLBR_RDI)
21476 +#endif
21477 +
21478 + popq %rdi
21479 + pax_force_retaddr
21480 + retq
21481 +
21482 +#ifdef CONFIG_PAX_KERNEXEC
21483 +2: ljmpq __KERNEL_CS,1b
21484 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21485 +4: SET_RDI_INTO_CR0
21486 + jmp 1b
21487 +#endif
21488 +ENDPROC(pax_enter_kernel)
21489 +
21490 +ENTRY(pax_exit_kernel)
21491 + pushq %rdi
21492 +
21493 +#ifdef CONFIG_PARAVIRT
21494 + PV_SAVE_REGS(CLBR_RDI)
21495 +#endif
21496 +
21497 +#ifdef CONFIG_PAX_KERNEXEC
21498 + mov %cs,%rdi
21499 + cmp $__KERNEXEC_KERNEL_CS,%edi
21500 + jz 2f
21501 + GET_CR0_INTO_RDI
21502 + bts $16,%rdi
21503 + jnc 4f
21504 +1:
21505 +#endif
21506 +
21507 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21508 + 661: jmp 111f
21509 + .pushsection .altinstr_replacement, "a"
21510 + 662: ASM_NOP2
21511 + .popsection
21512 + .pushsection .altinstructions, "a"
21513 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21514 + .popsection
21515 + mov %ss,%edi
21516 + cmp $__UDEREF_KERNEL_DS,%edi
21517 + jnz 111f
21518 + GET_CR3_INTO_RDI
21519 + cmp $0,%dil
21520 + jz 112f
21521 + ud2
21522 +112: add $4097,%rdi
21523 + bts $63,%rdi
21524 + SET_RDI_INTO_CR3
21525 + mov $__KERNEL_DS,%edi
21526 + mov %edi,%ss
21527 +111:
21528 +#endif
21529 +
21530 +#ifdef CONFIG_PARAVIRT
21531 + PV_RESTORE_REGS(CLBR_RDI);
21532 +#endif
21533 +
21534 + popq %rdi
21535 + pax_force_retaddr
21536 + retq
21537 +
21538 +#ifdef CONFIG_PAX_KERNEXEC
21539 +2: GET_CR0_INTO_RDI
21540 + btr $16,%rdi
21541 + jnc 4f
21542 + ljmpq __KERNEL_CS,3f
21543 +3: SET_RDI_INTO_CR0
21544 + jmp 1b
21545 +4: ud2
21546 + jmp 4b
21547 +#endif
21548 +ENDPROC(pax_exit_kernel)
21549 +#endif
21550 +
21551 + .macro pax_enter_kernel_user
21552 + pax_set_fptr_mask
21553 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21554 + call pax_enter_kernel_user
21555 +#endif
21556 + .endm
21557 +
21558 + .macro pax_exit_kernel_user
21559 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21560 + call pax_exit_kernel_user
21561 +#endif
21562 +#ifdef CONFIG_PAX_RANDKSTACK
21563 + pushq %rax
21564 + pushq %r11
21565 + call pax_randomize_kstack
21566 + popq %r11
21567 + popq %rax
21568 +#endif
21569 + .endm
21570 +
21571 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21572 +ENTRY(pax_enter_kernel_user)
21573 + pushq %rdi
21574 + pushq %rbx
21575 +
21576 +#ifdef CONFIG_PARAVIRT
21577 + PV_SAVE_REGS(CLBR_RDI)
21578 +#endif
21579 +
21580 + 661: jmp 111f
21581 + .pushsection .altinstr_replacement, "a"
21582 + 662: ASM_NOP2
21583 + .popsection
21584 + .pushsection .altinstructions, "a"
21585 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21586 + .popsection
21587 + GET_CR3_INTO_RDI
21588 + cmp $1,%dil
21589 + jnz 4f
21590 + sub $4097,%rdi
21591 + bts $63,%rdi
21592 + SET_RDI_INTO_CR3
21593 + jmp 3f
21594 +111:
21595 +
21596 + GET_CR3_INTO_RDI
21597 + mov %rdi,%rbx
21598 + add $__START_KERNEL_map,%rbx
21599 + sub phys_base(%rip),%rbx
21600 +
21601 +#ifdef CONFIG_PARAVIRT
21602 + cmpl $0, pv_info+PARAVIRT_enabled
21603 + jz 1f
21604 + pushq %rdi
21605 + i = 0
21606 + .rept USER_PGD_PTRS
21607 + mov i*8(%rbx),%rsi
21608 + mov $0,%sil
21609 + lea i*8(%rbx),%rdi
21610 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21611 + i = i + 1
21612 + .endr
21613 + popq %rdi
21614 + jmp 2f
21615 +1:
21616 +#endif
21617 +
21618 + i = 0
21619 + .rept USER_PGD_PTRS
21620 + movb $0,i*8(%rbx)
21621 + i = i + 1
21622 + .endr
21623 +
21624 +2: SET_RDI_INTO_CR3
21625 +
21626 +#ifdef CONFIG_PAX_KERNEXEC
21627 + GET_CR0_INTO_RDI
21628 + bts $16,%rdi
21629 + SET_RDI_INTO_CR0
21630 +#endif
21631 +
21632 +3:
21633 +
21634 +#ifdef CONFIG_PARAVIRT
21635 + PV_RESTORE_REGS(CLBR_RDI)
21636 +#endif
21637 +
21638 + popq %rbx
21639 + popq %rdi
21640 + pax_force_retaddr
21641 + retq
21642 +4: ud2
21643 +ENDPROC(pax_enter_kernel_user)
21644 +
21645 +ENTRY(pax_exit_kernel_user)
21646 + pushq %rdi
21647 + pushq %rbx
21648 +
21649 +#ifdef CONFIG_PARAVIRT
21650 + PV_SAVE_REGS(CLBR_RDI)
21651 +#endif
21652 +
21653 + GET_CR3_INTO_RDI
21654 + 661: jmp 1f
21655 + .pushsection .altinstr_replacement, "a"
21656 + 662: ASM_NOP2
21657 + .popsection
21658 + .pushsection .altinstructions, "a"
21659 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21660 + .popsection
21661 + cmp $0,%dil
21662 + jnz 3f
21663 + add $4097,%rdi
21664 + bts $63,%rdi
21665 + SET_RDI_INTO_CR3
21666 + jmp 2f
21667 +1:
21668 +
21669 + mov %rdi,%rbx
21670 +
21671 +#ifdef CONFIG_PAX_KERNEXEC
21672 + GET_CR0_INTO_RDI
21673 + btr $16,%rdi
21674 + jnc 3f
21675 + SET_RDI_INTO_CR0
21676 +#endif
21677 +
21678 + add $__START_KERNEL_map,%rbx
21679 + sub phys_base(%rip),%rbx
21680 +
21681 +#ifdef CONFIG_PARAVIRT
21682 + cmpl $0, pv_info+PARAVIRT_enabled
21683 + jz 1f
21684 + i = 0
21685 + .rept USER_PGD_PTRS
21686 + mov i*8(%rbx),%rsi
21687 + mov $0x67,%sil
21688 + lea i*8(%rbx),%rdi
21689 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21690 + i = i + 1
21691 + .endr
21692 + jmp 2f
21693 +1:
21694 +#endif
21695 +
21696 + i = 0
21697 + .rept USER_PGD_PTRS
21698 + movb $0x67,i*8(%rbx)
21699 + i = i + 1
21700 + .endr
21701 +2:
21702 +
21703 +#ifdef CONFIG_PARAVIRT
21704 + PV_RESTORE_REGS(CLBR_RDI)
21705 +#endif
21706 +
21707 + popq %rbx
21708 + popq %rdi
21709 + pax_force_retaddr
21710 + retq
21711 +3: ud2
21712 +ENDPROC(pax_exit_kernel_user)
21713 +#endif
21714 +
21715 + .macro pax_enter_kernel_nmi
21716 + pax_set_fptr_mask
21717 +
21718 +#ifdef CONFIG_PAX_KERNEXEC
21719 + GET_CR0_INTO_RDI
21720 + bts $16,%rdi
21721 + jc 110f
21722 + SET_RDI_INTO_CR0
21723 + or $2,%ebx
21724 +110:
21725 +#endif
21726 +
21727 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21728 + 661: jmp 111f
21729 + .pushsection .altinstr_replacement, "a"
21730 + 662: ASM_NOP2
21731 + .popsection
21732 + .pushsection .altinstructions, "a"
21733 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21734 + .popsection
21735 + GET_CR3_INTO_RDI
21736 + cmp $0,%dil
21737 + jz 111f
21738 + sub $4097,%rdi
21739 + or $4,%ebx
21740 + bts $63,%rdi
21741 + SET_RDI_INTO_CR3
21742 + mov $__UDEREF_KERNEL_DS,%edi
21743 + mov %edi,%ss
21744 +111:
21745 +#endif
21746 + .endm
21747 +
21748 + .macro pax_exit_kernel_nmi
21749 +#ifdef CONFIG_PAX_KERNEXEC
21750 + btr $1,%ebx
21751 + jnc 110f
21752 + GET_CR0_INTO_RDI
21753 + btr $16,%rdi
21754 + SET_RDI_INTO_CR0
21755 +110:
21756 +#endif
21757 +
21758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21759 + btr $2,%ebx
21760 + jnc 111f
21761 + GET_CR3_INTO_RDI
21762 + add $4097,%rdi
21763 + bts $63,%rdi
21764 + SET_RDI_INTO_CR3
21765 + mov $__KERNEL_DS,%edi
21766 + mov %edi,%ss
21767 +111:
21768 +#endif
21769 + .endm
21770 +
21771 + .macro pax_erase_kstack
21772 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21773 + call pax_erase_kstack
21774 +#endif
21775 + .endm
21776 +
21777 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21778 +ENTRY(pax_erase_kstack)
21779 + pushq %rdi
21780 + pushq %rcx
21781 + pushq %rax
21782 + pushq %r11
21783 +
21784 + GET_THREAD_INFO(%r11)
21785 + mov TI_lowest_stack(%r11), %rdi
21786 + mov $-0xBEEF, %rax
21787 + std
21788 +
21789 +1: mov %edi, %ecx
21790 + and $THREAD_SIZE_asm - 1, %ecx
21791 + shr $3, %ecx
21792 + repne scasq
21793 + jecxz 2f
21794 +
21795 + cmp $2*8, %ecx
21796 + jc 2f
21797 +
21798 + mov $2*8, %ecx
21799 + repe scasq
21800 + jecxz 2f
21801 + jne 1b
21802 +
21803 +2: cld
21804 + mov %esp, %ecx
21805 + sub %edi, %ecx
21806 +
21807 + cmp $THREAD_SIZE_asm, %rcx
21808 + jb 3f
21809 + ud2
21810 +3:
21811 +
21812 + shr $3, %ecx
21813 + rep stosq
21814 +
21815 + mov TI_task_thread_sp0(%r11), %rdi
21816 + sub $256, %rdi
21817 + mov %rdi, TI_lowest_stack(%r11)
21818 +
21819 + popq %r11
21820 + popq %rax
21821 + popq %rcx
21822 + popq %rdi
21823 + pax_force_retaddr
21824 + ret
21825 +ENDPROC(pax_erase_kstack)
21826 +#endif
21827
21828 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21829 #ifdef CONFIG_TRACE_IRQFLAGS
21830 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21831 .endm
21832
21833 .macro UNFAKE_STACK_FRAME
21834 - addq $8*6, %rsp
21835 - CFI_ADJUST_CFA_OFFSET -(6*8)
21836 + addq $8*6 + ARG_SKIP, %rsp
21837 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21838 .endm
21839
21840 /*
21841 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21842 movq %rsp, %rsi
21843
21844 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21845 - testl $3, CS-RBP(%rsi)
21846 + testb $3, CS-RBP(%rsi)
21847 je 1f
21848 SWAPGS
21849 /*
21850 @@ -514,9 +947,10 @@ ENTRY(save_paranoid)
21851 js 1f /* negative -> in kernel */
21852 SWAPGS
21853 xorl %ebx,%ebx
21854 -1: ret
21855 +1: pax_force_retaddr_bts
21856 + ret
21857 CFI_ENDPROC
21858 -END(save_paranoid)
21859 +ENDPROC(save_paranoid)
21860 .popsection
21861
21862 /*
21863 @@ -538,7 +972,7 @@ ENTRY(ret_from_fork)
21864
21865 RESTORE_REST
21866
21867 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21868 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21869 jz 1f
21870
21871 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21872 @@ -556,7 +990,7 @@ ENTRY(ret_from_fork)
21873 RESTORE_REST
21874 jmp int_ret_from_sys_call
21875 CFI_ENDPROC
21876 -END(ret_from_fork)
21877 +ENDPROC(ret_from_fork)
21878
21879 /*
21880 * System call entry. Up to 6 arguments in registers are supported.
21881 @@ -593,7 +1027,7 @@ END(ret_from_fork)
21882 ENTRY(system_call)
21883 CFI_STARTPROC simple
21884 CFI_SIGNAL_FRAME
21885 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21886 + CFI_DEF_CFA rsp,0
21887 CFI_REGISTER rip,rcx
21888 /*CFI_REGISTER rflags,r11*/
21889 SWAPGS_UNSAFE_STACK
21890 @@ -606,16 +1040,23 @@ GLOBAL(system_call_after_swapgs)
21891
21892 movq %rsp,PER_CPU_VAR(old_rsp)
21893 movq PER_CPU_VAR(kernel_stack),%rsp
21894 + SAVE_ARGS 8*6,0
21895 + pax_enter_kernel_user
21896 +
21897 +#ifdef CONFIG_PAX_RANDKSTACK
21898 + pax_erase_kstack
21899 +#endif
21900 +
21901 /*
21902 * No need to follow this irqs off/on section - it's straight
21903 * and short:
21904 */
21905 ENABLE_INTERRUPTS(CLBR_NONE)
21906 - SAVE_ARGS 8,0
21907 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21908 movq %rcx,RIP-ARGOFFSET(%rsp)
21909 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21910 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21911 + GET_THREAD_INFO(%rcx)
21912 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21913 jnz tracesys
21914 system_call_fastpath:
21915 #if __SYSCALL_MASK == ~0
21916 @@ -625,7 +1066,7 @@ system_call_fastpath:
21917 cmpl $__NR_syscall_max,%eax
21918 #endif
21919 ja badsys
21920 - movq %r10,%rcx
21921 + movq R10-ARGOFFSET(%rsp),%rcx
21922 call *sys_call_table(,%rax,8) # XXX: rip relative
21923 movq %rax,RAX-ARGOFFSET(%rsp)
21924 /*
21925 @@ -639,10 +1080,13 @@ sysret_check:
21926 LOCKDEP_SYS_EXIT
21927 DISABLE_INTERRUPTS(CLBR_NONE)
21928 TRACE_IRQS_OFF
21929 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21930 + GET_THREAD_INFO(%rcx)
21931 + movl TI_flags(%rcx),%edx
21932 andl %edi,%edx
21933 jnz sysret_careful
21934 CFI_REMEMBER_STATE
21935 + pax_exit_kernel_user
21936 + pax_erase_kstack
21937 /*
21938 * sysretq will re-enable interrupts:
21939 */
21940 @@ -694,14 +1138,18 @@ badsys:
21941 * jump back to the normal fast path.
21942 */
21943 auditsys:
21944 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21945 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21946 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21947 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21948 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21949 movq %rax,%rsi /* 2nd arg: syscall number */
21950 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21951 call __audit_syscall_entry
21952 +
21953 + pax_erase_kstack
21954 +
21955 LOAD_ARGS 0 /* reload call-clobbered registers */
21956 + pax_set_fptr_mask
21957 jmp system_call_fastpath
21958
21959 /*
21960 @@ -722,7 +1170,7 @@ sysret_audit:
21961 /* Do syscall tracing */
21962 tracesys:
21963 #ifdef CONFIG_AUDITSYSCALL
21964 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21965 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21966 jz auditsys
21967 #endif
21968 SAVE_REST
21969 @@ -730,12 +1178,16 @@ tracesys:
21970 FIXUP_TOP_OF_STACK %rdi
21971 movq %rsp,%rdi
21972 call syscall_trace_enter
21973 +
21974 + pax_erase_kstack
21975 +
21976 /*
21977 * Reload arg registers from stack in case ptrace changed them.
21978 * We don't reload %rax because syscall_trace_enter() returned
21979 * the value it wants us to use in the table lookup.
21980 */
21981 LOAD_ARGS ARGOFFSET, 1
21982 + pax_set_fptr_mask
21983 RESTORE_REST
21984 #if __SYSCALL_MASK == ~0
21985 cmpq $__NR_syscall_max,%rax
21986 @@ -744,7 +1196,7 @@ tracesys:
21987 cmpl $__NR_syscall_max,%eax
21988 #endif
21989 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21990 - movq %r10,%rcx /* fixup for C */
21991 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21992 call *sys_call_table(,%rax,8)
21993 movq %rax,RAX-ARGOFFSET(%rsp)
21994 /* Use IRET because user could have changed frame */
21995 @@ -765,7 +1217,9 @@ GLOBAL(int_with_check)
21996 andl %edi,%edx
21997 jnz int_careful
21998 andl $~TS_COMPAT,TI_status(%rcx)
21999 - jmp retint_swapgs
22000 + pax_exit_kernel_user
22001 + pax_erase_kstack
22002 + jmp retint_swapgs_pax
22003
22004 /* Either reschedule or signal or syscall exit tracking needed. */
22005 /* First do a reschedule test. */
22006 @@ -811,7 +1265,7 @@ int_restore_rest:
22007 TRACE_IRQS_OFF
22008 jmp int_with_check
22009 CFI_ENDPROC
22010 -END(system_call)
22011 +ENDPROC(system_call)
22012
22013 .macro FORK_LIKE func
22014 ENTRY(stub_\func)
22015 @@ -824,9 +1278,10 @@ ENTRY(stub_\func)
22016 DEFAULT_FRAME 0 8 /* offset 8: return address */
22017 call sys_\func
22018 RESTORE_TOP_OF_STACK %r11, 8
22019 + pax_force_retaddr
22020 ret $REST_SKIP /* pop extended registers */
22021 CFI_ENDPROC
22022 -END(stub_\func)
22023 +ENDPROC(stub_\func)
22024 .endm
22025
22026 .macro FIXED_FRAME label,func
22027 @@ -836,9 +1291,10 @@ ENTRY(\label)
22028 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22029 call \func
22030 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22031 + pax_force_retaddr
22032 ret
22033 CFI_ENDPROC
22034 -END(\label)
22035 +ENDPROC(\label)
22036 .endm
22037
22038 FORK_LIKE clone
22039 @@ -855,9 +1311,10 @@ ENTRY(ptregscall_common)
22040 movq_cfi_restore R12+8, r12
22041 movq_cfi_restore RBP+8, rbp
22042 movq_cfi_restore RBX+8, rbx
22043 + pax_force_retaddr
22044 ret $REST_SKIP /* pop extended registers */
22045 CFI_ENDPROC
22046 -END(ptregscall_common)
22047 +ENDPROC(ptregscall_common)
22048
22049 ENTRY(stub_execve)
22050 CFI_STARTPROC
22051 @@ -870,7 +1327,7 @@ ENTRY(stub_execve)
22052 RESTORE_REST
22053 jmp int_ret_from_sys_call
22054 CFI_ENDPROC
22055 -END(stub_execve)
22056 +ENDPROC(stub_execve)
22057
22058 /*
22059 * sigreturn is special because it needs to restore all registers on return.
22060 @@ -887,7 +1344,7 @@ ENTRY(stub_rt_sigreturn)
22061 RESTORE_REST
22062 jmp int_ret_from_sys_call
22063 CFI_ENDPROC
22064 -END(stub_rt_sigreturn)
22065 +ENDPROC(stub_rt_sigreturn)
22066
22067 #ifdef CONFIG_X86_X32_ABI
22068 ENTRY(stub_x32_rt_sigreturn)
22069 @@ -901,7 +1358,7 @@ ENTRY(stub_x32_rt_sigreturn)
22070 RESTORE_REST
22071 jmp int_ret_from_sys_call
22072 CFI_ENDPROC
22073 -END(stub_x32_rt_sigreturn)
22074 +ENDPROC(stub_x32_rt_sigreturn)
22075
22076 ENTRY(stub_x32_execve)
22077 CFI_STARTPROC
22078 @@ -915,7 +1372,7 @@ ENTRY(stub_x32_execve)
22079 RESTORE_REST
22080 jmp int_ret_from_sys_call
22081 CFI_ENDPROC
22082 -END(stub_x32_execve)
22083 +ENDPROC(stub_x32_execve)
22084
22085 #endif
22086
22087 @@ -952,7 +1409,7 @@ vector=vector+1
22088 2: jmp common_interrupt
22089 .endr
22090 CFI_ENDPROC
22091 -END(irq_entries_start)
22092 +ENDPROC(irq_entries_start)
22093
22094 .previous
22095 END(interrupt)
22096 @@ -972,6 +1429,16 @@ END(interrupt)
22097 subq $ORIG_RAX-RBP, %rsp
22098 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22099 SAVE_ARGS_IRQ
22100 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22101 + testb $3, CS(%rdi)
22102 + jnz 1f
22103 + pax_enter_kernel
22104 + jmp 2f
22105 +1: pax_enter_kernel_user
22106 +2:
22107 +#else
22108 + pax_enter_kernel
22109 +#endif
22110 call \func
22111 .endm
22112
22113 @@ -1004,7 +1471,7 @@ ret_from_intr:
22114
22115 exit_intr:
22116 GET_THREAD_INFO(%rcx)
22117 - testl $3,CS-ARGOFFSET(%rsp)
22118 + testb $3,CS-ARGOFFSET(%rsp)
22119 je retint_kernel
22120
22121 /* Interrupt came from user space */
22122 @@ -1026,12 +1493,16 @@ retint_swapgs: /* return to user-space */
22123 * The iretq could re-enable interrupts:
22124 */
22125 DISABLE_INTERRUPTS(CLBR_ANY)
22126 + pax_exit_kernel_user
22127 +retint_swapgs_pax:
22128 TRACE_IRQS_IRETQ
22129 SWAPGS
22130 jmp restore_args
22131
22132 retint_restore_args: /* return to kernel space */
22133 DISABLE_INTERRUPTS(CLBR_ANY)
22134 + pax_exit_kernel
22135 + pax_force_retaddr (RIP-ARGOFFSET)
22136 /*
22137 * The iretq could re-enable interrupts:
22138 */
22139 @@ -1114,7 +1585,7 @@ ENTRY(retint_kernel)
22140 #endif
22141
22142 CFI_ENDPROC
22143 -END(common_interrupt)
22144 +ENDPROC(common_interrupt)
22145 /*
22146 * End of kprobes section
22147 */
22148 @@ -1132,7 +1603,7 @@ ENTRY(\sym)
22149 interrupt \do_sym
22150 jmp ret_from_intr
22151 CFI_ENDPROC
22152 -END(\sym)
22153 +ENDPROC(\sym)
22154 .endm
22155
22156 #ifdef CONFIG_TRACING
22157 @@ -1215,12 +1686,22 @@ ENTRY(\sym)
22158 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22159 call error_entry
22160 DEFAULT_FRAME 0
22161 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22162 + testb $3, CS(%rsp)
22163 + jnz 1f
22164 + pax_enter_kernel
22165 + jmp 2f
22166 +1: pax_enter_kernel_user
22167 +2:
22168 +#else
22169 + pax_enter_kernel
22170 +#endif
22171 movq %rsp,%rdi /* pt_regs pointer */
22172 xorl %esi,%esi /* no error code */
22173 call \do_sym
22174 jmp error_exit /* %ebx: no swapgs flag */
22175 CFI_ENDPROC
22176 -END(\sym)
22177 +ENDPROC(\sym)
22178 .endm
22179
22180 .macro paranoidzeroentry sym do_sym
22181 @@ -1233,15 +1714,25 @@ ENTRY(\sym)
22182 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22183 call save_paranoid
22184 TRACE_IRQS_OFF
22185 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22186 + testb $3, CS(%rsp)
22187 + jnz 1f
22188 + pax_enter_kernel
22189 + jmp 2f
22190 +1: pax_enter_kernel_user
22191 +2:
22192 +#else
22193 + pax_enter_kernel
22194 +#endif
22195 movq %rsp,%rdi /* pt_regs pointer */
22196 xorl %esi,%esi /* no error code */
22197 call \do_sym
22198 jmp paranoid_exit /* %ebx: no swapgs flag */
22199 CFI_ENDPROC
22200 -END(\sym)
22201 +ENDPROC(\sym)
22202 .endm
22203
22204 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22205 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22206 .macro paranoidzeroentry_ist sym do_sym ist
22207 ENTRY(\sym)
22208 INTR_FRAME
22209 @@ -1252,14 +1743,30 @@ ENTRY(\sym)
22210 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22211 call save_paranoid
22212 TRACE_IRQS_OFF_DEBUG
22213 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22214 + testb $3, CS(%rsp)
22215 + jnz 1f
22216 + pax_enter_kernel
22217 + jmp 2f
22218 +1: pax_enter_kernel_user
22219 +2:
22220 +#else
22221 + pax_enter_kernel
22222 +#endif
22223 movq %rsp,%rdi /* pt_regs pointer */
22224 xorl %esi,%esi /* no error code */
22225 +#ifdef CONFIG_SMP
22226 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22227 + lea init_tss(%r12), %r12
22228 +#else
22229 + lea init_tss(%rip), %r12
22230 +#endif
22231 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22232 call \do_sym
22233 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22234 jmp paranoid_exit /* %ebx: no swapgs flag */
22235 CFI_ENDPROC
22236 -END(\sym)
22237 +ENDPROC(\sym)
22238 .endm
22239
22240 .macro errorentry sym do_sym
22241 @@ -1271,13 +1778,23 @@ ENTRY(\sym)
22242 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22243 call error_entry
22244 DEFAULT_FRAME 0
22245 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22246 + testb $3, CS(%rsp)
22247 + jnz 1f
22248 + pax_enter_kernel
22249 + jmp 2f
22250 +1: pax_enter_kernel_user
22251 +2:
22252 +#else
22253 + pax_enter_kernel
22254 +#endif
22255 movq %rsp,%rdi /* pt_regs pointer */
22256 movq ORIG_RAX(%rsp),%rsi /* get error code */
22257 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22258 call \do_sym
22259 jmp error_exit /* %ebx: no swapgs flag */
22260 CFI_ENDPROC
22261 -END(\sym)
22262 +ENDPROC(\sym)
22263 .endm
22264
22265 /* error code is on the stack already */
22266 @@ -1291,13 +1808,23 @@ ENTRY(\sym)
22267 call save_paranoid
22268 DEFAULT_FRAME 0
22269 TRACE_IRQS_OFF
22270 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22271 + testb $3, CS(%rsp)
22272 + jnz 1f
22273 + pax_enter_kernel
22274 + jmp 2f
22275 +1: pax_enter_kernel_user
22276 +2:
22277 +#else
22278 + pax_enter_kernel
22279 +#endif
22280 movq %rsp,%rdi /* pt_regs pointer */
22281 movq ORIG_RAX(%rsp),%rsi /* get error code */
22282 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22283 call \do_sym
22284 jmp paranoid_exit /* %ebx: no swapgs flag */
22285 CFI_ENDPROC
22286 -END(\sym)
22287 +ENDPROC(\sym)
22288 .endm
22289
22290 zeroentry divide_error do_divide_error
22291 @@ -1327,9 +1854,10 @@ gs_change:
22292 2: mfence /* workaround */
22293 SWAPGS
22294 popfq_cfi
22295 + pax_force_retaddr
22296 ret
22297 CFI_ENDPROC
22298 -END(native_load_gs_index)
22299 +ENDPROC(native_load_gs_index)
22300
22301 _ASM_EXTABLE(gs_change,bad_gs)
22302 .section .fixup,"ax"
22303 @@ -1357,9 +1885,10 @@ ENTRY(call_softirq)
22304 CFI_DEF_CFA_REGISTER rsp
22305 CFI_ADJUST_CFA_OFFSET -8
22306 decl PER_CPU_VAR(irq_count)
22307 + pax_force_retaddr
22308 ret
22309 CFI_ENDPROC
22310 -END(call_softirq)
22311 +ENDPROC(call_softirq)
22312
22313 #ifdef CONFIG_XEN
22314 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22315 @@ -1397,7 +1926,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22316 decl PER_CPU_VAR(irq_count)
22317 jmp error_exit
22318 CFI_ENDPROC
22319 -END(xen_do_hypervisor_callback)
22320 +ENDPROC(xen_do_hypervisor_callback)
22321
22322 /*
22323 * Hypervisor uses this for application faults while it executes.
22324 @@ -1456,7 +1985,7 @@ ENTRY(xen_failsafe_callback)
22325 SAVE_ALL
22326 jmp error_exit
22327 CFI_ENDPROC
22328 -END(xen_failsafe_callback)
22329 +ENDPROC(xen_failsafe_callback)
22330
22331 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22332 xen_hvm_callback_vector xen_evtchn_do_upcall
22333 @@ -1508,18 +2037,33 @@ ENTRY(paranoid_exit)
22334 DEFAULT_FRAME
22335 DISABLE_INTERRUPTS(CLBR_NONE)
22336 TRACE_IRQS_OFF_DEBUG
22337 - testl %ebx,%ebx /* swapgs needed? */
22338 + testl $1,%ebx /* swapgs needed? */
22339 jnz paranoid_restore
22340 - testl $3,CS(%rsp)
22341 + testb $3,CS(%rsp)
22342 jnz paranoid_userspace
22343 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22344 + pax_exit_kernel
22345 + TRACE_IRQS_IRETQ 0
22346 + SWAPGS_UNSAFE_STACK
22347 + RESTORE_ALL 8
22348 + pax_force_retaddr_bts
22349 + jmp irq_return
22350 +#endif
22351 paranoid_swapgs:
22352 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22353 + pax_exit_kernel_user
22354 +#else
22355 + pax_exit_kernel
22356 +#endif
22357 TRACE_IRQS_IRETQ 0
22358 SWAPGS_UNSAFE_STACK
22359 RESTORE_ALL 8
22360 jmp irq_return
22361 paranoid_restore:
22362 + pax_exit_kernel
22363 TRACE_IRQS_IRETQ_DEBUG 0
22364 RESTORE_ALL 8
22365 + pax_force_retaddr_bts
22366 jmp irq_return
22367 paranoid_userspace:
22368 GET_THREAD_INFO(%rcx)
22369 @@ -1548,7 +2092,7 @@ paranoid_schedule:
22370 TRACE_IRQS_OFF
22371 jmp paranoid_userspace
22372 CFI_ENDPROC
22373 -END(paranoid_exit)
22374 +ENDPROC(paranoid_exit)
22375
22376 /*
22377 * Exception entry point. This expects an error code/orig_rax on the stack.
22378 @@ -1575,12 +2119,13 @@ ENTRY(error_entry)
22379 movq_cfi r14, R14+8
22380 movq_cfi r15, R15+8
22381 xorl %ebx,%ebx
22382 - testl $3,CS+8(%rsp)
22383 + testb $3,CS+8(%rsp)
22384 je error_kernelspace
22385 error_swapgs:
22386 SWAPGS
22387 error_sti:
22388 TRACE_IRQS_OFF
22389 + pax_force_retaddr_bts
22390 ret
22391
22392 /*
22393 @@ -1607,7 +2152,7 @@ bstep_iret:
22394 movq %rcx,RIP+8(%rsp)
22395 jmp error_swapgs
22396 CFI_ENDPROC
22397 -END(error_entry)
22398 +ENDPROC(error_entry)
22399
22400
22401 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22402 @@ -1618,7 +2163,7 @@ ENTRY(error_exit)
22403 DISABLE_INTERRUPTS(CLBR_NONE)
22404 TRACE_IRQS_OFF
22405 GET_THREAD_INFO(%rcx)
22406 - testl %eax,%eax
22407 + testl $1,%eax
22408 jne retint_kernel
22409 LOCKDEP_SYS_EXIT_IRQ
22410 movl TI_flags(%rcx),%edx
22411 @@ -1627,7 +2172,7 @@ ENTRY(error_exit)
22412 jnz retint_careful
22413 jmp retint_swapgs
22414 CFI_ENDPROC
22415 -END(error_exit)
22416 +ENDPROC(error_exit)
22417
22418 /*
22419 * Test if a given stack is an NMI stack or not.
22420 @@ -1685,9 +2230,11 @@ ENTRY(nmi)
22421 * If %cs was not the kernel segment, then the NMI triggered in user
22422 * space, which means it is definitely not nested.
22423 */
22424 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22425 + je 1f
22426 cmpl $__KERNEL_CS, 16(%rsp)
22427 jne first_nmi
22428 -
22429 +1:
22430 /*
22431 * Check the special variable on the stack to see if NMIs are
22432 * executing.
22433 @@ -1721,8 +2268,7 @@ nested_nmi:
22434
22435 1:
22436 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22437 - leaq -1*8(%rsp), %rdx
22438 - movq %rdx, %rsp
22439 + subq $8, %rsp
22440 CFI_ADJUST_CFA_OFFSET 1*8
22441 leaq -10*8(%rsp), %rdx
22442 pushq_cfi $__KERNEL_DS
22443 @@ -1740,6 +2286,7 @@ nested_nmi_out:
22444 CFI_RESTORE rdx
22445
22446 /* No need to check faults here */
22447 +# pax_force_retaddr_bts
22448 INTERRUPT_RETURN
22449
22450 CFI_RESTORE_STATE
22451 @@ -1856,6 +2403,8 @@ end_repeat_nmi:
22452 */
22453 movq %cr2, %r12
22454
22455 + pax_enter_kernel_nmi
22456 +
22457 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22458 movq %rsp,%rdi
22459 movq $-1,%rsi
22460 @@ -1868,26 +2417,31 @@ end_repeat_nmi:
22461 movq %r12, %cr2
22462 1:
22463
22464 - testl %ebx,%ebx /* swapgs needed? */
22465 + testl $1,%ebx /* swapgs needed? */
22466 jnz nmi_restore
22467 nmi_swapgs:
22468 SWAPGS_UNSAFE_STACK
22469 nmi_restore:
22470 + pax_exit_kernel_nmi
22471 /* Pop the extra iret frame at once */
22472 RESTORE_ALL 6*8
22473 + testb $3, 8(%rsp)
22474 + jnz 1f
22475 + pax_force_retaddr_bts
22476 +1:
22477
22478 /* Clear the NMI executing stack variable */
22479 movq $0, 5*8(%rsp)
22480 jmp irq_return
22481 CFI_ENDPROC
22482 -END(nmi)
22483 +ENDPROC(nmi)
22484
22485 ENTRY(ignore_sysret)
22486 CFI_STARTPROC
22487 mov $-ENOSYS,%eax
22488 sysret
22489 CFI_ENDPROC
22490 -END(ignore_sysret)
22491 +ENDPROC(ignore_sysret)
22492
22493 /*
22494 * End of kprobes section
22495 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22496 index 42a392a..fbbd930 100644
22497 --- a/arch/x86/kernel/ftrace.c
22498 +++ b/arch/x86/kernel/ftrace.c
22499 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22500 {
22501 unsigned char replaced[MCOUNT_INSN_SIZE];
22502
22503 + ip = ktla_ktva(ip);
22504 +
22505 /*
22506 * Note: Due to modules and __init, code can
22507 * disappear and change, we need to protect against faulting
22508 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22509 unsigned char old[MCOUNT_INSN_SIZE], *new;
22510 int ret;
22511
22512 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22513 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22514 new = ftrace_call_replace(ip, (unsigned long)func);
22515
22516 /* See comment above by declaration of modifying_ftrace_code */
22517 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22518 /* Also update the regs callback function */
22519 if (!ret) {
22520 ip = (unsigned long)(&ftrace_regs_call);
22521 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22522 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22523 new = ftrace_call_replace(ip, (unsigned long)func);
22524 ret = ftrace_modify_code(ip, old, new);
22525 }
22526 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22527 * kernel identity mapping to modify code.
22528 */
22529 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22530 - ip = (unsigned long)__va(__pa_symbol(ip));
22531 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22532
22533 return probe_kernel_write((void *)ip, val, size);
22534 }
22535 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22536 unsigned char replaced[MCOUNT_INSN_SIZE];
22537 unsigned char brk = BREAKPOINT_INSTRUCTION;
22538
22539 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22540 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22541 return -EFAULT;
22542
22543 /* Make sure it is what we expect it to be */
22544 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22545 return ret;
22546
22547 fail_update:
22548 - probe_kernel_write((void *)ip, &old_code[0], 1);
22549 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22550 goto out;
22551 }
22552
22553 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22554 {
22555 unsigned char code[MCOUNT_INSN_SIZE];
22556
22557 + ip = ktla_ktva(ip);
22558 +
22559 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22560 return -EFAULT;
22561
22562 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22563 index 1be8e43..d9b9ef6 100644
22564 --- a/arch/x86/kernel/head64.c
22565 +++ b/arch/x86/kernel/head64.c
22566 @@ -67,12 +67,12 @@ again:
22567 pgd = *pgd_p;
22568
22569 /*
22570 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22571 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22572 + * The use of __early_va rather than __va here is critical:
22573 + * __va would point us back into the dynamic
22574 * range and we might end up looping forever...
22575 */
22576 if (pgd)
22577 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22578 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22579 else {
22580 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22581 reset_early_page_tables();
22582 @@ -82,13 +82,13 @@ again:
22583 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22584 for (i = 0; i < PTRS_PER_PUD; i++)
22585 pud_p[i] = 0;
22586 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22587 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22588 }
22589 pud_p += pud_index(address);
22590 pud = *pud_p;
22591
22592 if (pud)
22593 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22594 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22595 else {
22596 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22597 reset_early_page_tables();
22598 @@ -98,7 +98,7 @@ again:
22599 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22600 for (i = 0; i < PTRS_PER_PMD; i++)
22601 pmd_p[i] = 0;
22602 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22603 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22604 }
22605 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22606 pmd_p[pmd_index(address)] = pmd;
22607 @@ -175,7 +175,6 @@ asmlinkage void __init x86_64_start_kernel(char * real_mode_data)
22608 if (console_loglevel == 10)
22609 early_printk("Kernel alive\n");
22610
22611 - clear_page(init_level4_pgt);
22612 /* set init_level4_pgt kernel high mapping*/
22613 init_level4_pgt[511] = early_level4_pgt[511];
22614
22615 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22616 index 81ba276..30c5411 100644
22617 --- a/arch/x86/kernel/head_32.S
22618 +++ b/arch/x86/kernel/head_32.S
22619 @@ -26,6 +26,12 @@
22620 /* Physical address */
22621 #define pa(X) ((X) - __PAGE_OFFSET)
22622
22623 +#ifdef CONFIG_PAX_KERNEXEC
22624 +#define ta(X) (X)
22625 +#else
22626 +#define ta(X) ((X) - __PAGE_OFFSET)
22627 +#endif
22628 +
22629 /*
22630 * References to members of the new_cpu_data structure.
22631 */
22632 @@ -55,11 +61,7 @@
22633 * and small than max_low_pfn, otherwise will waste some page table entries
22634 */
22635
22636 -#if PTRS_PER_PMD > 1
22637 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22638 -#else
22639 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22640 -#endif
22641 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22642
22643 /* Number of possible pages in the lowmem region */
22644 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22645 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22646 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22647
22648 /*
22649 + * Real beginning of normal "text" segment
22650 + */
22651 +ENTRY(stext)
22652 +ENTRY(_stext)
22653 +
22654 +/*
22655 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22656 * %esi points to the real-mode code as a 32-bit pointer.
22657 * CS and DS must be 4 GB flat segments, but we don't depend on
22658 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22659 * can.
22660 */
22661 __HEAD
22662 +
22663 +#ifdef CONFIG_PAX_KERNEXEC
22664 + jmp startup_32
22665 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22666 +.fill PAGE_SIZE-5,1,0xcc
22667 +#endif
22668 +
22669 ENTRY(startup_32)
22670 movl pa(stack_start),%ecx
22671
22672 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22673 2:
22674 leal -__PAGE_OFFSET(%ecx),%esp
22675
22676 +#ifdef CONFIG_SMP
22677 + movl $pa(cpu_gdt_table),%edi
22678 + movl $__per_cpu_load,%eax
22679 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22680 + rorl $16,%eax
22681 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22682 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22683 + movl $__per_cpu_end - 1,%eax
22684 + subl $__per_cpu_start,%eax
22685 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22686 +#endif
22687 +
22688 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22689 + movl $NR_CPUS,%ecx
22690 + movl $pa(cpu_gdt_table),%edi
22691 +1:
22692 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22693 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22694 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22695 + addl $PAGE_SIZE_asm,%edi
22696 + loop 1b
22697 +#endif
22698 +
22699 +#ifdef CONFIG_PAX_KERNEXEC
22700 + movl $pa(boot_gdt),%edi
22701 + movl $__LOAD_PHYSICAL_ADDR,%eax
22702 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22703 + rorl $16,%eax
22704 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22705 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22706 + rorl $16,%eax
22707 +
22708 + ljmp $(__BOOT_CS),$1f
22709 +1:
22710 +
22711 + movl $NR_CPUS,%ecx
22712 + movl $pa(cpu_gdt_table),%edi
22713 + addl $__PAGE_OFFSET,%eax
22714 +1:
22715 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22716 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22717 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22718 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22719 + rorl $16,%eax
22720 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22721 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22722 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22723 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22724 + rorl $16,%eax
22725 + addl $PAGE_SIZE_asm,%edi
22726 + loop 1b
22727 +#endif
22728 +
22729 /*
22730 * Clear BSS first so that there are no surprises...
22731 */
22732 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22733 movl %eax, pa(max_pfn_mapped)
22734
22735 /* Do early initialization of the fixmap area */
22736 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22737 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22738 +#ifdef CONFIG_COMPAT_VDSO
22739 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22740 +#else
22741 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22742 +#endif
22743 #else /* Not PAE */
22744
22745 page_pde_offset = (__PAGE_OFFSET >> 20);
22746 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22747 movl %eax, pa(max_pfn_mapped)
22748
22749 /* Do early initialization of the fixmap area */
22750 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22751 - movl %eax,pa(initial_page_table+0xffc)
22752 +#ifdef CONFIG_COMPAT_VDSO
22753 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22754 +#else
22755 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22756 +#endif
22757 #endif
22758
22759 #ifdef CONFIG_PARAVIRT
22760 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22761 cmpl $num_subarch_entries, %eax
22762 jae bad_subarch
22763
22764 - movl pa(subarch_entries)(,%eax,4), %eax
22765 - subl $__PAGE_OFFSET, %eax
22766 - jmp *%eax
22767 + jmp *pa(subarch_entries)(,%eax,4)
22768
22769 bad_subarch:
22770 WEAK(lguest_entry)
22771 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22772 __INITDATA
22773
22774 subarch_entries:
22775 - .long default_entry /* normal x86/PC */
22776 - .long lguest_entry /* lguest hypervisor */
22777 - .long xen_entry /* Xen hypervisor */
22778 - .long default_entry /* Moorestown MID */
22779 + .long ta(default_entry) /* normal x86/PC */
22780 + .long ta(lguest_entry) /* lguest hypervisor */
22781 + .long ta(xen_entry) /* Xen hypervisor */
22782 + .long ta(default_entry) /* Moorestown MID */
22783 num_subarch_entries = (. - subarch_entries) / 4
22784 .previous
22785 #else
22786 @@ -354,6 +426,7 @@ default_entry:
22787 movl pa(mmu_cr4_features),%eax
22788 movl %eax,%cr4
22789
22790 +#ifdef CONFIG_X86_PAE
22791 testb $X86_CR4_PAE, %al # check if PAE is enabled
22792 jz enable_paging
22793
22794 @@ -382,6 +455,9 @@ default_entry:
22795 /* Make changes effective */
22796 wrmsr
22797
22798 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22799 +#endif
22800 +
22801 enable_paging:
22802
22803 /*
22804 @@ -449,14 +525,20 @@ is486:
22805 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22806 movl %eax,%ss # after changing gdt.
22807
22808 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22809 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22810 movl %eax,%ds
22811 movl %eax,%es
22812
22813 movl $(__KERNEL_PERCPU), %eax
22814 movl %eax,%fs # set this cpu's percpu
22815
22816 +#ifdef CONFIG_CC_STACKPROTECTOR
22817 movl $(__KERNEL_STACK_CANARY),%eax
22818 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22819 + movl $(__USER_DS),%eax
22820 +#else
22821 + xorl %eax,%eax
22822 +#endif
22823 movl %eax,%gs
22824
22825 xorl %eax,%eax # Clear LDT
22826 @@ -512,8 +594,11 @@ setup_once:
22827 * relocation. Manually set base address in stack canary
22828 * segment descriptor.
22829 */
22830 - movl $gdt_page,%eax
22831 + movl $cpu_gdt_table,%eax
22832 movl $stack_canary,%ecx
22833 +#ifdef CONFIG_SMP
22834 + addl $__per_cpu_load,%ecx
22835 +#endif
22836 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22837 shrl $16, %ecx
22838 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22839 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22840 /* This is global to keep gas from relaxing the jumps */
22841 ENTRY(early_idt_handler)
22842 cld
22843 - cmpl $2,%ss:early_recursion_flag
22844 + cmpl $1,%ss:early_recursion_flag
22845 je hlt_loop
22846 incl %ss:early_recursion_flag
22847
22848 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22849 pushl (20+6*4)(%esp) /* trapno */
22850 pushl $fault_msg
22851 call printk
22852 -#endif
22853 call dump_stack
22854 +#endif
22855 hlt_loop:
22856 hlt
22857 jmp hlt_loop
22858 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22859 /* This is the default interrupt "handler" :-) */
22860 ALIGN
22861 ignore_int:
22862 - cld
22863 #ifdef CONFIG_PRINTK
22864 + cmpl $2,%ss:early_recursion_flag
22865 + je hlt_loop
22866 + incl %ss:early_recursion_flag
22867 + cld
22868 pushl %eax
22869 pushl %ecx
22870 pushl %edx
22871 @@ -612,9 +700,6 @@ ignore_int:
22872 movl $(__KERNEL_DS),%eax
22873 movl %eax,%ds
22874 movl %eax,%es
22875 - cmpl $2,early_recursion_flag
22876 - je hlt_loop
22877 - incl early_recursion_flag
22878 pushl 16(%esp)
22879 pushl 24(%esp)
22880 pushl 32(%esp)
22881 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22882 /*
22883 * BSS section
22884 */
22885 -__PAGE_ALIGNED_BSS
22886 - .align PAGE_SIZE
22887 #ifdef CONFIG_X86_PAE
22888 +.section .initial_pg_pmd,"a",@progbits
22889 initial_pg_pmd:
22890 .fill 1024*KPMDS,4,0
22891 #else
22892 +.section .initial_page_table,"a",@progbits
22893 ENTRY(initial_page_table)
22894 .fill 1024,4,0
22895 #endif
22896 +.section .initial_pg_fixmap,"a",@progbits
22897 initial_pg_fixmap:
22898 .fill 1024,4,0
22899 +.section .empty_zero_page,"a",@progbits
22900 ENTRY(empty_zero_page)
22901 .fill 4096,1,0
22902 +.section .swapper_pg_dir,"a",@progbits
22903 ENTRY(swapper_pg_dir)
22904 +#ifdef CONFIG_X86_PAE
22905 + .fill 4,8,0
22906 +#else
22907 .fill 1024,4,0
22908 +#endif
22909
22910 /*
22911 * This starts the data section.
22912 */
22913 #ifdef CONFIG_X86_PAE
22914 -__PAGE_ALIGNED_DATA
22915 - /* Page-aligned for the benefit of paravirt? */
22916 - .align PAGE_SIZE
22917 +.section .initial_page_table,"a",@progbits
22918 ENTRY(initial_page_table)
22919 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22920 # if KPMDS == 3
22921 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22922 # error "Kernel PMDs should be 1, 2 or 3"
22923 # endif
22924 .align PAGE_SIZE /* needs to be page-sized too */
22925 +
22926 +#ifdef CONFIG_PAX_PER_CPU_PGD
22927 +ENTRY(cpu_pgd)
22928 + .rept 2*NR_CPUS
22929 + .fill 4,8,0
22930 + .endr
22931 +#endif
22932 +
22933 #endif
22934
22935 .data
22936 .balign 4
22937 ENTRY(stack_start)
22938 - .long init_thread_union+THREAD_SIZE
22939 + .long init_thread_union+THREAD_SIZE-8
22940
22941 __INITRODATA
22942 int_msg:
22943 @@ -722,7 +820,7 @@ fault_msg:
22944 * segment size, and 32-bit linear address value:
22945 */
22946
22947 - .data
22948 +.section .rodata,"a",@progbits
22949 .globl boot_gdt_descr
22950 .globl idt_descr
22951
22952 @@ -731,7 +829,7 @@ fault_msg:
22953 .word 0 # 32 bit align gdt_desc.address
22954 boot_gdt_descr:
22955 .word __BOOT_DS+7
22956 - .long boot_gdt - __PAGE_OFFSET
22957 + .long pa(boot_gdt)
22958
22959 .word 0 # 32-bit align idt_desc.address
22960 idt_descr:
22961 @@ -742,7 +840,7 @@ idt_descr:
22962 .word 0 # 32 bit align gdt_desc.address
22963 ENTRY(early_gdt_descr)
22964 .word GDT_ENTRIES*8-1
22965 - .long gdt_page /* Overwritten for secondary CPUs */
22966 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22967
22968 /*
22969 * The boot_gdt must mirror the equivalent in setup.S and is
22970 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22971 .align L1_CACHE_BYTES
22972 ENTRY(boot_gdt)
22973 .fill GDT_ENTRY_BOOT_CS,8,0
22974 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22975 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22976 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22977 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22978 +
22979 + .align PAGE_SIZE_asm
22980 +ENTRY(cpu_gdt_table)
22981 + .rept NR_CPUS
22982 + .quad 0x0000000000000000 /* NULL descriptor */
22983 + .quad 0x0000000000000000 /* 0x0b reserved */
22984 + .quad 0x0000000000000000 /* 0x13 reserved */
22985 + .quad 0x0000000000000000 /* 0x1b reserved */
22986 +
22987 +#ifdef CONFIG_PAX_KERNEXEC
22988 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22989 +#else
22990 + .quad 0x0000000000000000 /* 0x20 unused */
22991 +#endif
22992 +
22993 + .quad 0x0000000000000000 /* 0x28 unused */
22994 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22995 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22996 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22997 + .quad 0x0000000000000000 /* 0x4b reserved */
22998 + .quad 0x0000000000000000 /* 0x53 reserved */
22999 + .quad 0x0000000000000000 /* 0x5b reserved */
23000 +
23001 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23002 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23003 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23004 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23005 +
23006 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23007 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23008 +
23009 + /*
23010 + * Segments used for calling PnP BIOS have byte granularity.
23011 + * The code segments and data segments have fixed 64k limits,
23012 + * the transfer segment sizes are set at run time.
23013 + */
23014 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23015 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23016 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23017 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23018 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23019 +
23020 + /*
23021 + * The APM segments have byte granularity and their bases
23022 + * are set at run time. All have 64k limits.
23023 + */
23024 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23025 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23026 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23027 +
23028 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23029 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23030 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23031 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23032 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23033 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23034 +
23035 + /* Be sure this is zeroed to avoid false validations in Xen */
23036 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23037 + .endr
23038 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23039 index e1aabdb..fee4fee 100644
23040 --- a/arch/x86/kernel/head_64.S
23041 +++ b/arch/x86/kernel/head_64.S
23042 @@ -20,6 +20,8 @@
23043 #include <asm/processor-flags.h>
23044 #include <asm/percpu.h>
23045 #include <asm/nops.h>
23046 +#include <asm/cpufeature.h>
23047 +#include <asm/alternative-asm.h>
23048
23049 #ifdef CONFIG_PARAVIRT
23050 #include <asm/asm-offsets.h>
23051 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23052 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23053 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23054 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23055 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23056 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23057 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23058 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23059 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23060 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23061
23062 .text
23063 __HEAD
23064 @@ -89,11 +97,24 @@ startup_64:
23065 * Fixup the physical addresses in the page table
23066 */
23067 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23068 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23069 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23070 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23071 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23072 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23073
23074 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23075 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23076 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23077 +#ifndef CONFIG_XEN
23078 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23079 +#endif
23080 +
23081 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23082 +
23083 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23084 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23085
23086 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23087 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23088
23089 /*
23090 * Set up the identity mapping for the switchover. These
23091 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
23092 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23093 1:
23094
23095 - /* Enable PAE mode and PGE */
23096 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23097 + /* Enable PAE mode and PSE/PGE */
23098 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23099 movq %rcx, %cr4
23100
23101 /* Setup early boot stage 4 level pagetables. */
23102 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
23103 movl $MSR_EFER, %ecx
23104 rdmsr
23105 btsl $_EFER_SCE, %eax /* Enable System Call */
23106 - btl $20,%edi /* No Execute supported? */
23107 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23108 jnc 1f
23109 btsl $_EFER_NX, %eax
23110 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23111 +#ifndef CONFIG_EFI
23112 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
23113 +#endif
23114 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
23115 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
23116 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
23117 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
23118 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
23119 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23120 1: wrmsr /* Make changes effective */
23121
23122 /* Setup cr0 */
23123 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
23124 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23125 * address given in m16:64.
23126 */
23127 + pax_set_fptr_mask
23128 movq initial_code(%rip),%rax
23129 pushq $0 # fake return address to stop unwinder
23130 pushq $__KERNEL_CS # set correct cs
23131 @@ -388,7 +419,7 @@ ENTRY(early_idt_handler)
23132 call dump_stack
23133 #ifdef CONFIG_KALLSYMS
23134 leaq early_idt_ripmsg(%rip),%rdi
23135 - movq 40(%rsp),%rsi # %rip again
23136 + movq 88(%rsp),%rsi # %rip again
23137 call __print_symbol
23138 #endif
23139 #endif /* EARLY_PRINTK */
23140 @@ -416,6 +447,7 @@ ENDPROC(early_idt_handler)
23141 early_recursion_flag:
23142 .long 0
23143
23144 + .section .rodata,"a",@progbits
23145 #ifdef CONFIG_EARLY_PRINTK
23146 early_idt_msg:
23147 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23148 @@ -443,29 +475,52 @@ NEXT_PAGE(early_level4_pgt)
23149 NEXT_PAGE(early_dynamic_pgts)
23150 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23151
23152 - .data
23153 + .section .rodata,"a",@progbits
23154
23155 -#ifndef CONFIG_XEN
23156 NEXT_PAGE(init_level4_pgt)
23157 - .fill 512,8,0
23158 -#else
23159 -NEXT_PAGE(init_level4_pgt)
23160 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23161 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23162 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23163 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23164 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23165 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23166 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23167 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23168 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23169 .org init_level4_pgt + L4_START_KERNEL*8, 0
23170 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23171 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23172
23173 +#ifdef CONFIG_PAX_PER_CPU_PGD
23174 +NEXT_PAGE(cpu_pgd)
23175 + .rept 2*NR_CPUS
23176 + .fill 512,8,0
23177 + .endr
23178 +#endif
23179 +
23180 NEXT_PAGE(level3_ident_pgt)
23181 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23182 +#ifdef CONFIG_XEN
23183 .fill 511, 8, 0
23184 +#else
23185 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23186 + .fill 510,8,0
23187 +#endif
23188 +
23189 +NEXT_PAGE(level3_vmalloc_start_pgt)
23190 + .fill 512,8,0
23191 +
23192 +NEXT_PAGE(level3_vmalloc_end_pgt)
23193 + .fill 512,8,0
23194 +
23195 +NEXT_PAGE(level3_vmemmap_pgt)
23196 + .fill L3_VMEMMAP_START,8,0
23197 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23198 +
23199 NEXT_PAGE(level2_ident_pgt)
23200 - /* Since I easily can, map the first 1G.
23201 + /* Since I easily can, map the first 2G.
23202 * Don't set NX because code runs from these pages.
23203 */
23204 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23205 -#endif
23206 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23207
23208 NEXT_PAGE(level3_kernel_pgt)
23209 .fill L3_START_KERNEL,8,0
23210 @@ -473,6 +528,9 @@ NEXT_PAGE(level3_kernel_pgt)
23211 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23212 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23213
23214 +NEXT_PAGE(level2_vmemmap_pgt)
23215 + .fill 512,8,0
23216 +
23217 NEXT_PAGE(level2_kernel_pgt)
23218 /*
23219 * 512 MB kernel mapping. We spend a full page on this pagetable
23220 @@ -490,28 +548,64 @@ NEXT_PAGE(level2_kernel_pgt)
23221 NEXT_PAGE(level2_fixmap_pgt)
23222 .fill 506,8,0
23223 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23224 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23225 - .fill 5,8,0
23226 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23227 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23228 + .fill 4,8,0
23229
23230 NEXT_PAGE(level1_fixmap_pgt)
23231 .fill 512,8,0
23232
23233 +NEXT_PAGE(level1_vsyscall_pgt)
23234 + .fill 512,8,0
23235 +
23236 #undef PMDS
23237
23238 - .data
23239 + .align PAGE_SIZE
23240 +ENTRY(cpu_gdt_table)
23241 + .rept NR_CPUS
23242 + .quad 0x0000000000000000 /* NULL descriptor */
23243 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23244 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23245 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23246 + .quad 0x00cffb000000ffff /* __USER32_CS */
23247 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23248 + .quad 0x00affb000000ffff /* __USER_CS */
23249 +
23250 +#ifdef CONFIG_PAX_KERNEXEC
23251 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23252 +#else
23253 + .quad 0x0 /* unused */
23254 +#endif
23255 +
23256 + .quad 0,0 /* TSS */
23257 + .quad 0,0 /* LDT */
23258 + .quad 0,0,0 /* three TLS descriptors */
23259 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23260 + /* asm/segment.h:GDT_ENTRIES must match this */
23261 +
23262 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23263 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23264 +#else
23265 + .quad 0x0 /* unused */
23266 +#endif
23267 +
23268 + /* zero the remaining page */
23269 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23270 + .endr
23271 +
23272 .align 16
23273 .globl early_gdt_descr
23274 early_gdt_descr:
23275 .word GDT_ENTRIES*8-1
23276 early_gdt_descr_base:
23277 - .quad INIT_PER_CPU_VAR(gdt_page)
23278 + .quad cpu_gdt_table
23279
23280 ENTRY(phys_base)
23281 /* This must match the first entry in level2_kernel_pgt */
23282 .quad 0x0000000000000000
23283
23284 #include "../../x86/xen/xen-head.S"
23285 -
23286 - __PAGE_ALIGNED_BSS
23287 +
23288 + .section .rodata,"a",@progbits
23289 NEXT_PAGE(empty_zero_page)
23290 .skip PAGE_SIZE
23291 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23292 index 0fa6912..b37438b 100644
23293 --- a/arch/x86/kernel/i386_ksyms_32.c
23294 +++ b/arch/x86/kernel/i386_ksyms_32.c
23295 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23296 EXPORT_SYMBOL(cmpxchg8b_emu);
23297 #endif
23298
23299 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23300 +
23301 /* Networking helper routines. */
23302 EXPORT_SYMBOL(csum_partial_copy_generic);
23303 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23304 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23305
23306 EXPORT_SYMBOL(__get_user_1);
23307 EXPORT_SYMBOL(__get_user_2);
23308 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23309
23310 EXPORT_SYMBOL(csum_partial);
23311 EXPORT_SYMBOL(empty_zero_page);
23312 +
23313 +#ifdef CONFIG_PAX_KERNEXEC
23314 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23315 +#endif
23316 +
23317 +#ifdef CONFIG_PAX_PER_CPU_PGD
23318 +EXPORT_SYMBOL(cpu_pgd);
23319 +#endif
23320 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23321 index 5d576ab..1403a03 100644
23322 --- a/arch/x86/kernel/i387.c
23323 +++ b/arch/x86/kernel/i387.c
23324 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23325 static inline bool interrupted_user_mode(void)
23326 {
23327 struct pt_regs *regs = get_irq_regs();
23328 - return regs && user_mode_vm(regs);
23329 + return regs && user_mode(regs);
23330 }
23331
23332 /*
23333 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23334 index 9a5c460..84868423 100644
23335 --- a/arch/x86/kernel/i8259.c
23336 +++ b/arch/x86/kernel/i8259.c
23337 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23338 static void make_8259A_irq(unsigned int irq)
23339 {
23340 disable_irq_nosync(irq);
23341 - io_apic_irqs &= ~(1<<irq);
23342 + io_apic_irqs &= ~(1UL<<irq);
23343 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23344 i8259A_chip.name);
23345 enable_irq(irq);
23346 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23347 "spurious 8259A interrupt: IRQ%d.\n", irq);
23348 spurious_irq_mask |= irqmask;
23349 }
23350 - atomic_inc(&irq_err_count);
23351 + atomic_inc_unchecked(&irq_err_count);
23352 /*
23353 * Theoretically we do not have to handle this IRQ,
23354 * but in Linux this does not cause problems and is
23355 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23356 /* (slave's support for AEOI in flat mode is to be investigated) */
23357 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23358
23359 + pax_open_kernel();
23360 if (auto_eoi)
23361 /*
23362 * In AEOI mode we just have to mask the interrupt
23363 * when acking.
23364 */
23365 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23366 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23367 else
23368 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23369 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23370 + pax_close_kernel();
23371
23372 udelay(100); /* wait for 8259A to initialize */
23373
23374 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23375 index a979b5b..1d6db75 100644
23376 --- a/arch/x86/kernel/io_delay.c
23377 +++ b/arch/x86/kernel/io_delay.c
23378 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23379 * Quirk table for systems that misbehave (lock up, etc.) if port
23380 * 0x80 is used:
23381 */
23382 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23383 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23384 {
23385 .callback = dmi_io_delay_0xed_port,
23386 .ident = "Compaq Presario V6000",
23387 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23388 index 4ddaf66..6292f4e 100644
23389 --- a/arch/x86/kernel/ioport.c
23390 +++ b/arch/x86/kernel/ioport.c
23391 @@ -6,6 +6,7 @@
23392 #include <linux/sched.h>
23393 #include <linux/kernel.h>
23394 #include <linux/capability.h>
23395 +#include <linux/security.h>
23396 #include <linux/errno.h>
23397 #include <linux/types.h>
23398 #include <linux/ioport.h>
23399 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23400
23401 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23402 return -EINVAL;
23403 +#ifdef CONFIG_GRKERNSEC_IO
23404 + if (turn_on && grsec_disable_privio) {
23405 + gr_handle_ioperm();
23406 + return -EPERM;
23407 + }
23408 +#endif
23409 if (turn_on && !capable(CAP_SYS_RAWIO))
23410 return -EPERM;
23411
23412 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23413 * because the ->io_bitmap_max value must match the bitmap
23414 * contents:
23415 */
23416 - tss = &per_cpu(init_tss, get_cpu());
23417 + tss = init_tss + get_cpu();
23418
23419 if (turn_on)
23420 bitmap_clear(t->io_bitmap_ptr, from, num);
23421 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23422 return -EINVAL;
23423 /* Trying to gain more privileges? */
23424 if (level > old) {
23425 +#ifdef CONFIG_GRKERNSEC_IO
23426 + if (grsec_disable_privio) {
23427 + gr_handle_iopl();
23428 + return -EPERM;
23429 + }
23430 +#endif
23431 if (!capable(CAP_SYS_RAWIO))
23432 return -EPERM;
23433 }
23434 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23435 index 22d0687..e07b2a5 100644
23436 --- a/arch/x86/kernel/irq.c
23437 +++ b/arch/x86/kernel/irq.c
23438 @@ -21,7 +21,7 @@
23439 #define CREATE_TRACE_POINTS
23440 #include <asm/trace/irq_vectors.h>
23441
23442 -atomic_t irq_err_count;
23443 +atomic_unchecked_t irq_err_count;
23444
23445 /* Function pointer for generic interrupt vector handling */
23446 void (*x86_platform_ipi_callback)(void) = NULL;
23447 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23448 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23449 seq_printf(p, " Machine check polls\n");
23450 #endif
23451 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23452 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23453 #if defined(CONFIG_X86_IO_APIC)
23454 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23455 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23456 #endif
23457 return 0;
23458 }
23459 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23460
23461 u64 arch_irq_stat(void)
23462 {
23463 - u64 sum = atomic_read(&irq_err_count);
23464 + u64 sum = atomic_read_unchecked(&irq_err_count);
23465 return sum;
23466 }
23467
23468 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23469 index 4186755..784efa0 100644
23470 --- a/arch/x86/kernel/irq_32.c
23471 +++ b/arch/x86/kernel/irq_32.c
23472 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23473 __asm__ __volatile__("andl %%esp,%0" :
23474 "=r" (sp) : "0" (THREAD_SIZE - 1));
23475
23476 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23477 + return sp < STACK_WARN;
23478 }
23479
23480 static void print_stack_overflow(void)
23481 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23482 * per-CPU IRQ handling contexts (thread information and stack)
23483 */
23484 union irq_ctx {
23485 - struct thread_info tinfo;
23486 - u32 stack[THREAD_SIZE/sizeof(u32)];
23487 + unsigned long previous_esp;
23488 + u32 stack[THREAD_SIZE/sizeof(u32)];
23489 } __attribute__((aligned(THREAD_SIZE)));
23490
23491 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23492 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23493 static inline int
23494 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23495 {
23496 - union irq_ctx *curctx, *irqctx;
23497 + union irq_ctx *irqctx;
23498 u32 *isp, arg1, arg2;
23499
23500 - curctx = (union irq_ctx *) current_thread_info();
23501 irqctx = __this_cpu_read(hardirq_ctx);
23502
23503 /*
23504 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23505 * handler) we can't do that and just have to keep using the
23506 * current stack (which is the irq stack already after all)
23507 */
23508 - if (unlikely(curctx == irqctx))
23509 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23510 return 0;
23511
23512 /* build the stack frame on the IRQ stack */
23513 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23514 - irqctx->tinfo.task = curctx->tinfo.task;
23515 - irqctx->tinfo.previous_esp = current_stack_pointer;
23516 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23517 + irqctx->previous_esp = current_stack_pointer;
23518
23519 - /* Copy the preempt_count so that the [soft]irq checks work. */
23520 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23521 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23522 + __set_fs(MAKE_MM_SEG(0));
23523 +#endif
23524
23525 if (unlikely(overflow))
23526 call_on_stack(print_stack_overflow, isp);
23527 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23528 : "0" (irq), "1" (desc), "2" (isp),
23529 "D" (desc->handle_irq)
23530 : "memory", "cc", "ecx");
23531 +
23532 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23533 + __set_fs(current_thread_info()->addr_limit);
23534 +#endif
23535 +
23536 return 1;
23537 }
23538
23539 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23540 */
23541 void irq_ctx_init(int cpu)
23542 {
23543 - union irq_ctx *irqctx;
23544 -
23545 if (per_cpu(hardirq_ctx, cpu))
23546 return;
23547
23548 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23549 - THREADINFO_GFP,
23550 - THREAD_SIZE_ORDER));
23551 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23552 - irqctx->tinfo.cpu = cpu;
23553 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23554 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23555 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23556 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23557
23558 - per_cpu(hardirq_ctx, cpu) = irqctx;
23559 -
23560 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23561 - THREADINFO_GFP,
23562 - THREAD_SIZE_ORDER));
23563 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23564 - irqctx->tinfo.cpu = cpu;
23565 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23566 -
23567 - per_cpu(softirq_ctx, cpu) = irqctx;
23568 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23569 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23570
23571 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23572 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23573 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23574 asmlinkage void do_softirq(void)
23575 {
23576 unsigned long flags;
23577 - struct thread_info *curctx;
23578 union irq_ctx *irqctx;
23579 u32 *isp;
23580
23581 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23582 local_irq_save(flags);
23583
23584 if (local_softirq_pending()) {
23585 - curctx = current_thread_info();
23586 irqctx = __this_cpu_read(softirq_ctx);
23587 - irqctx->tinfo.task = curctx->task;
23588 - irqctx->tinfo.previous_esp = current_stack_pointer;
23589 + irqctx->previous_esp = current_stack_pointer;
23590
23591 /* build the stack frame on the softirq stack */
23592 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23593 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23594 +
23595 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23596 + __set_fs(MAKE_MM_SEG(0));
23597 +#endif
23598
23599 call_on_stack(__do_softirq, isp);
23600 +
23601 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23602 + __set_fs(current_thread_info()->addr_limit);
23603 +#endif
23604 +
23605 /*
23606 * Shouldn't happen, we returned above if in_interrupt():
23607 */
23608 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23609 if (unlikely(!desc))
23610 return false;
23611
23612 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23613 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23614 if (unlikely(overflow))
23615 print_stack_overflow();
23616 desc->handle_irq(irq, desc);
23617 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23618 index d04d3ec..ea4b374 100644
23619 --- a/arch/x86/kernel/irq_64.c
23620 +++ b/arch/x86/kernel/irq_64.c
23621 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23622 u64 estack_top, estack_bottom;
23623 u64 curbase = (u64)task_stack_page(current);
23624
23625 - if (user_mode_vm(regs))
23626 + if (user_mode(regs))
23627 return;
23628
23629 if (regs->sp >= curbase + sizeof(struct thread_info) +
23630 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
23631 index ee11b7d..4df4d0c 100644
23632 --- a/arch/x86/kernel/jump_label.c
23633 +++ b/arch/x86/kernel/jump_label.c
23634 @@ -49,7 +49,7 @@ static void __jump_label_transform(struct jump_entry *entry,
23635 * We are enabling this jump label. If it is not a nop
23636 * then something must have gone wrong.
23637 */
23638 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) != 0))
23639 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5) != 0))
23640 bug_at((void *)entry->code, __LINE__);
23641
23642 code.jump = 0xe9;
23643 @@ -64,13 +64,13 @@ static void __jump_label_transform(struct jump_entry *entry,
23644 */
23645 if (init) {
23646 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
23647 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
23648 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
23649 bug_at((void *)entry->code, __LINE__);
23650 } else {
23651 code.jump = 0xe9;
23652 code.offset = entry->target -
23653 (entry->code + JUMP_LABEL_NOP_SIZE);
23654 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
23655 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
23656 bug_at((void *)entry->code, __LINE__);
23657 }
23658 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
23659 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23660 index 836f832..a8bda67 100644
23661 --- a/arch/x86/kernel/kgdb.c
23662 +++ b/arch/x86/kernel/kgdb.c
23663 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23664 #ifdef CONFIG_X86_32
23665 switch (regno) {
23666 case GDB_SS:
23667 - if (!user_mode_vm(regs))
23668 + if (!user_mode(regs))
23669 *(unsigned long *)mem = __KERNEL_DS;
23670 break;
23671 case GDB_SP:
23672 - if (!user_mode_vm(regs))
23673 + if (!user_mode(regs))
23674 *(unsigned long *)mem = kernel_stack_pointer(regs);
23675 break;
23676 case GDB_GS:
23677 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23678 bp->attr.bp_addr = breakinfo[breakno].addr;
23679 bp->attr.bp_len = breakinfo[breakno].len;
23680 bp->attr.bp_type = breakinfo[breakno].type;
23681 - info->address = breakinfo[breakno].addr;
23682 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23683 + info->address = ktla_ktva(breakinfo[breakno].addr);
23684 + else
23685 + info->address = breakinfo[breakno].addr;
23686 info->len = breakinfo[breakno].len;
23687 info->type = breakinfo[breakno].type;
23688 val = arch_install_hw_breakpoint(bp);
23689 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23690 case 'k':
23691 /* clear the trace bit */
23692 linux_regs->flags &= ~X86_EFLAGS_TF;
23693 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23694 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23695
23696 /* set the trace bit if we're stepping */
23697 if (remcomInBuffer[0] == 's') {
23698 linux_regs->flags |= X86_EFLAGS_TF;
23699 - atomic_set(&kgdb_cpu_doing_single_step,
23700 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23701 raw_smp_processor_id());
23702 }
23703
23704 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23705
23706 switch (cmd) {
23707 case DIE_DEBUG:
23708 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23709 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23710 if (user_mode(regs))
23711 return single_step_cont(regs, args);
23712 break;
23713 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23714 #endif /* CONFIG_DEBUG_RODATA */
23715
23716 bpt->type = BP_BREAKPOINT;
23717 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23718 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23719 BREAK_INSTR_SIZE);
23720 if (err)
23721 return err;
23722 - err = probe_kernel_write((char *)bpt->bpt_addr,
23723 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23724 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23725 #ifdef CONFIG_DEBUG_RODATA
23726 if (!err)
23727 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23728 return -EBUSY;
23729 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23730 BREAK_INSTR_SIZE);
23731 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23732 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23733 if (err)
23734 return err;
23735 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23736 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23737 if (mutex_is_locked(&text_mutex))
23738 goto knl_write;
23739 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23740 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23741 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23742 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23743 goto knl_write;
23744 return err;
23745 knl_write:
23746 #endif /* CONFIG_DEBUG_RODATA */
23747 - return probe_kernel_write((char *)bpt->bpt_addr,
23748 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23749 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23750 }
23751
23752 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23753 index 79a3f96..6ba030a 100644
23754 --- a/arch/x86/kernel/kprobes/core.c
23755 +++ b/arch/x86/kernel/kprobes/core.c
23756 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23757 s32 raddr;
23758 } __packed *insn;
23759
23760 - insn = (struct __arch_relative_insn *)from;
23761 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23762 +
23763 + pax_open_kernel();
23764 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23765 insn->op = op;
23766 + pax_close_kernel();
23767 }
23768
23769 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23770 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23771 kprobe_opcode_t opcode;
23772 kprobe_opcode_t *orig_opcodes = opcodes;
23773
23774 - if (search_exception_tables((unsigned long)opcodes))
23775 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23776 return 0; /* Page fault may occur on this address. */
23777
23778 retry:
23779 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23780 * for the first byte, we can recover the original instruction
23781 * from it and kp->opcode.
23782 */
23783 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23784 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23785 buf[0] = kp->opcode;
23786 - return (unsigned long)buf;
23787 + return ktva_ktla((unsigned long)buf);
23788 }
23789
23790 /*
23791 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23792 /* Another subsystem puts a breakpoint, failed to recover */
23793 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23794 return 0;
23795 + pax_open_kernel();
23796 memcpy(dest, insn.kaddr, insn.length);
23797 + pax_close_kernel();
23798
23799 #ifdef CONFIG_X86_64
23800 if (insn_rip_relative(&insn)) {
23801 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23802 return 0;
23803 }
23804 disp = (u8 *) dest + insn_offset_displacement(&insn);
23805 + pax_open_kernel();
23806 *(s32 *) disp = (s32) newdisp;
23807 + pax_close_kernel();
23808 }
23809 #endif
23810 return insn.length;
23811 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23812 * nor set current_kprobe, because it doesn't use single
23813 * stepping.
23814 */
23815 - regs->ip = (unsigned long)p->ainsn.insn;
23816 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23817 preempt_enable_no_resched();
23818 return;
23819 }
23820 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23821 regs->flags &= ~X86_EFLAGS_IF;
23822 /* single step inline if the instruction is an int3 */
23823 if (p->opcode == BREAKPOINT_INSTRUCTION)
23824 - regs->ip = (unsigned long)p->addr;
23825 + regs->ip = ktla_ktva((unsigned long)p->addr);
23826 else
23827 - regs->ip = (unsigned long)p->ainsn.insn;
23828 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23829 }
23830
23831 /*
23832 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23833 setup_singlestep(p, regs, kcb, 0);
23834 return 1;
23835 }
23836 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23837 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23838 /*
23839 * The breakpoint instruction was removed right
23840 * after we hit it. Another cpu has removed
23841 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23842 " movq %rax, 152(%rsp)\n"
23843 RESTORE_REGS_STRING
23844 " popfq\n"
23845 +#ifdef KERNEXEC_PLUGIN
23846 + " btsq $63,(%rsp)\n"
23847 +#endif
23848 #else
23849 " pushf\n"
23850 SAVE_REGS_STRING
23851 @@ -779,7 +789,7 @@ static void __kprobes
23852 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23853 {
23854 unsigned long *tos = stack_addr(regs);
23855 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23856 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23857 unsigned long orig_ip = (unsigned long)p->addr;
23858 kprobe_opcode_t *insn = p->ainsn.insn;
23859
23860 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23861 struct die_args *args = data;
23862 int ret = NOTIFY_DONE;
23863
23864 - if (args->regs && user_mode_vm(args->regs))
23865 + if (args->regs && user_mode(args->regs))
23866 return ret;
23867
23868 switch (val) {
23869 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23870 index 898160b..758cde8 100644
23871 --- a/arch/x86/kernel/kprobes/opt.c
23872 +++ b/arch/x86/kernel/kprobes/opt.c
23873 @@ -79,6 +79,7 @@ found:
23874 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23875 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23876 {
23877 + pax_open_kernel();
23878 #ifdef CONFIG_X86_64
23879 *addr++ = 0x48;
23880 *addr++ = 0xbf;
23881 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23882 *addr++ = 0xb8;
23883 #endif
23884 *(unsigned long *)addr = val;
23885 + pax_close_kernel();
23886 }
23887
23888 asm (
23889 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23890 * Verify if the address gap is in 2GB range, because this uses
23891 * a relative jump.
23892 */
23893 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23894 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23895 if (abs(rel) > 0x7fffffff)
23896 return -ERANGE;
23897
23898 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23899 op->optinsn.size = ret;
23900
23901 /* Copy arch-dep-instance from template */
23902 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23903 + pax_open_kernel();
23904 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23905 + pax_close_kernel();
23906
23907 /* Set probe information */
23908 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23909
23910 /* Set probe function call */
23911 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23912 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23913
23914 /* Set returning jmp instruction at the tail of out-of-line buffer */
23915 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23916 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23917 (u8 *)op->kp.addr + op->optinsn.size);
23918
23919 flush_icache_range((unsigned long) buf,
23920 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
23921 WARN_ON(kprobe_disabled(&op->kp));
23922
23923 /* Backup instructions which will be replaced by jump address */
23924 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23925 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23926 RELATIVE_ADDR_SIZE);
23927
23928 insn_buf[0] = RELATIVEJUMP_OPCODE;
23929 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23930 /* This kprobe is really able to run optimized path. */
23931 op = container_of(p, struct optimized_kprobe, kp);
23932 /* Detour through copied instructions */
23933 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23934 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23935 if (!reenter)
23936 reset_current_kprobe();
23937 preempt_enable_no_resched();
23938 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23939 index ebc9873..1b9724b 100644
23940 --- a/arch/x86/kernel/ldt.c
23941 +++ b/arch/x86/kernel/ldt.c
23942 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23943 if (reload) {
23944 #ifdef CONFIG_SMP
23945 preempt_disable();
23946 - load_LDT(pc);
23947 + load_LDT_nolock(pc);
23948 if (!cpumask_equal(mm_cpumask(current->mm),
23949 cpumask_of(smp_processor_id())))
23950 smp_call_function(flush_ldt, current->mm, 1);
23951 preempt_enable();
23952 #else
23953 - load_LDT(pc);
23954 + load_LDT_nolock(pc);
23955 #endif
23956 }
23957 if (oldsize) {
23958 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23959 return err;
23960
23961 for (i = 0; i < old->size; i++)
23962 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23963 + write_ldt_entry(new->ldt, i, old->ldt + i);
23964 return 0;
23965 }
23966
23967 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23968 retval = copy_ldt(&mm->context, &old_mm->context);
23969 mutex_unlock(&old_mm->context.lock);
23970 }
23971 +
23972 + if (tsk == current) {
23973 + mm->context.vdso = 0;
23974 +
23975 +#ifdef CONFIG_X86_32
23976 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23977 + mm->context.user_cs_base = 0UL;
23978 + mm->context.user_cs_limit = ~0UL;
23979 +
23980 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23981 + cpus_clear(mm->context.cpu_user_cs_mask);
23982 +#endif
23983 +
23984 +#endif
23985 +#endif
23986 +
23987 + }
23988 +
23989 return retval;
23990 }
23991
23992 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23993 }
23994 }
23995
23996 +#ifdef CONFIG_PAX_SEGMEXEC
23997 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23998 + error = -EINVAL;
23999 + goto out_unlock;
24000 + }
24001 +#endif
24002 +
24003 fill_ldt(&ldt, &ldt_info);
24004 if (oldmode)
24005 ldt.avl = 0;
24006 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24007 index 5b19e4d..6476a76 100644
24008 --- a/arch/x86/kernel/machine_kexec_32.c
24009 +++ b/arch/x86/kernel/machine_kexec_32.c
24010 @@ -26,7 +26,7 @@
24011 #include <asm/cacheflush.h>
24012 #include <asm/debugreg.h>
24013
24014 -static void set_idt(void *newidt, __u16 limit)
24015 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24016 {
24017 struct desc_ptr curidt;
24018
24019 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24020 }
24021
24022
24023 -static void set_gdt(void *newgdt, __u16 limit)
24024 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24025 {
24026 struct desc_ptr curgdt;
24027
24028 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24029 }
24030
24031 control_page = page_address(image->control_code_page);
24032 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24033 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24034
24035 relocate_kernel_ptr = control_page;
24036 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24037 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24038 index 15c9876..0a43909 100644
24039 --- a/arch/x86/kernel/microcode_core.c
24040 +++ b/arch/x86/kernel/microcode_core.c
24041 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24042 return NOTIFY_OK;
24043 }
24044
24045 -static struct notifier_block __refdata mc_cpu_notifier = {
24046 +static struct notifier_block mc_cpu_notifier = {
24047 .notifier_call = mc_cpu_callback,
24048 };
24049
24050 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24051 index 5fb2ceb..3ae90bb 100644
24052 --- a/arch/x86/kernel/microcode_intel.c
24053 +++ b/arch/x86/kernel/microcode_intel.c
24054 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24055
24056 static int get_ucode_user(void *to, const void *from, size_t n)
24057 {
24058 - return copy_from_user(to, from, n);
24059 + return copy_from_user(to, (const void __force_user *)from, n);
24060 }
24061
24062 static enum ucode_state
24063 request_microcode_user(int cpu, const void __user *buf, size_t size)
24064 {
24065 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24066 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24067 }
24068
24069 static void microcode_fini_cpu(int cpu)
24070 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24071 index 216a4d7..228255a 100644
24072 --- a/arch/x86/kernel/module.c
24073 +++ b/arch/x86/kernel/module.c
24074 @@ -43,15 +43,60 @@ do { \
24075 } while (0)
24076 #endif
24077
24078 -void *module_alloc(unsigned long size)
24079 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24080 {
24081 - if (PAGE_ALIGN(size) > MODULES_LEN)
24082 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24083 return NULL;
24084 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24085 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24086 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24087 -1, __builtin_return_address(0));
24088 }
24089
24090 +void *module_alloc(unsigned long size)
24091 +{
24092 +
24093 +#ifdef CONFIG_PAX_KERNEXEC
24094 + return __module_alloc(size, PAGE_KERNEL);
24095 +#else
24096 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24097 +#endif
24098 +
24099 +}
24100 +
24101 +#ifdef CONFIG_PAX_KERNEXEC
24102 +#ifdef CONFIG_X86_32
24103 +void *module_alloc_exec(unsigned long size)
24104 +{
24105 + struct vm_struct *area;
24106 +
24107 + if (size == 0)
24108 + return NULL;
24109 +
24110 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24111 + return area ? area->addr : NULL;
24112 +}
24113 +EXPORT_SYMBOL(module_alloc_exec);
24114 +
24115 +void module_free_exec(struct module *mod, void *module_region)
24116 +{
24117 + vunmap(module_region);
24118 +}
24119 +EXPORT_SYMBOL(module_free_exec);
24120 +#else
24121 +void module_free_exec(struct module *mod, void *module_region)
24122 +{
24123 + module_free(mod, module_region);
24124 +}
24125 +EXPORT_SYMBOL(module_free_exec);
24126 +
24127 +void *module_alloc_exec(unsigned long size)
24128 +{
24129 + return __module_alloc(size, PAGE_KERNEL_RX);
24130 +}
24131 +EXPORT_SYMBOL(module_alloc_exec);
24132 +#endif
24133 +#endif
24134 +
24135 #ifdef CONFIG_X86_32
24136 int apply_relocate(Elf32_Shdr *sechdrs,
24137 const char *strtab,
24138 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24139 unsigned int i;
24140 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24141 Elf32_Sym *sym;
24142 - uint32_t *location;
24143 + uint32_t *plocation, location;
24144
24145 DEBUGP("Applying relocate section %u to %u\n",
24146 relsec, sechdrs[relsec].sh_info);
24147 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24148 /* This is where to make the change */
24149 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24150 - + rel[i].r_offset;
24151 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24152 + location = (uint32_t)plocation;
24153 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24154 + plocation = ktla_ktva((void *)plocation);
24155 /* This is the symbol it is referring to. Note that all
24156 undefined symbols have been resolved. */
24157 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24158 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24159 switch (ELF32_R_TYPE(rel[i].r_info)) {
24160 case R_386_32:
24161 /* We add the value into the location given */
24162 - *location += sym->st_value;
24163 + pax_open_kernel();
24164 + *plocation += sym->st_value;
24165 + pax_close_kernel();
24166 break;
24167 case R_386_PC32:
24168 /* Add the value, subtract its position */
24169 - *location += sym->st_value - (uint32_t)location;
24170 + pax_open_kernel();
24171 + *plocation += sym->st_value - location;
24172 + pax_close_kernel();
24173 break;
24174 default:
24175 pr_err("%s: Unknown relocation: %u\n",
24176 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24177 case R_X86_64_NONE:
24178 break;
24179 case R_X86_64_64:
24180 + pax_open_kernel();
24181 *(u64 *)loc = val;
24182 + pax_close_kernel();
24183 break;
24184 case R_X86_64_32:
24185 + pax_open_kernel();
24186 *(u32 *)loc = val;
24187 + pax_close_kernel();
24188 if (val != *(u32 *)loc)
24189 goto overflow;
24190 break;
24191 case R_X86_64_32S:
24192 + pax_open_kernel();
24193 *(s32 *)loc = val;
24194 + pax_close_kernel();
24195 if ((s64)val != *(s32 *)loc)
24196 goto overflow;
24197 break;
24198 case R_X86_64_PC32:
24199 val -= (u64)loc;
24200 + pax_open_kernel();
24201 *(u32 *)loc = val;
24202 + pax_close_kernel();
24203 +
24204 #if 0
24205 if ((s64)val != *(s32 *)loc)
24206 goto overflow;
24207 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24208 index 88458fa..349f7a4 100644
24209 --- a/arch/x86/kernel/msr.c
24210 +++ b/arch/x86/kernel/msr.c
24211 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24212 return notifier_from_errno(err);
24213 }
24214
24215 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24216 +static struct notifier_block msr_class_cpu_notifier = {
24217 .notifier_call = msr_class_cpu_callback,
24218 };
24219
24220 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24221 index 6fcb49c..5b3f4ff 100644
24222 --- a/arch/x86/kernel/nmi.c
24223 +++ b/arch/x86/kernel/nmi.c
24224 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24225 return handled;
24226 }
24227
24228 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24229 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24230 {
24231 struct nmi_desc *desc = nmi_to_desc(type);
24232 unsigned long flags;
24233 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24234 * event confuses some handlers (kdump uses this flag)
24235 */
24236 if (action->flags & NMI_FLAG_FIRST)
24237 - list_add_rcu(&action->list, &desc->head);
24238 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24239 else
24240 - list_add_tail_rcu(&action->list, &desc->head);
24241 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24242
24243 spin_unlock_irqrestore(&desc->lock, flags);
24244 return 0;
24245 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24246 if (!strcmp(n->name, name)) {
24247 WARN(in_nmi(),
24248 "Trying to free NMI (%s) from NMI context!\n", n->name);
24249 - list_del_rcu(&n->list);
24250 + pax_list_del_rcu((struct list_head *)&n->list);
24251 break;
24252 }
24253 }
24254 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24255 dotraplinkage notrace __kprobes void
24256 do_nmi(struct pt_regs *regs, long error_code)
24257 {
24258 +
24259 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24260 + if (!user_mode(regs)) {
24261 + unsigned long cs = regs->cs & 0xFFFF;
24262 + unsigned long ip = ktva_ktla(regs->ip);
24263 +
24264 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24265 + regs->ip = ip;
24266 + }
24267 +#endif
24268 +
24269 nmi_nesting_preprocess(regs);
24270
24271 nmi_enter();
24272 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24273 index 6d9582e..f746287 100644
24274 --- a/arch/x86/kernel/nmi_selftest.c
24275 +++ b/arch/x86/kernel/nmi_selftest.c
24276 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24277 {
24278 /* trap all the unknown NMIs we may generate */
24279 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24280 - __initdata);
24281 + __initconst);
24282 }
24283
24284 static void __init cleanup_nmi_testsuite(void)
24285 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24286 unsigned long timeout;
24287
24288 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24289 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24290 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24291 nmi_fail = FAILURE;
24292 return;
24293 }
24294 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24295 index bbb6c73..24a58ef 100644
24296 --- a/arch/x86/kernel/paravirt-spinlocks.c
24297 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24298 @@ -8,7 +8,7 @@
24299
24300 #include <asm/paravirt.h>
24301
24302 -struct pv_lock_ops pv_lock_ops = {
24303 +struct pv_lock_ops pv_lock_ops __read_only = {
24304 #ifdef CONFIG_SMP
24305 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
24306 .unlock_kick = paravirt_nop,
24307 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24308 index 1b10af8..0b58cbc 100644
24309 --- a/arch/x86/kernel/paravirt.c
24310 +++ b/arch/x86/kernel/paravirt.c
24311 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24312 {
24313 return x;
24314 }
24315 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24316 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24317 +#endif
24318
24319 void __init default_banner(void)
24320 {
24321 @@ -142,15 +145,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24322 if (opfunc == NULL)
24323 /* If there's no function, patch it with a ud2a (BUG) */
24324 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24325 - else if (opfunc == _paravirt_nop)
24326 + else if (opfunc == (void *)_paravirt_nop)
24327 /* If the operation is a nop, then nop the callsite */
24328 ret = paravirt_patch_nop();
24329
24330 /* identity functions just return their single argument */
24331 - else if (opfunc == _paravirt_ident_32)
24332 + else if (opfunc == (void *)_paravirt_ident_32)
24333 ret = paravirt_patch_ident_32(insnbuf, len);
24334 - else if (opfunc == _paravirt_ident_64)
24335 + else if (opfunc == (void *)_paravirt_ident_64)
24336 ret = paravirt_patch_ident_64(insnbuf, len);
24337 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24338 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24339 + ret = paravirt_patch_ident_64(insnbuf, len);
24340 +#endif
24341
24342 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24343 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24344 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24345 if (insn_len > len || start == NULL)
24346 insn_len = len;
24347 else
24348 - memcpy(insnbuf, start, insn_len);
24349 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24350
24351 return insn_len;
24352 }
24353 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24354 return this_cpu_read(paravirt_lazy_mode);
24355 }
24356
24357 -struct pv_info pv_info = {
24358 +struct pv_info pv_info __read_only = {
24359 .name = "bare hardware",
24360 .paravirt_enabled = 0,
24361 .kernel_rpl = 0,
24362 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
24363 #endif
24364 };
24365
24366 -struct pv_init_ops pv_init_ops = {
24367 +struct pv_init_ops pv_init_ops __read_only = {
24368 .patch = native_patch,
24369 };
24370
24371 -struct pv_time_ops pv_time_ops = {
24372 +struct pv_time_ops pv_time_ops __read_only = {
24373 .sched_clock = native_sched_clock,
24374 .steal_clock = native_steal_clock,
24375 };
24376
24377 -__visible struct pv_irq_ops pv_irq_ops = {
24378 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
24379 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24380 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24381 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24382 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
24383 #endif
24384 };
24385
24386 -__visible struct pv_cpu_ops pv_cpu_ops = {
24387 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
24388 .cpuid = native_cpuid,
24389 .get_debugreg = native_get_debugreg,
24390 .set_debugreg = native_set_debugreg,
24391 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
24392 .end_context_switch = paravirt_nop,
24393 };
24394
24395 -struct pv_apic_ops pv_apic_ops = {
24396 +struct pv_apic_ops pv_apic_ops __read_only= {
24397 #ifdef CONFIG_X86_LOCAL_APIC
24398 .startup_ipi_hook = paravirt_nop,
24399 #endif
24400 };
24401
24402 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24403 +#ifdef CONFIG_X86_32
24404 +#ifdef CONFIG_X86_PAE
24405 +/* 64-bit pagetable entries */
24406 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24407 +#else
24408 /* 32-bit pagetable entries */
24409 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24410 +#endif
24411 #else
24412 /* 64-bit pagetable entries */
24413 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24414 #endif
24415
24416 -struct pv_mmu_ops pv_mmu_ops = {
24417 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24418
24419 .read_cr2 = native_read_cr2,
24420 .write_cr2 = native_write_cr2,
24421 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24422 .make_pud = PTE_IDENT,
24423
24424 .set_pgd = native_set_pgd,
24425 + .set_pgd_batched = native_set_pgd_batched,
24426 #endif
24427 #endif /* PAGETABLE_LEVELS >= 3 */
24428
24429 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24430 },
24431
24432 .set_fixmap = native_set_fixmap,
24433 +
24434 +#ifdef CONFIG_PAX_KERNEXEC
24435 + .pax_open_kernel = native_pax_open_kernel,
24436 + .pax_close_kernel = native_pax_close_kernel,
24437 +#endif
24438 +
24439 };
24440
24441 EXPORT_SYMBOL_GPL(pv_time_ops);
24442 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24443 index 299d493..2ccb0ee 100644
24444 --- a/arch/x86/kernel/pci-calgary_64.c
24445 +++ b/arch/x86/kernel/pci-calgary_64.c
24446 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24447 tce_space = be64_to_cpu(readq(target));
24448 tce_space = tce_space & TAR_SW_BITS;
24449
24450 - tce_space = tce_space & (~specified_table_size);
24451 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24452 info->tce_space = (u64 *)__va(tce_space);
24453 }
24454 }
24455 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24456 index 35ccf75..7a15747 100644
24457 --- a/arch/x86/kernel/pci-iommu_table.c
24458 +++ b/arch/x86/kernel/pci-iommu_table.c
24459 @@ -2,7 +2,7 @@
24460 #include <asm/iommu_table.h>
24461 #include <linux/string.h>
24462 #include <linux/kallsyms.h>
24463 -
24464 +#include <linux/sched.h>
24465
24466 #define DEBUG 1
24467
24468 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24469 index 6c483ba..d10ce2f 100644
24470 --- a/arch/x86/kernel/pci-swiotlb.c
24471 +++ b/arch/x86/kernel/pci-swiotlb.c
24472 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24473 void *vaddr, dma_addr_t dma_addr,
24474 struct dma_attrs *attrs)
24475 {
24476 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24477 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24478 }
24479
24480 static struct dma_map_ops swiotlb_dma_ops = {
24481 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24482 index c83516b..432ad6d 100644
24483 --- a/arch/x86/kernel/process.c
24484 +++ b/arch/x86/kernel/process.c
24485 @@ -36,7 +36,8 @@
24486 * section. Since TSS's are completely CPU-local, we want them
24487 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24488 */
24489 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24490 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24491 +EXPORT_SYMBOL(init_tss);
24492
24493 #ifdef CONFIG_X86_64
24494 static DEFINE_PER_CPU(unsigned char, is_idle);
24495 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24496 task_xstate_cachep =
24497 kmem_cache_create("task_xstate", xstate_size,
24498 __alignof__(union thread_xstate),
24499 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24500 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24501 }
24502
24503 /*
24504 @@ -105,7 +106,7 @@ void exit_thread(void)
24505 unsigned long *bp = t->io_bitmap_ptr;
24506
24507 if (bp) {
24508 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24509 + struct tss_struct *tss = init_tss + get_cpu();
24510
24511 t->io_bitmap_ptr = NULL;
24512 clear_thread_flag(TIF_IO_BITMAP);
24513 @@ -125,6 +126,9 @@ void flush_thread(void)
24514 {
24515 struct task_struct *tsk = current;
24516
24517 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24518 + loadsegment(gs, 0);
24519 +#endif
24520 flush_ptrace_hw_breakpoint(tsk);
24521 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24522 drop_init_fpu(tsk);
24523 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24524 void exit_idle(void)
24525 {
24526 /* idle loop has pid 0 */
24527 - if (current->pid)
24528 + if (task_pid_nr(current))
24529 return;
24530 __exit_idle();
24531 }
24532 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24533 return ret;
24534 }
24535 #endif
24536 -void stop_this_cpu(void *dummy)
24537 +__noreturn void stop_this_cpu(void *dummy)
24538 {
24539 local_irq_disable();
24540 /*
24541 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24542 }
24543 early_param("idle", idle_setup);
24544
24545 -unsigned long arch_align_stack(unsigned long sp)
24546 +#ifdef CONFIG_PAX_RANDKSTACK
24547 +void pax_randomize_kstack(struct pt_regs *regs)
24548 {
24549 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24550 - sp -= get_random_int() % 8192;
24551 - return sp & ~0xf;
24552 -}
24553 + struct thread_struct *thread = &current->thread;
24554 + unsigned long time;
24555
24556 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24557 -{
24558 - unsigned long range_end = mm->brk + 0x02000000;
24559 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24560 -}
24561 + if (!randomize_va_space)
24562 + return;
24563 +
24564 + if (v8086_mode(regs))
24565 + return;
24566
24567 + rdtscl(time);
24568 +
24569 + /* P4 seems to return a 0 LSB, ignore it */
24570 +#ifdef CONFIG_MPENTIUM4
24571 + time &= 0x3EUL;
24572 + time <<= 2;
24573 +#elif defined(CONFIG_X86_64)
24574 + time &= 0xFUL;
24575 + time <<= 4;
24576 +#else
24577 + time &= 0x1FUL;
24578 + time <<= 3;
24579 +#endif
24580 +
24581 + thread->sp0 ^= time;
24582 + load_sp0(init_tss + smp_processor_id(), thread);
24583 +
24584 +#ifdef CONFIG_X86_64
24585 + this_cpu_write(kernel_stack, thread->sp0);
24586 +#endif
24587 +}
24588 +#endif
24589 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24590 index 884f98f..ec23e04 100644
24591 --- a/arch/x86/kernel/process_32.c
24592 +++ b/arch/x86/kernel/process_32.c
24593 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24594 unsigned long thread_saved_pc(struct task_struct *tsk)
24595 {
24596 return ((unsigned long *)tsk->thread.sp)[3];
24597 +//XXX return tsk->thread.eip;
24598 }
24599
24600 void __show_regs(struct pt_regs *regs, int all)
24601 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24602 unsigned long sp;
24603 unsigned short ss, gs;
24604
24605 - if (user_mode_vm(regs)) {
24606 + if (user_mode(regs)) {
24607 sp = regs->sp;
24608 ss = regs->ss & 0xffff;
24609 - gs = get_user_gs(regs);
24610 } else {
24611 sp = kernel_stack_pointer(regs);
24612 savesegment(ss, ss);
24613 - savesegment(gs, gs);
24614 }
24615 + gs = get_user_gs(regs);
24616
24617 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24618 (u16)regs->cs, regs->ip, regs->flags,
24619 - smp_processor_id());
24620 + raw_smp_processor_id());
24621 print_symbol("EIP is at %s\n", regs->ip);
24622
24623 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24624 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24625 int copy_thread(unsigned long clone_flags, unsigned long sp,
24626 unsigned long arg, struct task_struct *p)
24627 {
24628 - struct pt_regs *childregs = task_pt_regs(p);
24629 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24630 struct task_struct *tsk;
24631 int err;
24632
24633 p->thread.sp = (unsigned long) childregs;
24634 p->thread.sp0 = (unsigned long) (childregs+1);
24635 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24636
24637 if (unlikely(p->flags & PF_KTHREAD)) {
24638 /* kernel thread */
24639 memset(childregs, 0, sizeof(struct pt_regs));
24640 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24641 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24642 - childregs->ds = __USER_DS;
24643 - childregs->es = __USER_DS;
24644 + savesegment(gs, childregs->gs);
24645 + childregs->ds = __KERNEL_DS;
24646 + childregs->es = __KERNEL_DS;
24647 childregs->fs = __KERNEL_PERCPU;
24648 childregs->bx = sp; /* function */
24649 childregs->bp = arg;
24650 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24651 struct thread_struct *prev = &prev_p->thread,
24652 *next = &next_p->thread;
24653 int cpu = smp_processor_id();
24654 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24655 + struct tss_struct *tss = init_tss + cpu;
24656 fpu_switch_t fpu;
24657
24658 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24659 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24660 */
24661 lazy_save_gs(prev->gs);
24662
24663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24664 + __set_fs(task_thread_info(next_p)->addr_limit);
24665 +#endif
24666 +
24667 /*
24668 * Load the per-thread Thread-Local Storage descriptor.
24669 */
24670 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24671 */
24672 arch_end_context_switch(next_p);
24673
24674 + this_cpu_write(current_task, next_p);
24675 + this_cpu_write(current_tinfo, &next_p->tinfo);
24676 +
24677 /*
24678 * Restore %gs if needed (which is common)
24679 */
24680 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24681
24682 switch_fpu_finish(next_p, fpu);
24683
24684 - this_cpu_write(current_task, next_p);
24685 -
24686 return prev_p;
24687 }
24688
24689 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24690 } while (count++ < 16);
24691 return 0;
24692 }
24693 -
24694 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24695 index bb1dc51..08dda7f 100644
24696 --- a/arch/x86/kernel/process_64.c
24697 +++ b/arch/x86/kernel/process_64.c
24698 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24699 struct pt_regs *childregs;
24700 struct task_struct *me = current;
24701
24702 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24703 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24704 childregs = task_pt_regs(p);
24705 p->thread.sp = (unsigned long) childregs;
24706 p->thread.usersp = me->thread.usersp;
24707 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24708 set_tsk_thread_flag(p, TIF_FORK);
24709 p->fpu_counter = 0;
24710 p->thread.io_bitmap_ptr = NULL;
24711 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24712 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24713 savesegment(es, p->thread.es);
24714 savesegment(ds, p->thread.ds);
24715 + savesegment(ss, p->thread.ss);
24716 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24717 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24718
24719 if (unlikely(p->flags & PF_KTHREAD)) {
24720 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24721 struct thread_struct *prev = &prev_p->thread;
24722 struct thread_struct *next = &next_p->thread;
24723 int cpu = smp_processor_id();
24724 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24725 + struct tss_struct *tss = init_tss + cpu;
24726 unsigned fsindex, gsindex;
24727 fpu_switch_t fpu;
24728
24729 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24730 if (unlikely(next->ds | prev->ds))
24731 loadsegment(ds, next->ds);
24732
24733 + savesegment(ss, prev->ss);
24734 + if (unlikely(next->ss != prev->ss))
24735 + loadsegment(ss, next->ss);
24736
24737 /* We must save %fs and %gs before load_TLS() because
24738 * %fs and %gs may be cleared by load_TLS().
24739 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24740 prev->usersp = this_cpu_read(old_rsp);
24741 this_cpu_write(old_rsp, next->usersp);
24742 this_cpu_write(current_task, next_p);
24743 + this_cpu_write(current_tinfo, &next_p->tinfo);
24744
24745 - this_cpu_write(kernel_stack,
24746 - (unsigned long)task_stack_page(next_p) +
24747 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24748 + this_cpu_write(kernel_stack, next->sp0);
24749
24750 /*
24751 * Now maybe reload the debug registers and handle I/O bitmaps
24752 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24753 if (!p || p == current || p->state == TASK_RUNNING)
24754 return 0;
24755 stack = (unsigned long)task_stack_page(p);
24756 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24757 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24758 return 0;
24759 fp = *(u64 *)(p->thread.sp);
24760 do {
24761 - if (fp < (unsigned long)stack ||
24762 - fp >= (unsigned long)stack+THREAD_SIZE)
24763 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24764 return 0;
24765 ip = *(u64 *)(fp+8);
24766 if (!in_sched_functions(ip))
24767 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24768 index 7461f50..1334029 100644
24769 --- a/arch/x86/kernel/ptrace.c
24770 +++ b/arch/x86/kernel/ptrace.c
24771 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24772 {
24773 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24774 unsigned long sp = (unsigned long)&regs->sp;
24775 - struct thread_info *tinfo;
24776
24777 - if (context == (sp & ~(THREAD_SIZE - 1)))
24778 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24779 return sp;
24780
24781 - tinfo = (struct thread_info *)context;
24782 - if (tinfo->previous_esp)
24783 - return tinfo->previous_esp;
24784 + sp = *(unsigned long *)context;
24785 + if (sp)
24786 + return sp;
24787
24788 return (unsigned long)regs;
24789 }
24790 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24791 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24792 {
24793 int i;
24794 - int dr7 = 0;
24795 + unsigned long dr7 = 0;
24796 struct arch_hw_breakpoint *info;
24797
24798 for (i = 0; i < HBP_NUM; i++) {
24799 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24800 unsigned long addr, unsigned long data)
24801 {
24802 int ret;
24803 - unsigned long __user *datap = (unsigned long __user *)data;
24804 + unsigned long __user *datap = (__force unsigned long __user *)data;
24805
24806 switch (request) {
24807 /* read the word at location addr in the USER area. */
24808 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24809 if ((int) addr < 0)
24810 return -EIO;
24811 ret = do_get_thread_area(child, addr,
24812 - (struct user_desc __user *)data);
24813 + (__force struct user_desc __user *) data);
24814 break;
24815
24816 case PTRACE_SET_THREAD_AREA:
24817 if ((int) addr < 0)
24818 return -EIO;
24819 ret = do_set_thread_area(child, addr,
24820 - (struct user_desc __user *)data, 0);
24821 + (__force struct user_desc __user *) data, 0);
24822 break;
24823 #endif
24824
24825 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24826
24827 #ifdef CONFIG_X86_64
24828
24829 -static struct user_regset x86_64_regsets[] __read_mostly = {
24830 +static user_regset_no_const x86_64_regsets[] __read_only = {
24831 [REGSET_GENERAL] = {
24832 .core_note_type = NT_PRSTATUS,
24833 .n = sizeof(struct user_regs_struct) / sizeof(long),
24834 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24835 #endif /* CONFIG_X86_64 */
24836
24837 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24838 -static struct user_regset x86_32_regsets[] __read_mostly = {
24839 +static user_regset_no_const x86_32_regsets[] __read_only = {
24840 [REGSET_GENERAL] = {
24841 .core_note_type = NT_PRSTATUS,
24842 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24843 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24844 */
24845 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24846
24847 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24848 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24849 {
24850 #ifdef CONFIG_X86_64
24851 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24852 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24853 memset(info, 0, sizeof(*info));
24854 info->si_signo = SIGTRAP;
24855 info->si_code = si_code;
24856 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24857 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24858 }
24859
24860 void user_single_step_siginfo(struct task_struct *tsk,
24861 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24862 # define IS_IA32 0
24863 #endif
24864
24865 +#ifdef CONFIG_GRKERNSEC_SETXID
24866 +extern void gr_delayed_cred_worker(void);
24867 +#endif
24868 +
24869 /*
24870 * We must return the syscall number to actually look up in the table.
24871 * This can be -1L to skip running any syscall at all.
24872 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24873
24874 user_exit();
24875
24876 +#ifdef CONFIG_GRKERNSEC_SETXID
24877 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24878 + gr_delayed_cred_worker();
24879 +#endif
24880 +
24881 /*
24882 * If we stepped into a sysenter/syscall insn, it trapped in
24883 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24884 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24885 */
24886 user_exit();
24887
24888 +#ifdef CONFIG_GRKERNSEC_SETXID
24889 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24890 + gr_delayed_cred_worker();
24891 +#endif
24892 +
24893 audit_syscall_exit(regs);
24894
24895 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24896 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24897 index a16bae3..1f65f25 100644
24898 --- a/arch/x86/kernel/pvclock.c
24899 +++ b/arch/x86/kernel/pvclock.c
24900 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24901 return pv_tsc_khz;
24902 }
24903
24904 -static atomic64_t last_value = ATOMIC64_INIT(0);
24905 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24906
24907 void pvclock_resume(void)
24908 {
24909 - atomic64_set(&last_value, 0);
24910 + atomic64_set_unchecked(&last_value, 0);
24911 }
24912
24913 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24914 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24915 * updating at the same time, and one of them could be slightly behind,
24916 * making the assumption that last_value always go forward fail to hold.
24917 */
24918 - last = atomic64_read(&last_value);
24919 + last = atomic64_read_unchecked(&last_value);
24920 do {
24921 if (ret < last)
24922 return last;
24923 - last = atomic64_cmpxchg(&last_value, last, ret);
24924 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24925 } while (unlikely(last != ret));
24926
24927 return ret;
24928 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24929 index 7e920bf..cc24446 100644
24930 --- a/arch/x86/kernel/reboot.c
24931 +++ b/arch/x86/kernel/reboot.c
24932 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24933
24934 void __noreturn machine_real_restart(unsigned int type)
24935 {
24936 +
24937 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24938 + struct desc_struct *gdt;
24939 +#endif
24940 +
24941 local_irq_disable();
24942
24943 /*
24944 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24945
24946 /* Jump to the identity-mapped low memory code */
24947 #ifdef CONFIG_X86_32
24948 - asm volatile("jmpl *%0" : :
24949 +
24950 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24951 + gdt = get_cpu_gdt_table(smp_processor_id());
24952 + pax_open_kernel();
24953 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24954 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24955 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24956 + loadsegment(ds, __KERNEL_DS);
24957 + loadsegment(es, __KERNEL_DS);
24958 + loadsegment(ss, __KERNEL_DS);
24959 +#endif
24960 +#ifdef CONFIG_PAX_KERNEXEC
24961 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24962 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24963 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24964 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24965 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24966 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24967 +#endif
24968 + pax_close_kernel();
24969 +#endif
24970 +
24971 + asm volatile("ljmpl *%0" : :
24972 "rm" (real_mode_header->machine_real_restart_asm),
24973 "a" (type));
24974 #else
24975 @@ -466,7 +493,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24976 * try to force a triple fault and then cycle between hitting the keyboard
24977 * controller and doing that
24978 */
24979 -static void native_machine_emergency_restart(void)
24980 +static void __noreturn native_machine_emergency_restart(void)
24981 {
24982 int i;
24983 int attempt = 0;
24984 @@ -575,13 +602,13 @@ void native_machine_shutdown(void)
24985 #endif
24986 }
24987
24988 -static void __machine_emergency_restart(int emergency)
24989 +static void __noreturn __machine_emergency_restart(int emergency)
24990 {
24991 reboot_emergency = emergency;
24992 machine_ops.emergency_restart();
24993 }
24994
24995 -static void native_machine_restart(char *__unused)
24996 +static void __noreturn native_machine_restart(char *__unused)
24997 {
24998 pr_notice("machine restart\n");
24999
25000 @@ -590,7 +617,7 @@ static void native_machine_restart(char *__unused)
25001 __machine_emergency_restart(0);
25002 }
25003
25004 -static void native_machine_halt(void)
25005 +static void __noreturn native_machine_halt(void)
25006 {
25007 /* Stop other cpus and apics */
25008 machine_shutdown();
25009 @@ -600,7 +627,7 @@ static void native_machine_halt(void)
25010 stop_this_cpu(NULL);
25011 }
25012
25013 -static void native_machine_power_off(void)
25014 +static void __noreturn native_machine_power_off(void)
25015 {
25016 if (pm_power_off) {
25017 if (!reboot_force)
25018 @@ -609,9 +636,10 @@ static void native_machine_power_off(void)
25019 }
25020 /* A fallback in case there is no PM info available */
25021 tboot_shutdown(TB_SHUTDOWN_HALT);
25022 + unreachable();
25023 }
25024
25025 -struct machine_ops machine_ops = {
25026 +struct machine_ops machine_ops __read_only = {
25027 .power_off = native_machine_power_off,
25028 .shutdown = native_machine_shutdown,
25029 .emergency_restart = native_machine_emergency_restart,
25030 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25031 index c8e41e9..64049ef 100644
25032 --- a/arch/x86/kernel/reboot_fixups_32.c
25033 +++ b/arch/x86/kernel/reboot_fixups_32.c
25034 @@ -57,7 +57,7 @@ struct device_fixup {
25035 unsigned int vendor;
25036 unsigned int device;
25037 void (*reboot_fixup)(struct pci_dev *);
25038 -};
25039 +} __do_const;
25040
25041 /*
25042 * PCI ids solely used for fixups_table go here
25043 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25044 index 3fd2c69..16ef367 100644
25045 --- a/arch/x86/kernel/relocate_kernel_64.S
25046 +++ b/arch/x86/kernel/relocate_kernel_64.S
25047 @@ -11,6 +11,7 @@
25048 #include <asm/kexec.h>
25049 #include <asm/processor-flags.h>
25050 #include <asm/pgtable_types.h>
25051 +#include <asm/alternative-asm.h>
25052
25053 /*
25054 * Must be relocatable PIC code callable as a C function
25055 @@ -96,8 +97,7 @@ relocate_kernel:
25056
25057 /* jump to identity mapped page */
25058 addq $(identity_mapped - relocate_kernel), %r8
25059 - pushq %r8
25060 - ret
25061 + jmp *%r8
25062
25063 identity_mapped:
25064 /* set return address to 0 if not preserving context */
25065 @@ -167,6 +167,7 @@ identity_mapped:
25066 xorl %r14d, %r14d
25067 xorl %r15d, %r15d
25068
25069 + pax_force_retaddr 0, 1
25070 ret
25071
25072 1:
25073 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25074 index f0de629..a4978a8f 100644
25075 --- a/arch/x86/kernel/setup.c
25076 +++ b/arch/x86/kernel/setup.c
25077 @@ -110,6 +110,7 @@
25078 #include <asm/mce.h>
25079 #include <asm/alternative.h>
25080 #include <asm/prom.h>
25081 +#include <asm/boot.h>
25082
25083 /*
25084 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25085 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25086 #endif
25087
25088
25089 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25090 -__visible unsigned long mmu_cr4_features;
25091 +#ifdef CONFIG_X86_64
25092 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25093 +#elif defined(CONFIG_X86_PAE)
25094 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25095 #else
25096 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
25097 +__visible unsigned long mmu_cr4_features __read_only;
25098 #endif
25099
25100 +void set_in_cr4(unsigned long mask)
25101 +{
25102 + unsigned long cr4 = read_cr4();
25103 +
25104 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25105 + return;
25106 +
25107 + pax_open_kernel();
25108 + mmu_cr4_features |= mask;
25109 + pax_close_kernel();
25110 +
25111 + if (trampoline_cr4_features)
25112 + *trampoline_cr4_features = mmu_cr4_features;
25113 + cr4 |= mask;
25114 + write_cr4(cr4);
25115 +}
25116 +EXPORT_SYMBOL(set_in_cr4);
25117 +
25118 +void clear_in_cr4(unsigned long mask)
25119 +{
25120 + unsigned long cr4 = read_cr4();
25121 +
25122 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25123 + return;
25124 +
25125 + pax_open_kernel();
25126 + mmu_cr4_features &= ~mask;
25127 + pax_close_kernel();
25128 +
25129 + if (trampoline_cr4_features)
25130 + *trampoline_cr4_features = mmu_cr4_features;
25131 + cr4 &= ~mask;
25132 + write_cr4(cr4);
25133 +}
25134 +EXPORT_SYMBOL(clear_in_cr4);
25135 +
25136 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25137 int bootloader_type, bootloader_version;
25138
25139 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25140 * area (640->1Mb) as ram even though it is not.
25141 * take them out.
25142 */
25143 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25144 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25145
25146 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25147 }
25148 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25149 /* called before trim_bios_range() to spare extra sanitize */
25150 static void __init e820_add_kernel_range(void)
25151 {
25152 - u64 start = __pa_symbol(_text);
25153 + u64 start = __pa_symbol(ktla_ktva(_text));
25154 u64 size = __pa_symbol(_end) - start;
25155
25156 /*
25157 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25158
25159 void __init setup_arch(char **cmdline_p)
25160 {
25161 +#ifdef CONFIG_X86_32
25162 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25163 +#else
25164 memblock_reserve(__pa_symbol(_text),
25165 (unsigned long)__bss_stop - (unsigned long)_text);
25166 +#endif
25167
25168 early_reserve_initrd();
25169
25170 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25171
25172 if (!boot_params.hdr.root_flags)
25173 root_mountflags &= ~MS_RDONLY;
25174 - init_mm.start_code = (unsigned long) _text;
25175 - init_mm.end_code = (unsigned long) _etext;
25176 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25177 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25178 init_mm.end_data = (unsigned long) _edata;
25179 init_mm.brk = _brk_end;
25180
25181 - code_resource.start = __pa_symbol(_text);
25182 - code_resource.end = __pa_symbol(_etext)-1;
25183 - data_resource.start = __pa_symbol(_etext);
25184 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25185 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25186 + data_resource.start = __pa_symbol(_sdata);
25187 data_resource.end = __pa_symbol(_edata)-1;
25188 bss_resource.start = __pa_symbol(__bss_start);
25189 bss_resource.end = __pa_symbol(__bss_stop)-1;
25190 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25191 index 5cdff03..80fa283 100644
25192 --- a/arch/x86/kernel/setup_percpu.c
25193 +++ b/arch/x86/kernel/setup_percpu.c
25194 @@ -21,19 +21,17 @@
25195 #include <asm/cpu.h>
25196 #include <asm/stackprotector.h>
25197
25198 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25199 +#ifdef CONFIG_SMP
25200 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25201 EXPORT_PER_CPU_SYMBOL(cpu_number);
25202 +#endif
25203
25204 -#ifdef CONFIG_X86_64
25205 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25206 -#else
25207 -#define BOOT_PERCPU_OFFSET 0
25208 -#endif
25209
25210 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25211 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25212
25213 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25214 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25215 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25216 };
25217 EXPORT_SYMBOL(__per_cpu_offset);
25218 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25219 {
25220 #ifdef CONFIG_NEED_MULTIPLE_NODES
25221 pg_data_t *last = NULL;
25222 - unsigned int cpu;
25223 + int cpu;
25224
25225 for_each_possible_cpu(cpu) {
25226 int node = early_cpu_to_node(cpu);
25227 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25228 {
25229 #ifdef CONFIG_X86_32
25230 struct desc_struct gdt;
25231 + unsigned long base = per_cpu_offset(cpu);
25232
25233 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25234 - 0x2 | DESCTYPE_S, 0x8);
25235 - gdt.s = 1;
25236 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25237 + 0x83 | DESCTYPE_S, 0xC);
25238 write_gdt_entry(get_cpu_gdt_table(cpu),
25239 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25240 #endif
25241 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25242 /* alrighty, percpu areas up and running */
25243 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25244 for_each_possible_cpu(cpu) {
25245 +#ifdef CONFIG_CC_STACKPROTECTOR
25246 +#ifdef CONFIG_X86_32
25247 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25248 +#endif
25249 +#endif
25250 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25251 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25252 per_cpu(cpu_number, cpu) = cpu;
25253 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25254 */
25255 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25256 #endif
25257 +#ifdef CONFIG_CC_STACKPROTECTOR
25258 +#ifdef CONFIG_X86_32
25259 + if (!cpu)
25260 + per_cpu(stack_canary.canary, cpu) = canary;
25261 +#endif
25262 +#endif
25263 /*
25264 * Up to this point, the boot CPU has been using .init.data
25265 * area. Reload any changed state for the boot CPU.
25266 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25267 index 9e5de68..16c53cb 100644
25268 --- a/arch/x86/kernel/signal.c
25269 +++ b/arch/x86/kernel/signal.c
25270 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25271 * Align the stack pointer according to the i386 ABI,
25272 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25273 */
25274 - sp = ((sp + 4) & -16ul) - 4;
25275 + sp = ((sp - 12) & -16ul) - 4;
25276 #else /* !CONFIG_X86_32 */
25277 sp = round_down(sp, 16) - 8;
25278 #endif
25279 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25280 }
25281
25282 if (current->mm->context.vdso)
25283 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25284 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25285 else
25286 - restorer = &frame->retcode;
25287 + restorer = (void __user *)&frame->retcode;
25288 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25289 restorer = ksig->ka.sa.sa_restorer;
25290
25291 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25292 * reasons and because gdb uses it as a signature to notice
25293 * signal handler stack frames.
25294 */
25295 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25296 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25297
25298 if (err)
25299 return -EFAULT;
25300 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25301 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25302
25303 /* Set up to return from userspace. */
25304 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25305 + if (current->mm->context.vdso)
25306 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25307 + else
25308 + restorer = (void __user *)&frame->retcode;
25309 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25310 restorer = ksig->ka.sa.sa_restorer;
25311 put_user_ex(restorer, &frame->pretcode);
25312 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25313 * reasons and because gdb uses it as a signature to notice
25314 * signal handler stack frames.
25315 */
25316 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25317 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25318 } put_user_catch(err);
25319
25320 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25321 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25322 {
25323 int usig = signr_convert(ksig->sig);
25324 sigset_t *set = sigmask_to_save();
25325 - compat_sigset_t *cset = (compat_sigset_t *) set;
25326 + sigset_t sigcopy;
25327 + compat_sigset_t *cset;
25328 +
25329 + sigcopy = *set;
25330 +
25331 + cset = (compat_sigset_t *) &sigcopy;
25332
25333 /* Set up the stack frame */
25334 if (is_ia32_frame()) {
25335 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25336 } else if (is_x32_frame()) {
25337 return x32_setup_rt_frame(ksig, cset, regs);
25338 } else {
25339 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25340 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25341 }
25342 }
25343
25344 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25345 index 7c3a5a6..f0a8961 100644
25346 --- a/arch/x86/kernel/smp.c
25347 +++ b/arch/x86/kernel/smp.c
25348 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25349
25350 __setup("nonmi_ipi", nonmi_ipi_setup);
25351
25352 -struct smp_ops smp_ops = {
25353 +struct smp_ops smp_ops __read_only = {
25354 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25355 .smp_prepare_cpus = native_smp_prepare_cpus,
25356 .smp_cpus_done = native_smp_cpus_done,
25357 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25358 index 6cacab6..750636a 100644
25359 --- a/arch/x86/kernel/smpboot.c
25360 +++ b/arch/x86/kernel/smpboot.c
25361 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25362
25363 enable_start_cpu0 = 0;
25364
25365 -#ifdef CONFIG_X86_32
25366 - /* switch away from the initial page table */
25367 - load_cr3(swapper_pg_dir);
25368 - __flush_tlb_all();
25369 -#endif
25370 -
25371 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25372 barrier();
25373 +
25374 + /* switch away from the initial page table */
25375 +#ifdef CONFIG_PAX_PER_CPU_PGD
25376 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25377 + __flush_tlb_all();
25378 +#elif defined(CONFIG_X86_32)
25379 + load_cr3(swapper_pg_dir);
25380 + __flush_tlb_all();
25381 +#endif
25382 +
25383 /*
25384 * Check TSC synchronization with the BP:
25385 */
25386 @@ -749,6 +753,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25387 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25388 (THREAD_SIZE + task_stack_page(idle))) - 1);
25389 per_cpu(current_task, cpu) = idle;
25390 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25391
25392 #ifdef CONFIG_X86_32
25393 /* Stack for startup_32 can be just as for start_secondary onwards */
25394 @@ -756,11 +761,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25395 #else
25396 clear_tsk_thread_flag(idle, TIF_FORK);
25397 initial_gs = per_cpu_offset(cpu);
25398 - per_cpu(kernel_stack, cpu) =
25399 - (unsigned long)task_stack_page(idle) -
25400 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25401 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25402 #endif
25403 +
25404 + pax_open_kernel();
25405 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25406 + pax_close_kernel();
25407 +
25408 initial_code = (unsigned long)start_secondary;
25409 stack_start = idle->thread.sp;
25410
25411 @@ -909,6 +916,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25412 /* the FPU context is blank, nobody can own it */
25413 __cpu_disable_lazy_restore(cpu);
25414
25415 +#ifdef CONFIG_PAX_PER_CPU_PGD
25416 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25417 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25418 + KERNEL_PGD_PTRS);
25419 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25420 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25421 + KERNEL_PGD_PTRS);
25422 +#endif
25423 +
25424 err = do_boot_cpu(apicid, cpu, tidle);
25425 if (err) {
25426 pr_debug("do_boot_cpu failed %d\n", err);
25427 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25428 index 9b4d51d..5d28b58 100644
25429 --- a/arch/x86/kernel/step.c
25430 +++ b/arch/x86/kernel/step.c
25431 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25432 struct desc_struct *desc;
25433 unsigned long base;
25434
25435 - seg &= ~7UL;
25436 + seg >>= 3;
25437
25438 mutex_lock(&child->mm->context.lock);
25439 - if (unlikely((seg >> 3) >= child->mm->context.size))
25440 + if (unlikely(seg >= child->mm->context.size))
25441 addr = -1L; /* bogus selector, access would fault */
25442 else {
25443 desc = child->mm->context.ldt + seg;
25444 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25445 addr += base;
25446 }
25447 mutex_unlock(&child->mm->context.lock);
25448 - }
25449 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25450 + addr = ktla_ktva(addr);
25451
25452 return addr;
25453 }
25454 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25455 unsigned char opcode[15];
25456 unsigned long addr = convert_ip_to_linear(child, regs);
25457
25458 + if (addr == -EINVAL)
25459 + return 0;
25460 +
25461 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25462 for (i = 0; i < copied; i++) {
25463 switch (opcode[i]) {
25464 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25465 new file mode 100644
25466 index 0000000..5877189
25467 --- /dev/null
25468 +++ b/arch/x86/kernel/sys_i386_32.c
25469 @@ -0,0 +1,189 @@
25470 +/*
25471 + * This file contains various random system calls that
25472 + * have a non-standard calling sequence on the Linux/i386
25473 + * platform.
25474 + */
25475 +
25476 +#include <linux/errno.h>
25477 +#include <linux/sched.h>
25478 +#include <linux/mm.h>
25479 +#include <linux/fs.h>
25480 +#include <linux/smp.h>
25481 +#include <linux/sem.h>
25482 +#include <linux/msg.h>
25483 +#include <linux/shm.h>
25484 +#include <linux/stat.h>
25485 +#include <linux/syscalls.h>
25486 +#include <linux/mman.h>
25487 +#include <linux/file.h>
25488 +#include <linux/utsname.h>
25489 +#include <linux/ipc.h>
25490 +#include <linux/elf.h>
25491 +
25492 +#include <linux/uaccess.h>
25493 +#include <linux/unistd.h>
25494 +
25495 +#include <asm/syscalls.h>
25496 +
25497 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25498 +{
25499 + unsigned long pax_task_size = TASK_SIZE;
25500 +
25501 +#ifdef CONFIG_PAX_SEGMEXEC
25502 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25503 + pax_task_size = SEGMEXEC_TASK_SIZE;
25504 +#endif
25505 +
25506 + if (flags & MAP_FIXED)
25507 + if (len > pax_task_size || addr > pax_task_size - len)
25508 + return -EINVAL;
25509 +
25510 + return 0;
25511 +}
25512 +
25513 +/*
25514 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25515 + */
25516 +static unsigned long get_align_mask(void)
25517 +{
25518 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25519 + return 0;
25520 +
25521 + if (!(current->flags & PF_RANDOMIZE))
25522 + return 0;
25523 +
25524 + return va_align.mask;
25525 +}
25526 +
25527 +unsigned long
25528 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25529 + unsigned long len, unsigned long pgoff, unsigned long flags)
25530 +{
25531 + struct mm_struct *mm = current->mm;
25532 + struct vm_area_struct *vma;
25533 + unsigned long pax_task_size = TASK_SIZE;
25534 + struct vm_unmapped_area_info info;
25535 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25536 +
25537 +#ifdef CONFIG_PAX_SEGMEXEC
25538 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25539 + pax_task_size = SEGMEXEC_TASK_SIZE;
25540 +#endif
25541 +
25542 + pax_task_size -= PAGE_SIZE;
25543 +
25544 + if (len > pax_task_size)
25545 + return -ENOMEM;
25546 +
25547 + if (flags & MAP_FIXED)
25548 + return addr;
25549 +
25550 +#ifdef CONFIG_PAX_RANDMMAP
25551 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25552 +#endif
25553 +
25554 + if (addr) {
25555 + addr = PAGE_ALIGN(addr);
25556 + if (pax_task_size - len >= addr) {
25557 + vma = find_vma(mm, addr);
25558 + if (check_heap_stack_gap(vma, addr, len, offset))
25559 + return addr;
25560 + }
25561 + }
25562 +
25563 + info.flags = 0;
25564 + info.length = len;
25565 + info.align_mask = filp ? get_align_mask() : 0;
25566 + info.align_offset = pgoff << PAGE_SHIFT;
25567 + info.threadstack_offset = offset;
25568 +
25569 +#ifdef CONFIG_PAX_PAGEEXEC
25570 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25571 + info.low_limit = 0x00110000UL;
25572 + info.high_limit = mm->start_code;
25573 +
25574 +#ifdef CONFIG_PAX_RANDMMAP
25575 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25576 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25577 +#endif
25578 +
25579 + if (info.low_limit < info.high_limit) {
25580 + addr = vm_unmapped_area(&info);
25581 + if (!IS_ERR_VALUE(addr))
25582 + return addr;
25583 + }
25584 + } else
25585 +#endif
25586 +
25587 + info.low_limit = mm->mmap_base;
25588 + info.high_limit = pax_task_size;
25589 +
25590 + return vm_unmapped_area(&info);
25591 +}
25592 +
25593 +unsigned long
25594 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25595 + const unsigned long len, const unsigned long pgoff,
25596 + const unsigned long flags)
25597 +{
25598 + struct vm_area_struct *vma;
25599 + struct mm_struct *mm = current->mm;
25600 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25601 + struct vm_unmapped_area_info info;
25602 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25603 +
25604 +#ifdef CONFIG_PAX_SEGMEXEC
25605 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25606 + pax_task_size = SEGMEXEC_TASK_SIZE;
25607 +#endif
25608 +
25609 + pax_task_size -= PAGE_SIZE;
25610 +
25611 + /* requested length too big for entire address space */
25612 + if (len > pax_task_size)
25613 + return -ENOMEM;
25614 +
25615 + if (flags & MAP_FIXED)
25616 + return addr;
25617 +
25618 +#ifdef CONFIG_PAX_PAGEEXEC
25619 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25620 + goto bottomup;
25621 +#endif
25622 +
25623 +#ifdef CONFIG_PAX_RANDMMAP
25624 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25625 +#endif
25626 +
25627 + /* requesting a specific address */
25628 + if (addr) {
25629 + addr = PAGE_ALIGN(addr);
25630 + if (pax_task_size - len >= addr) {
25631 + vma = find_vma(mm, addr);
25632 + if (check_heap_stack_gap(vma, addr, len, offset))
25633 + return addr;
25634 + }
25635 + }
25636 +
25637 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25638 + info.length = len;
25639 + info.low_limit = PAGE_SIZE;
25640 + info.high_limit = mm->mmap_base;
25641 + info.align_mask = filp ? get_align_mask() : 0;
25642 + info.align_offset = pgoff << PAGE_SHIFT;
25643 + info.threadstack_offset = offset;
25644 +
25645 + addr = vm_unmapped_area(&info);
25646 + if (!(addr & ~PAGE_MASK))
25647 + return addr;
25648 + VM_BUG_ON(addr != -ENOMEM);
25649 +
25650 +bottomup:
25651 + /*
25652 + * A failed mmap() very likely causes application failure,
25653 + * so fall back to the bottom-up function here. This scenario
25654 + * can happen with large stack limits and large mmap()
25655 + * allocations.
25656 + */
25657 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25658 +}
25659 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25660 index 30277e2..5664a29 100644
25661 --- a/arch/x86/kernel/sys_x86_64.c
25662 +++ b/arch/x86/kernel/sys_x86_64.c
25663 @@ -81,8 +81,8 @@ out:
25664 return error;
25665 }
25666
25667 -static void find_start_end(unsigned long flags, unsigned long *begin,
25668 - unsigned long *end)
25669 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25670 + unsigned long *begin, unsigned long *end)
25671 {
25672 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25673 unsigned long new_begin;
25674 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25675 *begin = new_begin;
25676 }
25677 } else {
25678 - *begin = current->mm->mmap_legacy_base;
25679 + *begin = mm->mmap_legacy_base;
25680 *end = TASK_SIZE;
25681 }
25682 }
25683 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25684 struct vm_area_struct *vma;
25685 struct vm_unmapped_area_info info;
25686 unsigned long begin, end;
25687 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25688
25689 if (flags & MAP_FIXED)
25690 return addr;
25691
25692 - find_start_end(flags, &begin, &end);
25693 + find_start_end(mm, flags, &begin, &end);
25694
25695 if (len > end)
25696 return -ENOMEM;
25697
25698 +#ifdef CONFIG_PAX_RANDMMAP
25699 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25700 +#endif
25701 +
25702 if (addr) {
25703 addr = PAGE_ALIGN(addr);
25704 vma = find_vma(mm, addr);
25705 - if (end - len >= addr &&
25706 - (!vma || addr + len <= vma->vm_start))
25707 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25708 return addr;
25709 }
25710
25711 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25712 info.high_limit = end;
25713 info.align_mask = filp ? get_align_mask() : 0;
25714 info.align_offset = pgoff << PAGE_SHIFT;
25715 + info.threadstack_offset = offset;
25716 return vm_unmapped_area(&info);
25717 }
25718
25719 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25720 struct mm_struct *mm = current->mm;
25721 unsigned long addr = addr0;
25722 struct vm_unmapped_area_info info;
25723 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25724
25725 /* requested length too big for entire address space */
25726 if (len > TASK_SIZE)
25727 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25728 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25729 goto bottomup;
25730
25731 +#ifdef CONFIG_PAX_RANDMMAP
25732 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25733 +#endif
25734 +
25735 /* requesting a specific address */
25736 if (addr) {
25737 addr = PAGE_ALIGN(addr);
25738 vma = find_vma(mm, addr);
25739 - if (TASK_SIZE - len >= addr &&
25740 - (!vma || addr + len <= vma->vm_start))
25741 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25742 return addr;
25743 }
25744
25745 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25746 info.high_limit = mm->mmap_base;
25747 info.align_mask = filp ? get_align_mask() : 0;
25748 info.align_offset = pgoff << PAGE_SHIFT;
25749 + info.threadstack_offset = offset;
25750 addr = vm_unmapped_area(&info);
25751 if (!(addr & ~PAGE_MASK))
25752 return addr;
25753 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25754 index 91a4496..1730bff 100644
25755 --- a/arch/x86/kernel/tboot.c
25756 +++ b/arch/x86/kernel/tboot.c
25757 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25758
25759 void tboot_shutdown(u32 shutdown_type)
25760 {
25761 - void (*shutdown)(void);
25762 + void (* __noreturn shutdown)(void);
25763
25764 if (!tboot_enabled())
25765 return;
25766 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25767
25768 switch_to_tboot_pt();
25769
25770 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25771 + shutdown = (void *)tboot->shutdown_entry;
25772 shutdown();
25773
25774 /* should not reach here */
25775 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
25776 return -ENODEV;
25777 }
25778
25779 -static atomic_t ap_wfs_count;
25780 +static atomic_unchecked_t ap_wfs_count;
25781
25782 static int tboot_wait_for_aps(int num_aps)
25783 {
25784 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25785 {
25786 switch (action) {
25787 case CPU_DYING:
25788 - atomic_inc(&ap_wfs_count);
25789 + atomic_inc_unchecked(&ap_wfs_count);
25790 if (num_online_cpus() == 1)
25791 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25792 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25793 return NOTIFY_BAD;
25794 break;
25795 }
25796 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
25797
25798 tboot_create_trampoline();
25799
25800 - atomic_set(&ap_wfs_count, 0);
25801 + atomic_set_unchecked(&ap_wfs_count, 0);
25802 register_hotcpu_notifier(&tboot_cpu_notifier);
25803
25804 #ifdef CONFIG_DEBUG_FS
25805 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25806 index 24d3c91..d06b473 100644
25807 --- a/arch/x86/kernel/time.c
25808 +++ b/arch/x86/kernel/time.c
25809 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25810 {
25811 unsigned long pc = instruction_pointer(regs);
25812
25813 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25814 + if (!user_mode(regs) && in_lock_functions(pc)) {
25815 #ifdef CONFIG_FRAME_POINTER
25816 - return *(unsigned long *)(regs->bp + sizeof(long));
25817 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25818 #else
25819 unsigned long *sp =
25820 (unsigned long *)kernel_stack_pointer(regs);
25821 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25822 * or above a saved flags. Eflags has bits 22-31 zero,
25823 * kernel addresses don't.
25824 */
25825 +
25826 +#ifdef CONFIG_PAX_KERNEXEC
25827 + return ktla_ktva(sp[0]);
25828 +#else
25829 if (sp[0] >> 22)
25830 return sp[0];
25831 if (sp[1] >> 22)
25832 return sp[1];
25833 #endif
25834 +
25835 +#endif
25836 }
25837 return pc;
25838 }
25839 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25840 index f7fec09..9991981 100644
25841 --- a/arch/x86/kernel/tls.c
25842 +++ b/arch/x86/kernel/tls.c
25843 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25844 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25845 return -EINVAL;
25846
25847 +#ifdef CONFIG_PAX_SEGMEXEC
25848 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25849 + return -EINVAL;
25850 +#endif
25851 +
25852 set_tls_desc(p, idx, &info, 1);
25853
25854 return 0;
25855 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25856
25857 if (kbuf)
25858 info = kbuf;
25859 - else if (__copy_from_user(infobuf, ubuf, count))
25860 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25861 return -EFAULT;
25862 else
25863 info = infobuf;
25864 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25865 index 1c113db..287b42e 100644
25866 --- a/arch/x86/kernel/tracepoint.c
25867 +++ b/arch/x86/kernel/tracepoint.c
25868 @@ -9,11 +9,11 @@
25869 #include <linux/atomic.h>
25870
25871 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25872 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25873 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25874 (unsigned long) trace_idt_table };
25875
25876 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25877 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25878 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25879
25880 static int trace_irq_vector_refcount;
25881 static DEFINE_MUTEX(irq_vector_mutex);
25882 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25883 index 8c8093b..c93f581 100644
25884 --- a/arch/x86/kernel/traps.c
25885 +++ b/arch/x86/kernel/traps.c
25886 @@ -66,7 +66,7 @@
25887 #include <asm/proto.h>
25888
25889 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25890 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25891 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25892 #else
25893 #include <asm/processor-flags.h>
25894 #include <asm/setup.h>
25895 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
25896 #endif
25897
25898 /* Must be page-aligned because the real IDT is used in a fixmap. */
25899 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25900 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25901
25902 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25903 EXPORT_SYMBOL_GPL(used_vectors);
25904 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25905 }
25906
25907 static int __kprobes
25908 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25909 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25910 struct pt_regs *regs, long error_code)
25911 {
25912 #ifdef CONFIG_X86_32
25913 - if (regs->flags & X86_VM_MASK) {
25914 + if (v8086_mode(regs)) {
25915 /*
25916 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25917 * On nmi (interrupt 2), do_trap should not be called.
25918 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25919 return -1;
25920 }
25921 #endif
25922 - if (!user_mode(regs)) {
25923 + if (!user_mode_novm(regs)) {
25924 if (!fixup_exception(regs)) {
25925 tsk->thread.error_code = error_code;
25926 tsk->thread.trap_nr = trapnr;
25927 +
25928 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25929 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25930 + str = "PAX: suspicious stack segment fault";
25931 +#endif
25932 +
25933 die(str, regs, error_code);
25934 }
25935 +
25936 +#ifdef CONFIG_PAX_REFCOUNT
25937 + if (trapnr == 4)
25938 + pax_report_refcount_overflow(regs);
25939 +#endif
25940 +
25941 return 0;
25942 }
25943
25944 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25945 }
25946
25947 static void __kprobes
25948 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25949 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25950 long error_code, siginfo_t *info)
25951 {
25952 struct task_struct *tsk = current;
25953 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25954 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25955 printk_ratelimit()) {
25956 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25957 - tsk->comm, tsk->pid, str,
25958 + tsk->comm, task_pid_nr(tsk), str,
25959 regs->ip, regs->sp, error_code);
25960 print_vma_addr(" in ", regs->ip);
25961 pr_cont("\n");
25962 @@ -277,7 +289,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25963 conditional_sti(regs);
25964
25965 #ifdef CONFIG_X86_32
25966 - if (regs->flags & X86_VM_MASK) {
25967 + if (v8086_mode(regs)) {
25968 local_irq_enable();
25969 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25970 goto exit;
25971 @@ -285,18 +297,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25972 #endif
25973
25974 tsk = current;
25975 - if (!user_mode(regs)) {
25976 + if (!user_mode_novm(regs)) {
25977 if (fixup_exception(regs))
25978 goto exit;
25979
25980 tsk->thread.error_code = error_code;
25981 tsk->thread.trap_nr = X86_TRAP_GP;
25982 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25983 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25984 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25985 +
25986 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25987 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25988 + die("PAX: suspicious general protection fault", regs, error_code);
25989 + else
25990 +#endif
25991 +
25992 die("general protection fault", regs, error_code);
25993 + }
25994 goto exit;
25995 }
25996
25997 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25998 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25999 + struct mm_struct *mm = tsk->mm;
26000 + unsigned long limit;
26001 +
26002 + down_write(&mm->mmap_sem);
26003 + limit = mm->context.user_cs_limit;
26004 + if (limit < TASK_SIZE) {
26005 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26006 + up_write(&mm->mmap_sem);
26007 + return;
26008 + }
26009 + up_write(&mm->mmap_sem);
26010 + }
26011 +#endif
26012 +
26013 tsk->thread.error_code = error_code;
26014 tsk->thread.trap_nr = X86_TRAP_GP;
26015
26016 @@ -457,7 +493,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26017 /* It's safe to allow irq's after DR6 has been saved */
26018 preempt_conditional_sti(regs);
26019
26020 - if (regs->flags & X86_VM_MASK) {
26021 + if (v8086_mode(regs)) {
26022 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26023 X86_TRAP_DB);
26024 preempt_conditional_cli(regs);
26025 @@ -472,7 +508,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26026 * We already checked v86 mode above, so we can check for kernel mode
26027 * by just checking the CPL of CS.
26028 */
26029 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26030 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26031 tsk->thread.debugreg6 &= ~DR_STEP;
26032 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26033 regs->flags &= ~X86_EFLAGS_TF;
26034 @@ -504,7 +540,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26035 return;
26036 conditional_sti(regs);
26037
26038 - if (!user_mode_vm(regs))
26039 + if (!user_mode(regs))
26040 {
26041 if (!fixup_exception(regs)) {
26042 task->thread.error_code = error_code;
26043 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26044 index 2ed8459..7cf329f 100644
26045 --- a/arch/x86/kernel/uprobes.c
26046 +++ b/arch/x86/kernel/uprobes.c
26047 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26048 int ret = NOTIFY_DONE;
26049
26050 /* We are only interested in userspace traps */
26051 - if (regs && !user_mode_vm(regs))
26052 + if (regs && !user_mode(regs))
26053 return NOTIFY_DONE;
26054
26055 switch (val) {
26056 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26057
26058 if (ncopied != rasize) {
26059 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26060 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26061 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26062
26063 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26064 }
26065 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26066 index b9242ba..50c5edd 100644
26067 --- a/arch/x86/kernel/verify_cpu.S
26068 +++ b/arch/x86/kernel/verify_cpu.S
26069 @@ -20,6 +20,7 @@
26070 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26071 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26072 * arch/x86/kernel/head_32.S: processor startup
26073 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26074 *
26075 * verify_cpu, returns the status of longmode and SSE in register %eax.
26076 * 0: Success 1: Failure
26077 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26078 index e8edcf5..27f9344 100644
26079 --- a/arch/x86/kernel/vm86_32.c
26080 +++ b/arch/x86/kernel/vm86_32.c
26081 @@ -44,6 +44,7 @@
26082 #include <linux/ptrace.h>
26083 #include <linux/audit.h>
26084 #include <linux/stddef.h>
26085 +#include <linux/grsecurity.h>
26086
26087 #include <asm/uaccess.h>
26088 #include <asm/io.h>
26089 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26090 do_exit(SIGSEGV);
26091 }
26092
26093 - tss = &per_cpu(init_tss, get_cpu());
26094 + tss = init_tss + get_cpu();
26095 current->thread.sp0 = current->thread.saved_sp0;
26096 current->thread.sysenter_cs = __KERNEL_CS;
26097 load_sp0(tss, &current->thread);
26098 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26099
26100 if (tsk->thread.saved_sp0)
26101 return -EPERM;
26102 +
26103 +#ifdef CONFIG_GRKERNSEC_VM86
26104 + if (!capable(CAP_SYS_RAWIO)) {
26105 + gr_handle_vm86();
26106 + return -EPERM;
26107 + }
26108 +#endif
26109 +
26110 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26111 offsetof(struct kernel_vm86_struct, vm86plus) -
26112 sizeof(info.regs));
26113 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26114 int tmp;
26115 struct vm86plus_struct __user *v86;
26116
26117 +#ifdef CONFIG_GRKERNSEC_VM86
26118 + if (!capable(CAP_SYS_RAWIO)) {
26119 + gr_handle_vm86();
26120 + return -EPERM;
26121 + }
26122 +#endif
26123 +
26124 tsk = current;
26125 switch (cmd) {
26126 case VM86_REQUEST_IRQ:
26127 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26128 tsk->thread.saved_fs = info->regs32->fs;
26129 tsk->thread.saved_gs = get_user_gs(info->regs32);
26130
26131 - tss = &per_cpu(init_tss, get_cpu());
26132 + tss = init_tss + get_cpu();
26133 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26134 if (cpu_has_sep)
26135 tsk->thread.sysenter_cs = 0;
26136 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26137 goto cannot_handle;
26138 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26139 goto cannot_handle;
26140 - intr_ptr = (unsigned long __user *) (i << 2);
26141 + intr_ptr = (__force unsigned long __user *) (i << 2);
26142 if (get_user(segoffs, intr_ptr))
26143 goto cannot_handle;
26144 if ((segoffs >> 16) == BIOSSEG)
26145 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26146 index 10c4f30..65408b9 100644
26147 --- a/arch/x86/kernel/vmlinux.lds.S
26148 +++ b/arch/x86/kernel/vmlinux.lds.S
26149 @@ -26,6 +26,13 @@
26150 #include <asm/page_types.h>
26151 #include <asm/cache.h>
26152 #include <asm/boot.h>
26153 +#include <asm/segment.h>
26154 +
26155 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26156 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26157 +#else
26158 +#define __KERNEL_TEXT_OFFSET 0
26159 +#endif
26160
26161 #undef i386 /* in case the preprocessor is a 32bit one */
26162
26163 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26164
26165 PHDRS {
26166 text PT_LOAD FLAGS(5); /* R_E */
26167 +#ifdef CONFIG_X86_32
26168 + module PT_LOAD FLAGS(5); /* R_E */
26169 +#endif
26170 +#ifdef CONFIG_XEN
26171 + rodata PT_LOAD FLAGS(5); /* R_E */
26172 +#else
26173 + rodata PT_LOAD FLAGS(4); /* R__ */
26174 +#endif
26175 data PT_LOAD FLAGS(6); /* RW_ */
26176 -#ifdef CONFIG_X86_64
26177 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26178 #ifdef CONFIG_SMP
26179 percpu PT_LOAD FLAGS(6); /* RW_ */
26180 #endif
26181 + text.init PT_LOAD FLAGS(5); /* R_E */
26182 + text.exit PT_LOAD FLAGS(5); /* R_E */
26183 init PT_LOAD FLAGS(7); /* RWE */
26184 -#endif
26185 note PT_NOTE FLAGS(0); /* ___ */
26186 }
26187
26188 SECTIONS
26189 {
26190 #ifdef CONFIG_X86_32
26191 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26192 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26193 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26194 #else
26195 - . = __START_KERNEL;
26196 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26197 + . = __START_KERNEL;
26198 #endif
26199
26200 /* Text and read-only data */
26201 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26202 - _text = .;
26203 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26204 /* bootstrapping code */
26205 +#ifdef CONFIG_X86_32
26206 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26207 +#else
26208 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26209 +#endif
26210 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26211 + _text = .;
26212 HEAD_TEXT
26213 . = ALIGN(8);
26214 _stext = .;
26215 @@ -104,13 +124,47 @@ SECTIONS
26216 IRQENTRY_TEXT
26217 *(.fixup)
26218 *(.gnu.warning)
26219 - /* End of text section */
26220 - _etext = .;
26221 } :text = 0x9090
26222
26223 - NOTES :text :note
26224 + . += __KERNEL_TEXT_OFFSET;
26225
26226 - EXCEPTION_TABLE(16) :text = 0x9090
26227 +#ifdef CONFIG_X86_32
26228 + . = ALIGN(PAGE_SIZE);
26229 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26230 +
26231 +#ifdef CONFIG_PAX_KERNEXEC
26232 + MODULES_EXEC_VADDR = .;
26233 + BYTE(0)
26234 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26235 + . = ALIGN(HPAGE_SIZE) - 1;
26236 + MODULES_EXEC_END = .;
26237 +#endif
26238 +
26239 + } :module
26240 +#endif
26241 +
26242 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26243 + /* End of text section */
26244 + BYTE(0)
26245 + _etext = . - __KERNEL_TEXT_OFFSET;
26246 + }
26247 +
26248 +#ifdef CONFIG_X86_32
26249 + . = ALIGN(PAGE_SIZE);
26250 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26251 + . = ALIGN(PAGE_SIZE);
26252 + *(.empty_zero_page)
26253 + *(.initial_pg_fixmap)
26254 + *(.initial_pg_pmd)
26255 + *(.initial_page_table)
26256 + *(.swapper_pg_dir)
26257 + } :rodata
26258 +#endif
26259 +
26260 + . = ALIGN(PAGE_SIZE);
26261 + NOTES :rodata :note
26262 +
26263 + EXCEPTION_TABLE(16) :rodata
26264
26265 #if defined(CONFIG_DEBUG_RODATA)
26266 /* .text should occupy whole number of pages */
26267 @@ -122,16 +176,20 @@ SECTIONS
26268
26269 /* Data */
26270 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26271 +
26272 +#ifdef CONFIG_PAX_KERNEXEC
26273 + . = ALIGN(HPAGE_SIZE);
26274 +#else
26275 + . = ALIGN(PAGE_SIZE);
26276 +#endif
26277 +
26278 /* Start of data section */
26279 _sdata = .;
26280
26281 /* init_task */
26282 INIT_TASK_DATA(THREAD_SIZE)
26283
26284 -#ifdef CONFIG_X86_32
26285 - /* 32 bit has nosave before _edata */
26286 NOSAVE_DATA
26287 -#endif
26288
26289 PAGE_ALIGNED_DATA(PAGE_SIZE)
26290
26291 @@ -172,12 +230,19 @@ SECTIONS
26292 #endif /* CONFIG_X86_64 */
26293
26294 /* Init code and data - will be freed after init */
26295 - . = ALIGN(PAGE_SIZE);
26296 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26297 + BYTE(0)
26298 +
26299 +#ifdef CONFIG_PAX_KERNEXEC
26300 + . = ALIGN(HPAGE_SIZE);
26301 +#else
26302 + . = ALIGN(PAGE_SIZE);
26303 +#endif
26304 +
26305 __init_begin = .; /* paired with __init_end */
26306 - }
26307 + } :init.begin
26308
26309 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26310 +#ifdef CONFIG_SMP
26311 /*
26312 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26313 * output PHDR, so the next output section - .init.text - should
26314 @@ -186,12 +251,27 @@ SECTIONS
26315 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26316 #endif
26317
26318 - INIT_TEXT_SECTION(PAGE_SIZE)
26319 -#ifdef CONFIG_X86_64
26320 - :init
26321 -#endif
26322 + . = ALIGN(PAGE_SIZE);
26323 + init_begin = .;
26324 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26325 + VMLINUX_SYMBOL(_sinittext) = .;
26326 + INIT_TEXT
26327 + VMLINUX_SYMBOL(_einittext) = .;
26328 + . = ALIGN(PAGE_SIZE);
26329 + } :text.init
26330
26331 - INIT_DATA_SECTION(16)
26332 + /*
26333 + * .exit.text is discard at runtime, not link time, to deal with
26334 + * references from .altinstructions and .eh_frame
26335 + */
26336 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26337 + EXIT_TEXT
26338 + . = ALIGN(16);
26339 + } :text.exit
26340 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26341 +
26342 + . = ALIGN(PAGE_SIZE);
26343 + INIT_DATA_SECTION(16) :init
26344
26345 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26346 __x86_cpu_dev_start = .;
26347 @@ -253,19 +333,12 @@ SECTIONS
26348 }
26349
26350 . = ALIGN(8);
26351 - /*
26352 - * .exit.text is discard at runtime, not link time, to deal with
26353 - * references from .altinstructions and .eh_frame
26354 - */
26355 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26356 - EXIT_TEXT
26357 - }
26358
26359 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26360 EXIT_DATA
26361 }
26362
26363 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26364 +#ifndef CONFIG_SMP
26365 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26366 #endif
26367
26368 @@ -284,16 +357,10 @@ SECTIONS
26369 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26370 __smp_locks = .;
26371 *(.smp_locks)
26372 - . = ALIGN(PAGE_SIZE);
26373 __smp_locks_end = .;
26374 + . = ALIGN(PAGE_SIZE);
26375 }
26376
26377 -#ifdef CONFIG_X86_64
26378 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26379 - NOSAVE_DATA
26380 - }
26381 -#endif
26382 -
26383 /* BSS */
26384 . = ALIGN(PAGE_SIZE);
26385 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26386 @@ -309,6 +376,7 @@ SECTIONS
26387 __brk_base = .;
26388 . += 64 * 1024; /* 64k alignment slop space */
26389 *(.brk_reservation) /* areas brk users have reserved */
26390 + . = ALIGN(HPAGE_SIZE);
26391 __brk_limit = .;
26392 }
26393
26394 @@ -335,13 +403,12 @@ SECTIONS
26395 * for the boot processor.
26396 */
26397 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26398 -INIT_PER_CPU(gdt_page);
26399 INIT_PER_CPU(irq_stack_union);
26400
26401 /*
26402 * Build-time check on the image size:
26403 */
26404 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26405 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26406 "kernel image bigger than KERNEL_IMAGE_SIZE");
26407
26408 #ifdef CONFIG_SMP
26409 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26410 index 1f96f93..d5c8f7a 100644
26411 --- a/arch/x86/kernel/vsyscall_64.c
26412 +++ b/arch/x86/kernel/vsyscall_64.c
26413 @@ -56,15 +56,13 @@
26414 DEFINE_VVAR(int, vgetcpu_mode);
26415 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26416
26417 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26418 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26419
26420 static int __init vsyscall_setup(char *str)
26421 {
26422 if (str) {
26423 if (!strcmp("emulate", str))
26424 vsyscall_mode = EMULATE;
26425 - else if (!strcmp("native", str))
26426 - vsyscall_mode = NATIVE;
26427 else if (!strcmp("none", str))
26428 vsyscall_mode = NONE;
26429 else
26430 @@ -323,8 +321,7 @@ do_ret:
26431 return true;
26432
26433 sigsegv:
26434 - force_sig(SIGSEGV, current);
26435 - return true;
26436 + do_group_exit(SIGKILL);
26437 }
26438
26439 /*
26440 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26441 extern char __vvar_page;
26442 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26443
26444 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26445 - vsyscall_mode == NATIVE
26446 - ? PAGE_KERNEL_VSYSCALL
26447 - : PAGE_KERNEL_VVAR);
26448 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26449 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26450 (unsigned long)VSYSCALL_START);
26451
26452 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26453 index b014d94..e775258 100644
26454 --- a/arch/x86/kernel/x8664_ksyms_64.c
26455 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26456 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26457 EXPORT_SYMBOL(copy_user_generic_unrolled);
26458 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26459 EXPORT_SYMBOL(__copy_user_nocache);
26460 -EXPORT_SYMBOL(_copy_from_user);
26461 -EXPORT_SYMBOL(_copy_to_user);
26462
26463 EXPORT_SYMBOL(copy_page);
26464 EXPORT_SYMBOL(clear_page);
26465 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26466 #ifndef CONFIG_PARAVIRT
26467 EXPORT_SYMBOL(native_load_gs_index);
26468 #endif
26469 +
26470 +#ifdef CONFIG_PAX_PER_CPU_PGD
26471 +EXPORT_SYMBOL(cpu_pgd);
26472 +#endif
26473 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26474 index 8ce0072..431a0e7 100644
26475 --- a/arch/x86/kernel/x86_init.c
26476 +++ b/arch/x86/kernel/x86_init.c
26477 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26478 static void default_nmi_init(void) { };
26479 static int default_i8042_detect(void) { return 1; };
26480
26481 -struct x86_platform_ops x86_platform = {
26482 +struct x86_platform_ops x86_platform __read_only = {
26483 .calibrate_tsc = native_calibrate_tsc,
26484 .get_wallclock = mach_get_cmos_time,
26485 .set_wallclock = mach_set_rtc_mmss,
26486 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
26487 EXPORT_SYMBOL_GPL(x86_platform);
26488
26489 #if defined(CONFIG_PCI_MSI)
26490 -struct x86_msi_ops x86_msi = {
26491 +struct x86_msi_ops x86_msi __read_only = {
26492 .setup_msi_irqs = native_setup_msi_irqs,
26493 .compose_msi_msg = native_compose_msi_msg,
26494 .teardown_msi_irq = native_teardown_msi_irq,
26495 @@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
26496 }
26497 #endif
26498
26499 -struct x86_io_apic_ops x86_io_apic_ops = {
26500 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26501 .init = native_io_apic_init_mappings,
26502 .read = native_io_apic_read,
26503 .write = native_io_apic_write,
26504 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26505 index 422fd82..c3687ca 100644
26506 --- a/arch/x86/kernel/xsave.c
26507 +++ b/arch/x86/kernel/xsave.c
26508 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26509 {
26510 int err;
26511
26512 + buf = (struct xsave_struct __user *)____m(buf);
26513 if (use_xsave())
26514 err = xsave_user(buf);
26515 else if (use_fxsr())
26516 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26517 */
26518 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26519 {
26520 + buf = (void __user *)____m(buf);
26521 if (use_xsave()) {
26522 if ((unsigned long)buf % 64 || fx_only) {
26523 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26524 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26525 index b110fe6..d9c19f2 100644
26526 --- a/arch/x86/kvm/cpuid.c
26527 +++ b/arch/x86/kvm/cpuid.c
26528 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26529 struct kvm_cpuid2 *cpuid,
26530 struct kvm_cpuid_entry2 __user *entries)
26531 {
26532 - int r;
26533 + int r, i;
26534
26535 r = -E2BIG;
26536 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26537 goto out;
26538 r = -EFAULT;
26539 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26540 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26541 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26542 goto out;
26543 + for (i = 0; i < cpuid->nent; ++i) {
26544 + struct kvm_cpuid_entry2 cpuid_entry;
26545 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26546 + goto out;
26547 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26548 + }
26549 vcpu->arch.cpuid_nent = cpuid->nent;
26550 kvm_apic_set_version(vcpu);
26551 kvm_x86_ops->cpuid_update(vcpu);
26552 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26553 struct kvm_cpuid2 *cpuid,
26554 struct kvm_cpuid_entry2 __user *entries)
26555 {
26556 - int r;
26557 + int r, i;
26558
26559 r = -E2BIG;
26560 if (cpuid->nent < vcpu->arch.cpuid_nent)
26561 goto out;
26562 r = -EFAULT;
26563 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26564 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26565 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26566 goto out;
26567 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26568 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26569 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26570 + goto out;
26571 + }
26572 return 0;
26573
26574 out:
26575 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26576 index 5439117..d08f3d4 100644
26577 --- a/arch/x86/kvm/lapic.c
26578 +++ b/arch/x86/kvm/lapic.c
26579 @@ -55,7 +55,7 @@
26580 #define APIC_BUS_CYCLE_NS 1
26581
26582 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26583 -#define apic_debug(fmt, arg...)
26584 +#define apic_debug(fmt, arg...) do {} while (0)
26585
26586 #define APIC_LVT_NUM 6
26587 /* 14 is the version for Xeon and Pentium 8.4.8*/
26588 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26589 index ad75d77..a679d32 100644
26590 --- a/arch/x86/kvm/paging_tmpl.h
26591 +++ b/arch/x86/kvm/paging_tmpl.h
26592 @@ -331,7 +331,7 @@ retry_walk:
26593 if (unlikely(kvm_is_error_hva(host_addr)))
26594 goto error;
26595
26596 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26597 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26598 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26599 goto error;
26600 walker->ptep_user[walker->level - 1] = ptep_user;
26601 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26602 index c0bc803..6837a50 100644
26603 --- a/arch/x86/kvm/svm.c
26604 +++ b/arch/x86/kvm/svm.c
26605 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26606 int cpu = raw_smp_processor_id();
26607
26608 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26609 +
26610 + pax_open_kernel();
26611 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26612 + pax_close_kernel();
26613 +
26614 load_TR_desc();
26615 }
26616
26617 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26618 #endif
26619 #endif
26620
26621 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26622 + __set_fs(current_thread_info()->addr_limit);
26623 +#endif
26624 +
26625 reload_tss(vcpu);
26626
26627 local_irq_disable();
26628 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26629 index 2b2fce1..da76be4 100644
26630 --- a/arch/x86/kvm/vmx.c
26631 +++ b/arch/x86/kvm/vmx.c
26632 @@ -1316,12 +1316,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26633 #endif
26634 }
26635
26636 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26637 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26638 {
26639 vmcs_writel(field, vmcs_readl(field) & ~mask);
26640 }
26641
26642 -static void vmcs_set_bits(unsigned long field, u32 mask)
26643 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26644 {
26645 vmcs_writel(field, vmcs_readl(field) | mask);
26646 }
26647 @@ -1522,7 +1522,11 @@ static void reload_tss(void)
26648 struct desc_struct *descs;
26649
26650 descs = (void *)gdt->address;
26651 +
26652 + pax_open_kernel();
26653 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26654 + pax_close_kernel();
26655 +
26656 load_TR_desc();
26657 }
26658
26659 @@ -1746,6 +1750,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26660 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26661 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26662
26663 +#ifdef CONFIG_PAX_PER_CPU_PGD
26664 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26665 +#endif
26666 +
26667 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26668 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26669 vmx->loaded_vmcs->cpu = cpu;
26670 @@ -2037,7 +2045,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
26671 * reads and returns guest's timestamp counter "register"
26672 * guest_tsc = host_tsc + tsc_offset -- 21.3
26673 */
26674 -static u64 guest_read_tsc(void)
26675 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
26676 {
26677 u64 host_tsc, tsc_offset;
26678
26679 @@ -2982,8 +2990,11 @@ static __init int hardware_setup(void)
26680 if (!cpu_has_vmx_flexpriority())
26681 flexpriority_enabled = 0;
26682
26683 - if (!cpu_has_vmx_tpr_shadow())
26684 - kvm_x86_ops->update_cr8_intercept = NULL;
26685 + if (!cpu_has_vmx_tpr_shadow()) {
26686 + pax_open_kernel();
26687 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26688 + pax_close_kernel();
26689 + }
26690
26691 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26692 kvm_disable_largepages();
26693 @@ -2994,13 +3005,15 @@ static __init int hardware_setup(void)
26694 if (!cpu_has_vmx_apicv())
26695 enable_apicv = 0;
26696
26697 + pax_open_kernel();
26698 if (enable_apicv)
26699 - kvm_x86_ops->update_cr8_intercept = NULL;
26700 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26701 else {
26702 - kvm_x86_ops->hwapic_irr_update = NULL;
26703 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26704 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26705 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26706 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26707 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26708 }
26709 + pax_close_kernel();
26710
26711 if (nested)
26712 nested_vmx_setup_ctls_msrs();
26713 @@ -4127,7 +4140,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26714
26715 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26716 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26717 +
26718 +#ifndef CONFIG_PAX_PER_CPU_PGD
26719 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26720 +#endif
26721
26722 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26723 #ifdef CONFIG_X86_64
26724 @@ -4149,7 +4165,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26725 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26726 vmx->host_idt_base = dt.address;
26727
26728 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26729 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26730
26731 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26732 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26733 @@ -7191,6 +7207,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26734 "jmp 2f \n\t"
26735 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26736 "2: "
26737 +
26738 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26739 + "ljmp %[cs],$3f\n\t"
26740 + "3: "
26741 +#endif
26742 +
26743 /* Save guest registers, load host registers, keep flags */
26744 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26745 "pop %0 \n\t"
26746 @@ -7243,6 +7265,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26747 #endif
26748 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26749 [wordsize]"i"(sizeof(ulong))
26750 +
26751 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26752 + ,[cs]"i"(__KERNEL_CS)
26753 +#endif
26754 +
26755 : "cc", "memory"
26756 #ifdef CONFIG_X86_64
26757 , "rax", "rbx", "rdi", "rsi"
26758 @@ -7256,7 +7283,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26759 if (debugctlmsr)
26760 update_debugctlmsr(debugctlmsr);
26761
26762 -#ifndef CONFIG_X86_64
26763 +#ifdef CONFIG_X86_32
26764 /*
26765 * The sysexit path does not restore ds/es, so we must set them to
26766 * a reasonable value ourselves.
26767 @@ -7265,8 +7292,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26768 * may be executed in interrupt context, which saves and restore segments
26769 * around it, nullifying its effect.
26770 */
26771 - loadsegment(ds, __USER_DS);
26772 - loadsegment(es, __USER_DS);
26773 + loadsegment(ds, __KERNEL_DS);
26774 + loadsegment(es, __KERNEL_DS);
26775 + loadsegment(ss, __KERNEL_DS);
26776 +
26777 +#ifdef CONFIG_PAX_KERNEXEC
26778 + loadsegment(fs, __KERNEL_PERCPU);
26779 +#endif
26780 +
26781 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26782 + __set_fs(current_thread_info()->addr_limit);
26783 +#endif
26784 +
26785 #endif
26786
26787 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26788 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26789 index e5ca72a..83d5177 100644
26790 --- a/arch/x86/kvm/x86.c
26791 +++ b/arch/x86/kvm/x86.c
26792 @@ -1779,8 +1779,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26793 {
26794 struct kvm *kvm = vcpu->kvm;
26795 int lm = is_long_mode(vcpu);
26796 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26797 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26798 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26799 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26800 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26801 : kvm->arch.xen_hvm_config.blob_size_32;
26802 u32 page_num = data & ~PAGE_MASK;
26803 @@ -2663,6 +2663,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26804 if (n < msr_list.nmsrs)
26805 goto out;
26806 r = -EFAULT;
26807 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26808 + goto out;
26809 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26810 num_msrs_to_save * sizeof(u32)))
26811 goto out;
26812 @@ -5462,7 +5464,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26813 };
26814 #endif
26815
26816 -int kvm_arch_init(void *opaque)
26817 +int kvm_arch_init(const void *opaque)
26818 {
26819 int r;
26820 struct kvm_x86_ops *ops = opaque;
26821 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26822 index bdf8532..f63c587 100644
26823 --- a/arch/x86/lguest/boot.c
26824 +++ b/arch/x86/lguest/boot.c
26825 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26826 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26827 * Launcher to reboot us.
26828 */
26829 -static void lguest_restart(char *reason)
26830 +static __noreturn void lguest_restart(char *reason)
26831 {
26832 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26833 + BUG();
26834 }
26835
26836 /*G:050
26837 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26838 index 00933d5..3a64af9 100644
26839 --- a/arch/x86/lib/atomic64_386_32.S
26840 +++ b/arch/x86/lib/atomic64_386_32.S
26841 @@ -48,6 +48,10 @@ BEGIN(read)
26842 movl (v), %eax
26843 movl 4(v), %edx
26844 RET_ENDP
26845 +BEGIN(read_unchecked)
26846 + movl (v), %eax
26847 + movl 4(v), %edx
26848 +RET_ENDP
26849 #undef v
26850
26851 #define v %esi
26852 @@ -55,6 +59,10 @@ BEGIN(set)
26853 movl %ebx, (v)
26854 movl %ecx, 4(v)
26855 RET_ENDP
26856 +BEGIN(set_unchecked)
26857 + movl %ebx, (v)
26858 + movl %ecx, 4(v)
26859 +RET_ENDP
26860 #undef v
26861
26862 #define v %esi
26863 @@ -70,6 +78,20 @@ RET_ENDP
26864 BEGIN(add)
26865 addl %eax, (v)
26866 adcl %edx, 4(v)
26867 +
26868 +#ifdef CONFIG_PAX_REFCOUNT
26869 + jno 0f
26870 + subl %eax, (v)
26871 + sbbl %edx, 4(v)
26872 + int $4
26873 +0:
26874 + _ASM_EXTABLE(0b, 0b)
26875 +#endif
26876 +
26877 +RET_ENDP
26878 +BEGIN(add_unchecked)
26879 + addl %eax, (v)
26880 + adcl %edx, 4(v)
26881 RET_ENDP
26882 #undef v
26883
26884 @@ -77,6 +99,24 @@ RET_ENDP
26885 BEGIN(add_return)
26886 addl (v), %eax
26887 adcl 4(v), %edx
26888 +
26889 +#ifdef CONFIG_PAX_REFCOUNT
26890 + into
26891 +1234:
26892 + _ASM_EXTABLE(1234b, 2f)
26893 +#endif
26894 +
26895 + movl %eax, (v)
26896 + movl %edx, 4(v)
26897 +
26898 +#ifdef CONFIG_PAX_REFCOUNT
26899 +2:
26900 +#endif
26901 +
26902 +RET_ENDP
26903 +BEGIN(add_return_unchecked)
26904 + addl (v), %eax
26905 + adcl 4(v), %edx
26906 movl %eax, (v)
26907 movl %edx, 4(v)
26908 RET_ENDP
26909 @@ -86,6 +126,20 @@ RET_ENDP
26910 BEGIN(sub)
26911 subl %eax, (v)
26912 sbbl %edx, 4(v)
26913 +
26914 +#ifdef CONFIG_PAX_REFCOUNT
26915 + jno 0f
26916 + addl %eax, (v)
26917 + adcl %edx, 4(v)
26918 + int $4
26919 +0:
26920 + _ASM_EXTABLE(0b, 0b)
26921 +#endif
26922 +
26923 +RET_ENDP
26924 +BEGIN(sub_unchecked)
26925 + subl %eax, (v)
26926 + sbbl %edx, 4(v)
26927 RET_ENDP
26928 #undef v
26929
26930 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26931 sbbl $0, %edx
26932 addl (v), %eax
26933 adcl 4(v), %edx
26934 +
26935 +#ifdef CONFIG_PAX_REFCOUNT
26936 + into
26937 +1234:
26938 + _ASM_EXTABLE(1234b, 2f)
26939 +#endif
26940 +
26941 + movl %eax, (v)
26942 + movl %edx, 4(v)
26943 +
26944 +#ifdef CONFIG_PAX_REFCOUNT
26945 +2:
26946 +#endif
26947 +
26948 +RET_ENDP
26949 +BEGIN(sub_return_unchecked)
26950 + negl %edx
26951 + negl %eax
26952 + sbbl $0, %edx
26953 + addl (v), %eax
26954 + adcl 4(v), %edx
26955 movl %eax, (v)
26956 movl %edx, 4(v)
26957 RET_ENDP
26958 @@ -105,6 +180,20 @@ RET_ENDP
26959 BEGIN(inc)
26960 addl $1, (v)
26961 adcl $0, 4(v)
26962 +
26963 +#ifdef CONFIG_PAX_REFCOUNT
26964 + jno 0f
26965 + subl $1, (v)
26966 + sbbl $0, 4(v)
26967 + int $4
26968 +0:
26969 + _ASM_EXTABLE(0b, 0b)
26970 +#endif
26971 +
26972 +RET_ENDP
26973 +BEGIN(inc_unchecked)
26974 + addl $1, (v)
26975 + adcl $0, 4(v)
26976 RET_ENDP
26977 #undef v
26978
26979 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26980 movl 4(v), %edx
26981 addl $1, %eax
26982 adcl $0, %edx
26983 +
26984 +#ifdef CONFIG_PAX_REFCOUNT
26985 + into
26986 +1234:
26987 + _ASM_EXTABLE(1234b, 2f)
26988 +#endif
26989 +
26990 + movl %eax, (v)
26991 + movl %edx, 4(v)
26992 +
26993 +#ifdef CONFIG_PAX_REFCOUNT
26994 +2:
26995 +#endif
26996 +
26997 +RET_ENDP
26998 +BEGIN(inc_return_unchecked)
26999 + movl (v), %eax
27000 + movl 4(v), %edx
27001 + addl $1, %eax
27002 + adcl $0, %edx
27003 movl %eax, (v)
27004 movl %edx, 4(v)
27005 RET_ENDP
27006 @@ -123,6 +232,20 @@ RET_ENDP
27007 BEGIN(dec)
27008 subl $1, (v)
27009 sbbl $0, 4(v)
27010 +
27011 +#ifdef CONFIG_PAX_REFCOUNT
27012 + jno 0f
27013 + addl $1, (v)
27014 + adcl $0, 4(v)
27015 + int $4
27016 +0:
27017 + _ASM_EXTABLE(0b, 0b)
27018 +#endif
27019 +
27020 +RET_ENDP
27021 +BEGIN(dec_unchecked)
27022 + subl $1, (v)
27023 + sbbl $0, 4(v)
27024 RET_ENDP
27025 #undef v
27026
27027 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27028 movl 4(v), %edx
27029 subl $1, %eax
27030 sbbl $0, %edx
27031 +
27032 +#ifdef CONFIG_PAX_REFCOUNT
27033 + into
27034 +1234:
27035 + _ASM_EXTABLE(1234b, 2f)
27036 +#endif
27037 +
27038 + movl %eax, (v)
27039 + movl %edx, 4(v)
27040 +
27041 +#ifdef CONFIG_PAX_REFCOUNT
27042 +2:
27043 +#endif
27044 +
27045 +RET_ENDP
27046 +BEGIN(dec_return_unchecked)
27047 + movl (v), %eax
27048 + movl 4(v), %edx
27049 + subl $1, %eax
27050 + sbbl $0, %edx
27051 movl %eax, (v)
27052 movl %edx, 4(v)
27053 RET_ENDP
27054 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27055 adcl %edx, %edi
27056 addl (v), %eax
27057 adcl 4(v), %edx
27058 +
27059 +#ifdef CONFIG_PAX_REFCOUNT
27060 + into
27061 +1234:
27062 + _ASM_EXTABLE(1234b, 2f)
27063 +#endif
27064 +
27065 cmpl %eax, %ecx
27066 je 3f
27067 1:
27068 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27069 1:
27070 addl $1, %eax
27071 adcl $0, %edx
27072 +
27073 +#ifdef CONFIG_PAX_REFCOUNT
27074 + into
27075 +1234:
27076 + _ASM_EXTABLE(1234b, 2f)
27077 +#endif
27078 +
27079 movl %eax, (v)
27080 movl %edx, 4(v)
27081 movl $1, %eax
27082 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27083 movl 4(v), %edx
27084 subl $1, %eax
27085 sbbl $0, %edx
27086 +
27087 +#ifdef CONFIG_PAX_REFCOUNT
27088 + into
27089 +1234:
27090 + _ASM_EXTABLE(1234b, 1f)
27091 +#endif
27092 +
27093 js 1f
27094 movl %eax, (v)
27095 movl %edx, 4(v)
27096 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27097 index f5cc9eb..51fa319 100644
27098 --- a/arch/x86/lib/atomic64_cx8_32.S
27099 +++ b/arch/x86/lib/atomic64_cx8_32.S
27100 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27101 CFI_STARTPROC
27102
27103 read64 %ecx
27104 + pax_force_retaddr
27105 ret
27106 CFI_ENDPROC
27107 ENDPROC(atomic64_read_cx8)
27108
27109 +ENTRY(atomic64_read_unchecked_cx8)
27110 + CFI_STARTPROC
27111 +
27112 + read64 %ecx
27113 + pax_force_retaddr
27114 + ret
27115 + CFI_ENDPROC
27116 +ENDPROC(atomic64_read_unchecked_cx8)
27117 +
27118 ENTRY(atomic64_set_cx8)
27119 CFI_STARTPROC
27120
27121 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27122 cmpxchg8b (%esi)
27123 jne 1b
27124
27125 + pax_force_retaddr
27126 ret
27127 CFI_ENDPROC
27128 ENDPROC(atomic64_set_cx8)
27129
27130 +ENTRY(atomic64_set_unchecked_cx8)
27131 + CFI_STARTPROC
27132 +
27133 +1:
27134 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27135 + * are atomic on 586 and newer */
27136 + cmpxchg8b (%esi)
27137 + jne 1b
27138 +
27139 + pax_force_retaddr
27140 + ret
27141 + CFI_ENDPROC
27142 +ENDPROC(atomic64_set_unchecked_cx8)
27143 +
27144 ENTRY(atomic64_xchg_cx8)
27145 CFI_STARTPROC
27146
27147 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27148 cmpxchg8b (%esi)
27149 jne 1b
27150
27151 + pax_force_retaddr
27152 ret
27153 CFI_ENDPROC
27154 ENDPROC(atomic64_xchg_cx8)
27155
27156 -.macro addsub_return func ins insc
27157 -ENTRY(atomic64_\func\()_return_cx8)
27158 +.macro addsub_return func ins insc unchecked=""
27159 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27160 CFI_STARTPROC
27161 SAVE ebp
27162 SAVE ebx
27163 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27164 movl %edx, %ecx
27165 \ins\()l %esi, %ebx
27166 \insc\()l %edi, %ecx
27167 +
27168 +.ifb \unchecked
27169 +#ifdef CONFIG_PAX_REFCOUNT
27170 + into
27171 +2:
27172 + _ASM_EXTABLE(2b, 3f)
27173 +#endif
27174 +.endif
27175 +
27176 LOCK_PREFIX
27177 cmpxchg8b (%ebp)
27178 jne 1b
27179 -
27180 -10:
27181 movl %ebx, %eax
27182 movl %ecx, %edx
27183 +
27184 +.ifb \unchecked
27185 +#ifdef CONFIG_PAX_REFCOUNT
27186 +3:
27187 +#endif
27188 +.endif
27189 +
27190 RESTORE edi
27191 RESTORE esi
27192 RESTORE ebx
27193 RESTORE ebp
27194 + pax_force_retaddr
27195 ret
27196 CFI_ENDPROC
27197 -ENDPROC(atomic64_\func\()_return_cx8)
27198 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27199 .endm
27200
27201 addsub_return add add adc
27202 addsub_return sub sub sbb
27203 +addsub_return add add adc _unchecked
27204 +addsub_return sub sub sbb _unchecked
27205
27206 -.macro incdec_return func ins insc
27207 -ENTRY(atomic64_\func\()_return_cx8)
27208 +.macro incdec_return func ins insc unchecked=""
27209 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27210 CFI_STARTPROC
27211 SAVE ebx
27212
27213 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27214 movl %edx, %ecx
27215 \ins\()l $1, %ebx
27216 \insc\()l $0, %ecx
27217 +
27218 +.ifb \unchecked
27219 +#ifdef CONFIG_PAX_REFCOUNT
27220 + into
27221 +2:
27222 + _ASM_EXTABLE(2b, 3f)
27223 +#endif
27224 +.endif
27225 +
27226 LOCK_PREFIX
27227 cmpxchg8b (%esi)
27228 jne 1b
27229
27230 -10:
27231 movl %ebx, %eax
27232 movl %ecx, %edx
27233 +
27234 +.ifb \unchecked
27235 +#ifdef CONFIG_PAX_REFCOUNT
27236 +3:
27237 +#endif
27238 +.endif
27239 +
27240 RESTORE ebx
27241 + pax_force_retaddr
27242 ret
27243 CFI_ENDPROC
27244 -ENDPROC(atomic64_\func\()_return_cx8)
27245 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27246 .endm
27247
27248 incdec_return inc add adc
27249 incdec_return dec sub sbb
27250 +incdec_return inc add adc _unchecked
27251 +incdec_return dec sub sbb _unchecked
27252
27253 ENTRY(atomic64_dec_if_positive_cx8)
27254 CFI_STARTPROC
27255 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27256 movl %edx, %ecx
27257 subl $1, %ebx
27258 sbb $0, %ecx
27259 +
27260 +#ifdef CONFIG_PAX_REFCOUNT
27261 + into
27262 +1234:
27263 + _ASM_EXTABLE(1234b, 2f)
27264 +#endif
27265 +
27266 js 2f
27267 LOCK_PREFIX
27268 cmpxchg8b (%esi)
27269 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27270 movl %ebx, %eax
27271 movl %ecx, %edx
27272 RESTORE ebx
27273 + pax_force_retaddr
27274 ret
27275 CFI_ENDPROC
27276 ENDPROC(atomic64_dec_if_positive_cx8)
27277 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27278 movl %edx, %ecx
27279 addl %ebp, %ebx
27280 adcl %edi, %ecx
27281 +
27282 +#ifdef CONFIG_PAX_REFCOUNT
27283 + into
27284 +1234:
27285 + _ASM_EXTABLE(1234b, 3f)
27286 +#endif
27287 +
27288 LOCK_PREFIX
27289 cmpxchg8b (%esi)
27290 jne 1b
27291 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27292 CFI_ADJUST_CFA_OFFSET -8
27293 RESTORE ebx
27294 RESTORE ebp
27295 + pax_force_retaddr
27296 ret
27297 4:
27298 cmpl %edx, 4(%esp)
27299 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27300 xorl %ecx, %ecx
27301 addl $1, %ebx
27302 adcl %edx, %ecx
27303 +
27304 +#ifdef CONFIG_PAX_REFCOUNT
27305 + into
27306 +1234:
27307 + _ASM_EXTABLE(1234b, 3f)
27308 +#endif
27309 +
27310 LOCK_PREFIX
27311 cmpxchg8b (%esi)
27312 jne 1b
27313 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27314 movl $1, %eax
27315 3:
27316 RESTORE ebx
27317 + pax_force_retaddr
27318 ret
27319 CFI_ENDPROC
27320 ENDPROC(atomic64_inc_not_zero_cx8)
27321 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27322 index e78b8ee..7e173a8 100644
27323 --- a/arch/x86/lib/checksum_32.S
27324 +++ b/arch/x86/lib/checksum_32.S
27325 @@ -29,7 +29,8 @@
27326 #include <asm/dwarf2.h>
27327 #include <asm/errno.h>
27328 #include <asm/asm.h>
27329 -
27330 +#include <asm/segment.h>
27331 +
27332 /*
27333 * computes a partial checksum, e.g. for TCP/UDP fragments
27334 */
27335 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27336
27337 #define ARGBASE 16
27338 #define FP 12
27339 -
27340 -ENTRY(csum_partial_copy_generic)
27341 +
27342 +ENTRY(csum_partial_copy_generic_to_user)
27343 CFI_STARTPROC
27344 +
27345 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27346 + pushl_cfi %gs
27347 + popl_cfi %es
27348 + jmp csum_partial_copy_generic
27349 +#endif
27350 +
27351 +ENTRY(csum_partial_copy_generic_from_user)
27352 +
27353 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27354 + pushl_cfi %gs
27355 + popl_cfi %ds
27356 +#endif
27357 +
27358 +ENTRY(csum_partial_copy_generic)
27359 subl $4,%esp
27360 CFI_ADJUST_CFA_OFFSET 4
27361 pushl_cfi %edi
27362 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27363 jmp 4f
27364 SRC(1: movw (%esi), %bx )
27365 addl $2, %esi
27366 -DST( movw %bx, (%edi) )
27367 +DST( movw %bx, %es:(%edi) )
27368 addl $2, %edi
27369 addw %bx, %ax
27370 adcl $0, %eax
27371 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27372 SRC(1: movl (%esi), %ebx )
27373 SRC( movl 4(%esi), %edx )
27374 adcl %ebx, %eax
27375 -DST( movl %ebx, (%edi) )
27376 +DST( movl %ebx, %es:(%edi) )
27377 adcl %edx, %eax
27378 -DST( movl %edx, 4(%edi) )
27379 +DST( movl %edx, %es:4(%edi) )
27380
27381 SRC( movl 8(%esi), %ebx )
27382 SRC( movl 12(%esi), %edx )
27383 adcl %ebx, %eax
27384 -DST( movl %ebx, 8(%edi) )
27385 +DST( movl %ebx, %es:8(%edi) )
27386 adcl %edx, %eax
27387 -DST( movl %edx, 12(%edi) )
27388 +DST( movl %edx, %es:12(%edi) )
27389
27390 SRC( movl 16(%esi), %ebx )
27391 SRC( movl 20(%esi), %edx )
27392 adcl %ebx, %eax
27393 -DST( movl %ebx, 16(%edi) )
27394 +DST( movl %ebx, %es:16(%edi) )
27395 adcl %edx, %eax
27396 -DST( movl %edx, 20(%edi) )
27397 +DST( movl %edx, %es:20(%edi) )
27398
27399 SRC( movl 24(%esi), %ebx )
27400 SRC( movl 28(%esi), %edx )
27401 adcl %ebx, %eax
27402 -DST( movl %ebx, 24(%edi) )
27403 +DST( movl %ebx, %es:24(%edi) )
27404 adcl %edx, %eax
27405 -DST( movl %edx, 28(%edi) )
27406 +DST( movl %edx, %es:28(%edi) )
27407
27408 lea 32(%esi), %esi
27409 lea 32(%edi), %edi
27410 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27411 shrl $2, %edx # This clears CF
27412 SRC(3: movl (%esi), %ebx )
27413 adcl %ebx, %eax
27414 -DST( movl %ebx, (%edi) )
27415 +DST( movl %ebx, %es:(%edi) )
27416 lea 4(%esi), %esi
27417 lea 4(%edi), %edi
27418 dec %edx
27419 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27420 jb 5f
27421 SRC( movw (%esi), %cx )
27422 leal 2(%esi), %esi
27423 -DST( movw %cx, (%edi) )
27424 +DST( movw %cx, %es:(%edi) )
27425 leal 2(%edi), %edi
27426 je 6f
27427 shll $16,%ecx
27428 SRC(5: movb (%esi), %cl )
27429 -DST( movb %cl, (%edi) )
27430 +DST( movb %cl, %es:(%edi) )
27431 6: addl %ecx, %eax
27432 adcl $0, %eax
27433 7:
27434 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27435
27436 6001:
27437 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27438 - movl $-EFAULT, (%ebx)
27439 + movl $-EFAULT, %ss:(%ebx)
27440
27441 # zero the complete destination - computing the rest
27442 # is too much work
27443 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27444
27445 6002:
27446 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27447 - movl $-EFAULT,(%ebx)
27448 + movl $-EFAULT,%ss:(%ebx)
27449 jmp 5000b
27450
27451 .previous
27452
27453 + pushl_cfi %ss
27454 + popl_cfi %ds
27455 + pushl_cfi %ss
27456 + popl_cfi %es
27457 popl_cfi %ebx
27458 CFI_RESTORE ebx
27459 popl_cfi %esi
27460 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27461 popl_cfi %ecx # equivalent to addl $4,%esp
27462 ret
27463 CFI_ENDPROC
27464 -ENDPROC(csum_partial_copy_generic)
27465 +ENDPROC(csum_partial_copy_generic_to_user)
27466
27467 #else
27468
27469 /* Version for PentiumII/PPro */
27470
27471 #define ROUND1(x) \
27472 + nop; nop; nop; \
27473 SRC(movl x(%esi), %ebx ) ; \
27474 addl %ebx, %eax ; \
27475 - DST(movl %ebx, x(%edi) ) ;
27476 + DST(movl %ebx, %es:x(%edi)) ;
27477
27478 #define ROUND(x) \
27479 + nop; nop; nop; \
27480 SRC(movl x(%esi), %ebx ) ; \
27481 adcl %ebx, %eax ; \
27482 - DST(movl %ebx, x(%edi) ) ;
27483 + DST(movl %ebx, %es:x(%edi)) ;
27484
27485 #define ARGBASE 12
27486 -
27487 -ENTRY(csum_partial_copy_generic)
27488 +
27489 +ENTRY(csum_partial_copy_generic_to_user)
27490 CFI_STARTPROC
27491 +
27492 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27493 + pushl_cfi %gs
27494 + popl_cfi %es
27495 + jmp csum_partial_copy_generic
27496 +#endif
27497 +
27498 +ENTRY(csum_partial_copy_generic_from_user)
27499 +
27500 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27501 + pushl_cfi %gs
27502 + popl_cfi %ds
27503 +#endif
27504 +
27505 +ENTRY(csum_partial_copy_generic)
27506 pushl_cfi %ebx
27507 CFI_REL_OFFSET ebx, 0
27508 pushl_cfi %edi
27509 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27510 subl %ebx, %edi
27511 lea -1(%esi),%edx
27512 andl $-32,%edx
27513 - lea 3f(%ebx,%ebx), %ebx
27514 + lea 3f(%ebx,%ebx,2), %ebx
27515 testl %esi, %esi
27516 jmp *%ebx
27517 1: addl $64,%esi
27518 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27519 jb 5f
27520 SRC( movw (%esi), %dx )
27521 leal 2(%esi), %esi
27522 -DST( movw %dx, (%edi) )
27523 +DST( movw %dx, %es:(%edi) )
27524 leal 2(%edi), %edi
27525 je 6f
27526 shll $16,%edx
27527 5:
27528 SRC( movb (%esi), %dl )
27529 -DST( movb %dl, (%edi) )
27530 +DST( movb %dl, %es:(%edi) )
27531 6: addl %edx, %eax
27532 adcl $0, %eax
27533 7:
27534 .section .fixup, "ax"
27535 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27536 - movl $-EFAULT, (%ebx)
27537 + movl $-EFAULT, %ss:(%ebx)
27538 # zero the complete destination (computing the rest is too much work)
27539 movl ARGBASE+8(%esp),%edi # dst
27540 movl ARGBASE+12(%esp),%ecx # len
27541 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27542 rep; stosb
27543 jmp 7b
27544 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27545 - movl $-EFAULT, (%ebx)
27546 + movl $-EFAULT, %ss:(%ebx)
27547 jmp 7b
27548 .previous
27549
27550 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27551 + pushl_cfi %ss
27552 + popl_cfi %ds
27553 + pushl_cfi %ss
27554 + popl_cfi %es
27555 +#endif
27556 +
27557 popl_cfi %esi
27558 CFI_RESTORE esi
27559 popl_cfi %edi
27560 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27561 CFI_RESTORE ebx
27562 ret
27563 CFI_ENDPROC
27564 -ENDPROC(csum_partial_copy_generic)
27565 +ENDPROC(csum_partial_copy_generic_to_user)
27566
27567 #undef ROUND
27568 #undef ROUND1
27569 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27570 index f2145cf..cea889d 100644
27571 --- a/arch/x86/lib/clear_page_64.S
27572 +++ b/arch/x86/lib/clear_page_64.S
27573 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27574 movl $4096/8,%ecx
27575 xorl %eax,%eax
27576 rep stosq
27577 + pax_force_retaddr
27578 ret
27579 CFI_ENDPROC
27580 ENDPROC(clear_page_c)
27581 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27582 movl $4096,%ecx
27583 xorl %eax,%eax
27584 rep stosb
27585 + pax_force_retaddr
27586 ret
27587 CFI_ENDPROC
27588 ENDPROC(clear_page_c_e)
27589 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27590 leaq 64(%rdi),%rdi
27591 jnz .Lloop
27592 nop
27593 + pax_force_retaddr
27594 ret
27595 CFI_ENDPROC
27596 .Lclear_page_end:
27597 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27598
27599 #include <asm/cpufeature.h>
27600
27601 - .section .altinstr_replacement,"ax"
27602 + .section .altinstr_replacement,"a"
27603 1: .byte 0xeb /* jmp <disp8> */
27604 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27605 2: .byte 0xeb /* jmp <disp8> */
27606 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27607 index 1e572c5..2a162cd 100644
27608 --- a/arch/x86/lib/cmpxchg16b_emu.S
27609 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27610 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27611
27612 popf
27613 mov $1, %al
27614 + pax_force_retaddr
27615 ret
27616
27617 not_same:
27618 popf
27619 xor %al,%al
27620 + pax_force_retaddr
27621 ret
27622
27623 CFI_ENDPROC
27624 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27625 index 176cca6..1166c50 100644
27626 --- a/arch/x86/lib/copy_page_64.S
27627 +++ b/arch/x86/lib/copy_page_64.S
27628 @@ -9,6 +9,7 @@ copy_page_rep:
27629 CFI_STARTPROC
27630 movl $4096/8, %ecx
27631 rep movsq
27632 + pax_force_retaddr
27633 ret
27634 CFI_ENDPROC
27635 ENDPROC(copy_page_rep)
27636 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27637
27638 ENTRY(copy_page)
27639 CFI_STARTPROC
27640 - subq $2*8, %rsp
27641 - CFI_ADJUST_CFA_OFFSET 2*8
27642 + subq $3*8, %rsp
27643 + CFI_ADJUST_CFA_OFFSET 3*8
27644 movq %rbx, (%rsp)
27645 CFI_REL_OFFSET rbx, 0
27646 movq %r12, 1*8(%rsp)
27647 CFI_REL_OFFSET r12, 1*8
27648 + movq %r13, 2*8(%rsp)
27649 + CFI_REL_OFFSET r13, 2*8
27650
27651 movl $(4096/64)-5, %ecx
27652 .p2align 4
27653 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27654 movq 0x8*2(%rsi), %rdx
27655 movq 0x8*3(%rsi), %r8
27656 movq 0x8*4(%rsi), %r9
27657 - movq 0x8*5(%rsi), %r10
27658 + movq 0x8*5(%rsi), %r13
27659 movq 0x8*6(%rsi), %r11
27660 movq 0x8*7(%rsi), %r12
27661
27662 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27663 movq %rdx, 0x8*2(%rdi)
27664 movq %r8, 0x8*3(%rdi)
27665 movq %r9, 0x8*4(%rdi)
27666 - movq %r10, 0x8*5(%rdi)
27667 + movq %r13, 0x8*5(%rdi)
27668 movq %r11, 0x8*6(%rdi)
27669 movq %r12, 0x8*7(%rdi)
27670
27671 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27672 movq 0x8*2(%rsi), %rdx
27673 movq 0x8*3(%rsi), %r8
27674 movq 0x8*4(%rsi), %r9
27675 - movq 0x8*5(%rsi), %r10
27676 + movq 0x8*5(%rsi), %r13
27677 movq 0x8*6(%rsi), %r11
27678 movq 0x8*7(%rsi), %r12
27679
27680 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27681 movq %rdx, 0x8*2(%rdi)
27682 movq %r8, 0x8*3(%rdi)
27683 movq %r9, 0x8*4(%rdi)
27684 - movq %r10, 0x8*5(%rdi)
27685 + movq %r13, 0x8*5(%rdi)
27686 movq %r11, 0x8*6(%rdi)
27687 movq %r12, 0x8*7(%rdi)
27688
27689 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27690 CFI_RESTORE rbx
27691 movq 1*8(%rsp), %r12
27692 CFI_RESTORE r12
27693 - addq $2*8, %rsp
27694 - CFI_ADJUST_CFA_OFFSET -2*8
27695 + movq 2*8(%rsp), %r13
27696 + CFI_RESTORE r13
27697 + addq $3*8, %rsp
27698 + CFI_ADJUST_CFA_OFFSET -3*8
27699 + pax_force_retaddr
27700 ret
27701 .Lcopy_page_end:
27702 CFI_ENDPROC
27703 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27704
27705 #include <asm/cpufeature.h>
27706
27707 - .section .altinstr_replacement,"ax"
27708 + .section .altinstr_replacement,"a"
27709 1: .byte 0xeb /* jmp <disp8> */
27710 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27711 2:
27712 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27713 index a30ca15..6b3f4e1 100644
27714 --- a/arch/x86/lib/copy_user_64.S
27715 +++ b/arch/x86/lib/copy_user_64.S
27716 @@ -18,31 +18,7 @@
27717 #include <asm/alternative-asm.h>
27718 #include <asm/asm.h>
27719 #include <asm/smap.h>
27720 -
27721 -/*
27722 - * By placing feature2 after feature1 in altinstructions section, we logically
27723 - * implement:
27724 - * If CPU has feature2, jmp to alt2 is used
27725 - * else if CPU has feature1, jmp to alt1 is used
27726 - * else jmp to orig is used.
27727 - */
27728 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27729 -0:
27730 - .byte 0xe9 /* 32bit jump */
27731 - .long \orig-1f /* by default jump to orig */
27732 -1:
27733 - .section .altinstr_replacement,"ax"
27734 -2: .byte 0xe9 /* near jump with 32bit immediate */
27735 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27736 -3: .byte 0xe9 /* near jump with 32bit immediate */
27737 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27738 - .previous
27739 -
27740 - .section .altinstructions,"a"
27741 - altinstruction_entry 0b,2b,\feature1,5,5
27742 - altinstruction_entry 0b,3b,\feature2,5,5
27743 - .previous
27744 - .endm
27745 +#include <asm/pgtable.h>
27746
27747 .macro ALIGN_DESTINATION
27748 #ifdef FIX_ALIGNMENT
27749 @@ -70,52 +46,6 @@
27750 #endif
27751 .endm
27752
27753 -/* Standard copy_to_user with segment limit checking */
27754 -ENTRY(_copy_to_user)
27755 - CFI_STARTPROC
27756 - GET_THREAD_INFO(%rax)
27757 - movq %rdi,%rcx
27758 - addq %rdx,%rcx
27759 - jc bad_to_user
27760 - cmpq TI_addr_limit(%rax),%rcx
27761 - ja bad_to_user
27762 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27763 - copy_user_generic_unrolled,copy_user_generic_string, \
27764 - copy_user_enhanced_fast_string
27765 - CFI_ENDPROC
27766 -ENDPROC(_copy_to_user)
27767 -
27768 -/* Standard copy_from_user with segment limit checking */
27769 -ENTRY(_copy_from_user)
27770 - CFI_STARTPROC
27771 - GET_THREAD_INFO(%rax)
27772 - movq %rsi,%rcx
27773 - addq %rdx,%rcx
27774 - jc bad_from_user
27775 - cmpq TI_addr_limit(%rax),%rcx
27776 - ja bad_from_user
27777 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27778 - copy_user_generic_unrolled,copy_user_generic_string, \
27779 - copy_user_enhanced_fast_string
27780 - CFI_ENDPROC
27781 -ENDPROC(_copy_from_user)
27782 -
27783 - .section .fixup,"ax"
27784 - /* must zero dest */
27785 -ENTRY(bad_from_user)
27786 -bad_from_user:
27787 - CFI_STARTPROC
27788 - movl %edx,%ecx
27789 - xorl %eax,%eax
27790 - rep
27791 - stosb
27792 -bad_to_user:
27793 - movl %edx,%eax
27794 - ret
27795 - CFI_ENDPROC
27796 -ENDPROC(bad_from_user)
27797 - .previous
27798 -
27799 /*
27800 * copy_user_generic_unrolled - memory copy with exception handling.
27801 * This version is for CPUs like P4 that don't have efficient micro
27802 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27803 */
27804 ENTRY(copy_user_generic_unrolled)
27805 CFI_STARTPROC
27806 + ASM_PAX_OPEN_USERLAND
27807 ASM_STAC
27808 cmpl $8,%edx
27809 jb 20f /* less then 8 bytes, go to byte copy loop */
27810 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27811 jz 17f
27812 1: movq (%rsi),%r8
27813 2: movq 1*8(%rsi),%r9
27814 -3: movq 2*8(%rsi),%r10
27815 +3: movq 2*8(%rsi),%rax
27816 4: movq 3*8(%rsi),%r11
27817 5: movq %r8,(%rdi)
27818 6: movq %r9,1*8(%rdi)
27819 -7: movq %r10,2*8(%rdi)
27820 +7: movq %rax,2*8(%rdi)
27821 8: movq %r11,3*8(%rdi)
27822 9: movq 4*8(%rsi),%r8
27823 10: movq 5*8(%rsi),%r9
27824 -11: movq 6*8(%rsi),%r10
27825 +11: movq 6*8(%rsi),%rax
27826 12: movq 7*8(%rsi),%r11
27827 13: movq %r8,4*8(%rdi)
27828 14: movq %r9,5*8(%rdi)
27829 -15: movq %r10,6*8(%rdi)
27830 +15: movq %rax,6*8(%rdi)
27831 16: movq %r11,7*8(%rdi)
27832 leaq 64(%rsi),%rsi
27833 leaq 64(%rdi),%rdi
27834 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27835 jnz 21b
27836 23: xor %eax,%eax
27837 ASM_CLAC
27838 + ASM_PAX_CLOSE_USERLAND
27839 + pax_force_retaddr
27840 ret
27841
27842 .section .fixup,"ax"
27843 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27844 */
27845 ENTRY(copy_user_generic_string)
27846 CFI_STARTPROC
27847 + ASM_PAX_OPEN_USERLAND
27848 ASM_STAC
27849 andl %edx,%edx
27850 jz 4f
27851 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27852 movsb
27853 4: xorl %eax,%eax
27854 ASM_CLAC
27855 + ASM_PAX_CLOSE_USERLAND
27856 + pax_force_retaddr
27857 ret
27858
27859 .section .fixup,"ax"
27860 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27861 */
27862 ENTRY(copy_user_enhanced_fast_string)
27863 CFI_STARTPROC
27864 + ASM_PAX_OPEN_USERLAND
27865 ASM_STAC
27866 andl %edx,%edx
27867 jz 2f
27868 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27869 movsb
27870 2: xorl %eax,%eax
27871 ASM_CLAC
27872 + ASM_PAX_CLOSE_USERLAND
27873 + pax_force_retaddr
27874 ret
27875
27876 .section .fixup,"ax"
27877 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27878 index 6a4f43c..55d26f2 100644
27879 --- a/arch/x86/lib/copy_user_nocache_64.S
27880 +++ b/arch/x86/lib/copy_user_nocache_64.S
27881 @@ -8,6 +8,7 @@
27882
27883 #include <linux/linkage.h>
27884 #include <asm/dwarf2.h>
27885 +#include <asm/alternative-asm.h>
27886
27887 #define FIX_ALIGNMENT 1
27888
27889 @@ -16,6 +17,7 @@
27890 #include <asm/thread_info.h>
27891 #include <asm/asm.h>
27892 #include <asm/smap.h>
27893 +#include <asm/pgtable.h>
27894
27895 .macro ALIGN_DESTINATION
27896 #ifdef FIX_ALIGNMENT
27897 @@ -49,6 +51,16 @@
27898 */
27899 ENTRY(__copy_user_nocache)
27900 CFI_STARTPROC
27901 +
27902 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27903 + mov pax_user_shadow_base,%rcx
27904 + cmp %rcx,%rsi
27905 + jae 1f
27906 + add %rcx,%rsi
27907 +1:
27908 +#endif
27909 +
27910 + ASM_PAX_OPEN_USERLAND
27911 ASM_STAC
27912 cmpl $8,%edx
27913 jb 20f /* less then 8 bytes, go to byte copy loop */
27914 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27915 jz 17f
27916 1: movq (%rsi),%r8
27917 2: movq 1*8(%rsi),%r9
27918 -3: movq 2*8(%rsi),%r10
27919 +3: movq 2*8(%rsi),%rax
27920 4: movq 3*8(%rsi),%r11
27921 5: movnti %r8,(%rdi)
27922 6: movnti %r9,1*8(%rdi)
27923 -7: movnti %r10,2*8(%rdi)
27924 +7: movnti %rax,2*8(%rdi)
27925 8: movnti %r11,3*8(%rdi)
27926 9: movq 4*8(%rsi),%r8
27927 10: movq 5*8(%rsi),%r9
27928 -11: movq 6*8(%rsi),%r10
27929 +11: movq 6*8(%rsi),%rax
27930 12: movq 7*8(%rsi),%r11
27931 13: movnti %r8,4*8(%rdi)
27932 14: movnti %r9,5*8(%rdi)
27933 -15: movnti %r10,6*8(%rdi)
27934 +15: movnti %rax,6*8(%rdi)
27935 16: movnti %r11,7*8(%rdi)
27936 leaq 64(%rsi),%rsi
27937 leaq 64(%rdi),%rdi
27938 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27939 jnz 21b
27940 23: xorl %eax,%eax
27941 ASM_CLAC
27942 + ASM_PAX_CLOSE_USERLAND
27943 sfence
27944 + pax_force_retaddr
27945 ret
27946
27947 .section .fixup,"ax"
27948 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27949 index 2419d5f..953ee51 100644
27950 --- a/arch/x86/lib/csum-copy_64.S
27951 +++ b/arch/x86/lib/csum-copy_64.S
27952 @@ -9,6 +9,7 @@
27953 #include <asm/dwarf2.h>
27954 #include <asm/errno.h>
27955 #include <asm/asm.h>
27956 +#include <asm/alternative-asm.h>
27957
27958 /*
27959 * Checksum copy with exception handling.
27960 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27961 CFI_RESTORE rbp
27962 addq $7*8, %rsp
27963 CFI_ADJUST_CFA_OFFSET -7*8
27964 + pax_force_retaddr 0, 1
27965 ret
27966 CFI_RESTORE_STATE
27967
27968 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27969 index 7609e0e..b449b98 100644
27970 --- a/arch/x86/lib/csum-wrappers_64.c
27971 +++ b/arch/x86/lib/csum-wrappers_64.c
27972 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27973 len -= 2;
27974 }
27975 }
27976 + pax_open_userland();
27977 stac();
27978 - isum = csum_partial_copy_generic((__force const void *)src,
27979 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27980 dst, len, isum, errp, NULL);
27981 clac();
27982 + pax_close_userland();
27983 if (unlikely(*errp))
27984 goto out_err;
27985
27986 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27987 }
27988
27989 *errp = 0;
27990 + pax_open_userland();
27991 stac();
27992 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27993 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27994 len, isum, NULL, errp);
27995 clac();
27996 + pax_close_userland();
27997 return ret;
27998 }
27999 EXPORT_SYMBOL(csum_partial_copy_to_user);
28000 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28001 index a451235..1daa956 100644
28002 --- a/arch/x86/lib/getuser.S
28003 +++ b/arch/x86/lib/getuser.S
28004 @@ -33,17 +33,40 @@
28005 #include <asm/thread_info.h>
28006 #include <asm/asm.h>
28007 #include <asm/smap.h>
28008 +#include <asm/segment.h>
28009 +#include <asm/pgtable.h>
28010 +#include <asm/alternative-asm.h>
28011 +
28012 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28013 +#define __copyuser_seg gs;
28014 +#else
28015 +#define __copyuser_seg
28016 +#endif
28017
28018 .text
28019 ENTRY(__get_user_1)
28020 CFI_STARTPROC
28021 +
28022 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28023 GET_THREAD_INFO(%_ASM_DX)
28024 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28025 jae bad_get_user
28026 ASM_STAC
28027 -1: movzbl (%_ASM_AX),%edx
28028 +
28029 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28030 + mov pax_user_shadow_base,%_ASM_DX
28031 + cmp %_ASM_DX,%_ASM_AX
28032 + jae 1234f
28033 + add %_ASM_DX,%_ASM_AX
28034 +1234:
28035 +#endif
28036 +
28037 +#endif
28038 +
28039 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28040 xor %eax,%eax
28041 ASM_CLAC
28042 + pax_force_retaddr
28043 ret
28044 CFI_ENDPROC
28045 ENDPROC(__get_user_1)
28046 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28047 ENTRY(__get_user_2)
28048 CFI_STARTPROC
28049 add $1,%_ASM_AX
28050 +
28051 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28052 jc bad_get_user
28053 GET_THREAD_INFO(%_ASM_DX)
28054 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28055 jae bad_get_user
28056 ASM_STAC
28057 -2: movzwl -1(%_ASM_AX),%edx
28058 +
28059 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28060 + mov pax_user_shadow_base,%_ASM_DX
28061 + cmp %_ASM_DX,%_ASM_AX
28062 + jae 1234f
28063 + add %_ASM_DX,%_ASM_AX
28064 +1234:
28065 +#endif
28066 +
28067 +#endif
28068 +
28069 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28070 xor %eax,%eax
28071 ASM_CLAC
28072 + pax_force_retaddr
28073 ret
28074 CFI_ENDPROC
28075 ENDPROC(__get_user_2)
28076 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28077 ENTRY(__get_user_4)
28078 CFI_STARTPROC
28079 add $3,%_ASM_AX
28080 +
28081 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28082 jc bad_get_user
28083 GET_THREAD_INFO(%_ASM_DX)
28084 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28085 jae bad_get_user
28086 ASM_STAC
28087 -3: movl -3(%_ASM_AX),%edx
28088 +
28089 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28090 + mov pax_user_shadow_base,%_ASM_DX
28091 + cmp %_ASM_DX,%_ASM_AX
28092 + jae 1234f
28093 + add %_ASM_DX,%_ASM_AX
28094 +1234:
28095 +#endif
28096 +
28097 +#endif
28098 +
28099 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28100 xor %eax,%eax
28101 ASM_CLAC
28102 + pax_force_retaddr
28103 ret
28104 CFI_ENDPROC
28105 ENDPROC(__get_user_4)
28106 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28107 GET_THREAD_INFO(%_ASM_DX)
28108 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28109 jae bad_get_user
28110 +
28111 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28112 + mov pax_user_shadow_base,%_ASM_DX
28113 + cmp %_ASM_DX,%_ASM_AX
28114 + jae 1234f
28115 + add %_ASM_DX,%_ASM_AX
28116 +1234:
28117 +#endif
28118 +
28119 ASM_STAC
28120 4: movq -7(%_ASM_AX),%rdx
28121 xor %eax,%eax
28122 ASM_CLAC
28123 + pax_force_retaddr
28124 ret
28125 #else
28126 add $7,%_ASM_AX
28127 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28128 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28129 jae bad_get_user_8
28130 ASM_STAC
28131 -4: movl -7(%_ASM_AX),%edx
28132 -5: movl -3(%_ASM_AX),%ecx
28133 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28134 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28135 xor %eax,%eax
28136 ASM_CLAC
28137 + pax_force_retaddr
28138 ret
28139 #endif
28140 CFI_ENDPROC
28141 @@ -113,6 +175,7 @@ bad_get_user:
28142 xor %edx,%edx
28143 mov $(-EFAULT),%_ASM_AX
28144 ASM_CLAC
28145 + pax_force_retaddr
28146 ret
28147 CFI_ENDPROC
28148 END(bad_get_user)
28149 @@ -124,6 +187,7 @@ bad_get_user_8:
28150 xor %ecx,%ecx
28151 mov $(-EFAULT),%_ASM_AX
28152 ASM_CLAC
28153 + pax_force_retaddr
28154 ret
28155 CFI_ENDPROC
28156 END(bad_get_user_8)
28157 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28158 index 54fcffe..7be149e 100644
28159 --- a/arch/x86/lib/insn.c
28160 +++ b/arch/x86/lib/insn.c
28161 @@ -20,8 +20,10 @@
28162
28163 #ifdef __KERNEL__
28164 #include <linux/string.h>
28165 +#include <asm/pgtable_types.h>
28166 #else
28167 #include <string.h>
28168 +#define ktla_ktva(addr) addr
28169 #endif
28170 #include <asm/inat.h>
28171 #include <asm/insn.h>
28172 @@ -53,8 +55,8 @@
28173 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28174 {
28175 memset(insn, 0, sizeof(*insn));
28176 - insn->kaddr = kaddr;
28177 - insn->next_byte = kaddr;
28178 + insn->kaddr = ktla_ktva(kaddr);
28179 + insn->next_byte = ktla_ktva(kaddr);
28180 insn->x86_64 = x86_64 ? 1 : 0;
28181 insn->opnd_bytes = 4;
28182 if (x86_64)
28183 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28184 index 05a95e7..326f2fa 100644
28185 --- a/arch/x86/lib/iomap_copy_64.S
28186 +++ b/arch/x86/lib/iomap_copy_64.S
28187 @@ -17,6 +17,7 @@
28188
28189 #include <linux/linkage.h>
28190 #include <asm/dwarf2.h>
28191 +#include <asm/alternative-asm.h>
28192
28193 /*
28194 * override generic version in lib/iomap_copy.c
28195 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28196 CFI_STARTPROC
28197 movl %edx,%ecx
28198 rep movsd
28199 + pax_force_retaddr
28200 ret
28201 CFI_ENDPROC
28202 ENDPROC(__iowrite32_copy)
28203 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28204 index 56313a3..9b59269 100644
28205 --- a/arch/x86/lib/memcpy_64.S
28206 +++ b/arch/x86/lib/memcpy_64.S
28207 @@ -24,7 +24,7 @@
28208 * This gets patched over the unrolled variant (below) via the
28209 * alternative instructions framework:
28210 */
28211 - .section .altinstr_replacement, "ax", @progbits
28212 + .section .altinstr_replacement, "a", @progbits
28213 .Lmemcpy_c:
28214 movq %rdi, %rax
28215 movq %rdx, %rcx
28216 @@ -33,6 +33,7 @@
28217 rep movsq
28218 movl %edx, %ecx
28219 rep movsb
28220 + pax_force_retaddr
28221 ret
28222 .Lmemcpy_e:
28223 .previous
28224 @@ -44,11 +45,12 @@
28225 * This gets patched over the unrolled variant (below) via the
28226 * alternative instructions framework:
28227 */
28228 - .section .altinstr_replacement, "ax", @progbits
28229 + .section .altinstr_replacement, "a", @progbits
28230 .Lmemcpy_c_e:
28231 movq %rdi, %rax
28232 movq %rdx, %rcx
28233 rep movsb
28234 + pax_force_retaddr
28235 ret
28236 .Lmemcpy_e_e:
28237 .previous
28238 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28239 */
28240 movq 0*8(%rsi), %r8
28241 movq 1*8(%rsi), %r9
28242 - movq 2*8(%rsi), %r10
28243 + movq 2*8(%rsi), %rcx
28244 movq 3*8(%rsi), %r11
28245 leaq 4*8(%rsi), %rsi
28246
28247 movq %r8, 0*8(%rdi)
28248 movq %r9, 1*8(%rdi)
28249 - movq %r10, 2*8(%rdi)
28250 + movq %rcx, 2*8(%rdi)
28251 movq %r11, 3*8(%rdi)
28252 leaq 4*8(%rdi), %rdi
28253 jae .Lcopy_forward_loop
28254 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28255 subq $0x20, %rdx
28256 movq -1*8(%rsi), %r8
28257 movq -2*8(%rsi), %r9
28258 - movq -3*8(%rsi), %r10
28259 + movq -3*8(%rsi), %rcx
28260 movq -4*8(%rsi), %r11
28261 leaq -4*8(%rsi), %rsi
28262 movq %r8, -1*8(%rdi)
28263 movq %r9, -2*8(%rdi)
28264 - movq %r10, -3*8(%rdi)
28265 + movq %rcx, -3*8(%rdi)
28266 movq %r11, -4*8(%rdi)
28267 leaq -4*8(%rdi), %rdi
28268 jae .Lcopy_backward_loop
28269 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28270 */
28271 movq 0*8(%rsi), %r8
28272 movq 1*8(%rsi), %r9
28273 - movq -2*8(%rsi, %rdx), %r10
28274 + movq -2*8(%rsi, %rdx), %rcx
28275 movq -1*8(%rsi, %rdx), %r11
28276 movq %r8, 0*8(%rdi)
28277 movq %r9, 1*8(%rdi)
28278 - movq %r10, -2*8(%rdi, %rdx)
28279 + movq %rcx, -2*8(%rdi, %rdx)
28280 movq %r11, -1*8(%rdi, %rdx)
28281 + pax_force_retaddr
28282 retq
28283 .p2align 4
28284 .Lless_16bytes:
28285 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28286 movq -1*8(%rsi, %rdx), %r9
28287 movq %r8, 0*8(%rdi)
28288 movq %r9, -1*8(%rdi, %rdx)
28289 + pax_force_retaddr
28290 retq
28291 .p2align 4
28292 .Lless_8bytes:
28293 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28294 movl -4(%rsi, %rdx), %r8d
28295 movl %ecx, (%rdi)
28296 movl %r8d, -4(%rdi, %rdx)
28297 + pax_force_retaddr
28298 retq
28299 .p2align 4
28300 .Lless_3bytes:
28301 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28302 movb %cl, (%rdi)
28303
28304 .Lend:
28305 + pax_force_retaddr
28306 retq
28307 CFI_ENDPROC
28308 ENDPROC(memcpy)
28309 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28310 index 65268a6..5aa7815 100644
28311 --- a/arch/x86/lib/memmove_64.S
28312 +++ b/arch/x86/lib/memmove_64.S
28313 @@ -61,13 +61,13 @@ ENTRY(memmove)
28314 5:
28315 sub $0x20, %rdx
28316 movq 0*8(%rsi), %r11
28317 - movq 1*8(%rsi), %r10
28318 + movq 1*8(%rsi), %rcx
28319 movq 2*8(%rsi), %r9
28320 movq 3*8(%rsi), %r8
28321 leaq 4*8(%rsi), %rsi
28322
28323 movq %r11, 0*8(%rdi)
28324 - movq %r10, 1*8(%rdi)
28325 + movq %rcx, 1*8(%rdi)
28326 movq %r9, 2*8(%rdi)
28327 movq %r8, 3*8(%rdi)
28328 leaq 4*8(%rdi), %rdi
28329 @@ -81,10 +81,10 @@ ENTRY(memmove)
28330 4:
28331 movq %rdx, %rcx
28332 movq -8(%rsi, %rdx), %r11
28333 - lea -8(%rdi, %rdx), %r10
28334 + lea -8(%rdi, %rdx), %r9
28335 shrq $3, %rcx
28336 rep movsq
28337 - movq %r11, (%r10)
28338 + movq %r11, (%r9)
28339 jmp 13f
28340 .Lmemmove_end_forward:
28341
28342 @@ -95,14 +95,14 @@ ENTRY(memmove)
28343 7:
28344 movq %rdx, %rcx
28345 movq (%rsi), %r11
28346 - movq %rdi, %r10
28347 + movq %rdi, %r9
28348 leaq -8(%rsi, %rdx), %rsi
28349 leaq -8(%rdi, %rdx), %rdi
28350 shrq $3, %rcx
28351 std
28352 rep movsq
28353 cld
28354 - movq %r11, (%r10)
28355 + movq %r11, (%r9)
28356 jmp 13f
28357
28358 /*
28359 @@ -127,13 +127,13 @@ ENTRY(memmove)
28360 8:
28361 subq $0x20, %rdx
28362 movq -1*8(%rsi), %r11
28363 - movq -2*8(%rsi), %r10
28364 + movq -2*8(%rsi), %rcx
28365 movq -3*8(%rsi), %r9
28366 movq -4*8(%rsi), %r8
28367 leaq -4*8(%rsi), %rsi
28368
28369 movq %r11, -1*8(%rdi)
28370 - movq %r10, -2*8(%rdi)
28371 + movq %rcx, -2*8(%rdi)
28372 movq %r9, -3*8(%rdi)
28373 movq %r8, -4*8(%rdi)
28374 leaq -4*8(%rdi), %rdi
28375 @@ -151,11 +151,11 @@ ENTRY(memmove)
28376 * Move data from 16 bytes to 31 bytes.
28377 */
28378 movq 0*8(%rsi), %r11
28379 - movq 1*8(%rsi), %r10
28380 + movq 1*8(%rsi), %rcx
28381 movq -2*8(%rsi, %rdx), %r9
28382 movq -1*8(%rsi, %rdx), %r8
28383 movq %r11, 0*8(%rdi)
28384 - movq %r10, 1*8(%rdi)
28385 + movq %rcx, 1*8(%rdi)
28386 movq %r9, -2*8(%rdi, %rdx)
28387 movq %r8, -1*8(%rdi, %rdx)
28388 jmp 13f
28389 @@ -167,9 +167,9 @@ ENTRY(memmove)
28390 * Move data from 8 bytes to 15 bytes.
28391 */
28392 movq 0*8(%rsi), %r11
28393 - movq -1*8(%rsi, %rdx), %r10
28394 + movq -1*8(%rsi, %rdx), %r9
28395 movq %r11, 0*8(%rdi)
28396 - movq %r10, -1*8(%rdi, %rdx)
28397 + movq %r9, -1*8(%rdi, %rdx)
28398 jmp 13f
28399 10:
28400 cmpq $4, %rdx
28401 @@ -178,9 +178,9 @@ ENTRY(memmove)
28402 * Move data from 4 bytes to 7 bytes.
28403 */
28404 movl (%rsi), %r11d
28405 - movl -4(%rsi, %rdx), %r10d
28406 + movl -4(%rsi, %rdx), %r9d
28407 movl %r11d, (%rdi)
28408 - movl %r10d, -4(%rdi, %rdx)
28409 + movl %r9d, -4(%rdi, %rdx)
28410 jmp 13f
28411 11:
28412 cmp $2, %rdx
28413 @@ -189,9 +189,9 @@ ENTRY(memmove)
28414 * Move data from 2 bytes to 3 bytes.
28415 */
28416 movw (%rsi), %r11w
28417 - movw -2(%rsi, %rdx), %r10w
28418 + movw -2(%rsi, %rdx), %r9w
28419 movw %r11w, (%rdi)
28420 - movw %r10w, -2(%rdi, %rdx)
28421 + movw %r9w, -2(%rdi, %rdx)
28422 jmp 13f
28423 12:
28424 cmp $1, %rdx
28425 @@ -202,14 +202,16 @@ ENTRY(memmove)
28426 movb (%rsi), %r11b
28427 movb %r11b, (%rdi)
28428 13:
28429 + pax_force_retaddr
28430 retq
28431 CFI_ENDPROC
28432
28433 - .section .altinstr_replacement,"ax"
28434 + .section .altinstr_replacement,"a"
28435 .Lmemmove_begin_forward_efs:
28436 /* Forward moving data. */
28437 movq %rdx, %rcx
28438 rep movsb
28439 + pax_force_retaddr
28440 retq
28441 .Lmemmove_end_forward_efs:
28442 .previous
28443 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28444 index 2dcb380..50a78bc 100644
28445 --- a/arch/x86/lib/memset_64.S
28446 +++ b/arch/x86/lib/memset_64.S
28447 @@ -16,7 +16,7 @@
28448 *
28449 * rax original destination
28450 */
28451 - .section .altinstr_replacement, "ax", @progbits
28452 + .section .altinstr_replacement, "a", @progbits
28453 .Lmemset_c:
28454 movq %rdi,%r9
28455 movq %rdx,%rcx
28456 @@ -30,6 +30,7 @@
28457 movl %edx,%ecx
28458 rep stosb
28459 movq %r9,%rax
28460 + pax_force_retaddr
28461 ret
28462 .Lmemset_e:
28463 .previous
28464 @@ -45,13 +46,14 @@
28465 *
28466 * rax original destination
28467 */
28468 - .section .altinstr_replacement, "ax", @progbits
28469 + .section .altinstr_replacement, "a", @progbits
28470 .Lmemset_c_e:
28471 movq %rdi,%r9
28472 movb %sil,%al
28473 movq %rdx,%rcx
28474 rep stosb
28475 movq %r9,%rax
28476 + pax_force_retaddr
28477 ret
28478 .Lmemset_e_e:
28479 .previous
28480 @@ -59,7 +61,7 @@
28481 ENTRY(memset)
28482 ENTRY(__memset)
28483 CFI_STARTPROC
28484 - movq %rdi,%r10
28485 + movq %rdi,%r11
28486
28487 /* expand byte value */
28488 movzbl %sil,%ecx
28489 @@ -117,7 +119,8 @@ ENTRY(__memset)
28490 jnz .Lloop_1
28491
28492 .Lende:
28493 - movq %r10,%rax
28494 + movq %r11,%rax
28495 + pax_force_retaddr
28496 ret
28497
28498 CFI_RESTORE_STATE
28499 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28500 index c9f2d9b..e7fd2c0 100644
28501 --- a/arch/x86/lib/mmx_32.c
28502 +++ b/arch/x86/lib/mmx_32.c
28503 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28504 {
28505 void *p;
28506 int i;
28507 + unsigned long cr0;
28508
28509 if (unlikely(in_interrupt()))
28510 return __memcpy(to, from, len);
28511 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28512 kernel_fpu_begin();
28513
28514 __asm__ __volatile__ (
28515 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28516 - " prefetch 64(%0)\n"
28517 - " prefetch 128(%0)\n"
28518 - " prefetch 192(%0)\n"
28519 - " prefetch 256(%0)\n"
28520 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28521 + " prefetch 64(%1)\n"
28522 + " prefetch 128(%1)\n"
28523 + " prefetch 192(%1)\n"
28524 + " prefetch 256(%1)\n"
28525 "2: \n"
28526 ".section .fixup, \"ax\"\n"
28527 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28528 + "3: \n"
28529 +
28530 +#ifdef CONFIG_PAX_KERNEXEC
28531 + " movl %%cr0, %0\n"
28532 + " movl %0, %%eax\n"
28533 + " andl $0xFFFEFFFF, %%eax\n"
28534 + " movl %%eax, %%cr0\n"
28535 +#endif
28536 +
28537 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28538 +
28539 +#ifdef CONFIG_PAX_KERNEXEC
28540 + " movl %0, %%cr0\n"
28541 +#endif
28542 +
28543 " jmp 2b\n"
28544 ".previous\n"
28545 _ASM_EXTABLE(1b, 3b)
28546 - : : "r" (from));
28547 + : "=&r" (cr0) : "r" (from) : "ax");
28548
28549 for ( ; i > 5; i--) {
28550 __asm__ __volatile__ (
28551 - "1: prefetch 320(%0)\n"
28552 - "2: movq (%0), %%mm0\n"
28553 - " movq 8(%0), %%mm1\n"
28554 - " movq 16(%0), %%mm2\n"
28555 - " movq 24(%0), %%mm3\n"
28556 - " movq %%mm0, (%1)\n"
28557 - " movq %%mm1, 8(%1)\n"
28558 - " movq %%mm2, 16(%1)\n"
28559 - " movq %%mm3, 24(%1)\n"
28560 - " movq 32(%0), %%mm0\n"
28561 - " movq 40(%0), %%mm1\n"
28562 - " movq 48(%0), %%mm2\n"
28563 - " movq 56(%0), %%mm3\n"
28564 - " movq %%mm0, 32(%1)\n"
28565 - " movq %%mm1, 40(%1)\n"
28566 - " movq %%mm2, 48(%1)\n"
28567 - " movq %%mm3, 56(%1)\n"
28568 + "1: prefetch 320(%1)\n"
28569 + "2: movq (%1), %%mm0\n"
28570 + " movq 8(%1), %%mm1\n"
28571 + " movq 16(%1), %%mm2\n"
28572 + " movq 24(%1), %%mm3\n"
28573 + " movq %%mm0, (%2)\n"
28574 + " movq %%mm1, 8(%2)\n"
28575 + " movq %%mm2, 16(%2)\n"
28576 + " movq %%mm3, 24(%2)\n"
28577 + " movq 32(%1), %%mm0\n"
28578 + " movq 40(%1), %%mm1\n"
28579 + " movq 48(%1), %%mm2\n"
28580 + " movq 56(%1), %%mm3\n"
28581 + " movq %%mm0, 32(%2)\n"
28582 + " movq %%mm1, 40(%2)\n"
28583 + " movq %%mm2, 48(%2)\n"
28584 + " movq %%mm3, 56(%2)\n"
28585 ".section .fixup, \"ax\"\n"
28586 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28587 + "3:\n"
28588 +
28589 +#ifdef CONFIG_PAX_KERNEXEC
28590 + " movl %%cr0, %0\n"
28591 + " movl %0, %%eax\n"
28592 + " andl $0xFFFEFFFF, %%eax\n"
28593 + " movl %%eax, %%cr0\n"
28594 +#endif
28595 +
28596 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28597 +
28598 +#ifdef CONFIG_PAX_KERNEXEC
28599 + " movl %0, %%cr0\n"
28600 +#endif
28601 +
28602 " jmp 2b\n"
28603 ".previous\n"
28604 _ASM_EXTABLE(1b, 3b)
28605 - : : "r" (from), "r" (to) : "memory");
28606 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28607
28608 from += 64;
28609 to += 64;
28610 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28611 static void fast_copy_page(void *to, void *from)
28612 {
28613 int i;
28614 + unsigned long cr0;
28615
28616 kernel_fpu_begin();
28617
28618 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28619 * but that is for later. -AV
28620 */
28621 __asm__ __volatile__(
28622 - "1: prefetch (%0)\n"
28623 - " prefetch 64(%0)\n"
28624 - " prefetch 128(%0)\n"
28625 - " prefetch 192(%0)\n"
28626 - " prefetch 256(%0)\n"
28627 + "1: prefetch (%1)\n"
28628 + " prefetch 64(%1)\n"
28629 + " prefetch 128(%1)\n"
28630 + " prefetch 192(%1)\n"
28631 + " prefetch 256(%1)\n"
28632 "2: \n"
28633 ".section .fixup, \"ax\"\n"
28634 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28635 + "3: \n"
28636 +
28637 +#ifdef CONFIG_PAX_KERNEXEC
28638 + " movl %%cr0, %0\n"
28639 + " movl %0, %%eax\n"
28640 + " andl $0xFFFEFFFF, %%eax\n"
28641 + " movl %%eax, %%cr0\n"
28642 +#endif
28643 +
28644 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28645 +
28646 +#ifdef CONFIG_PAX_KERNEXEC
28647 + " movl %0, %%cr0\n"
28648 +#endif
28649 +
28650 " jmp 2b\n"
28651 ".previous\n"
28652 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28653 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28654
28655 for (i = 0; i < (4096-320)/64; i++) {
28656 __asm__ __volatile__ (
28657 - "1: prefetch 320(%0)\n"
28658 - "2: movq (%0), %%mm0\n"
28659 - " movntq %%mm0, (%1)\n"
28660 - " movq 8(%0), %%mm1\n"
28661 - " movntq %%mm1, 8(%1)\n"
28662 - " movq 16(%0), %%mm2\n"
28663 - " movntq %%mm2, 16(%1)\n"
28664 - " movq 24(%0), %%mm3\n"
28665 - " movntq %%mm3, 24(%1)\n"
28666 - " movq 32(%0), %%mm4\n"
28667 - " movntq %%mm4, 32(%1)\n"
28668 - " movq 40(%0), %%mm5\n"
28669 - " movntq %%mm5, 40(%1)\n"
28670 - " movq 48(%0), %%mm6\n"
28671 - " movntq %%mm6, 48(%1)\n"
28672 - " movq 56(%0), %%mm7\n"
28673 - " movntq %%mm7, 56(%1)\n"
28674 + "1: prefetch 320(%1)\n"
28675 + "2: movq (%1), %%mm0\n"
28676 + " movntq %%mm0, (%2)\n"
28677 + " movq 8(%1), %%mm1\n"
28678 + " movntq %%mm1, 8(%2)\n"
28679 + " movq 16(%1), %%mm2\n"
28680 + " movntq %%mm2, 16(%2)\n"
28681 + " movq 24(%1), %%mm3\n"
28682 + " movntq %%mm3, 24(%2)\n"
28683 + " movq 32(%1), %%mm4\n"
28684 + " movntq %%mm4, 32(%2)\n"
28685 + " movq 40(%1), %%mm5\n"
28686 + " movntq %%mm5, 40(%2)\n"
28687 + " movq 48(%1), %%mm6\n"
28688 + " movntq %%mm6, 48(%2)\n"
28689 + " movq 56(%1), %%mm7\n"
28690 + " movntq %%mm7, 56(%2)\n"
28691 ".section .fixup, \"ax\"\n"
28692 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28693 + "3:\n"
28694 +
28695 +#ifdef CONFIG_PAX_KERNEXEC
28696 + " movl %%cr0, %0\n"
28697 + " movl %0, %%eax\n"
28698 + " andl $0xFFFEFFFF, %%eax\n"
28699 + " movl %%eax, %%cr0\n"
28700 +#endif
28701 +
28702 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28703 +
28704 +#ifdef CONFIG_PAX_KERNEXEC
28705 + " movl %0, %%cr0\n"
28706 +#endif
28707 +
28708 " jmp 2b\n"
28709 ".previous\n"
28710 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28711 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28712
28713 from += 64;
28714 to += 64;
28715 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28716 static void fast_copy_page(void *to, void *from)
28717 {
28718 int i;
28719 + unsigned long cr0;
28720
28721 kernel_fpu_begin();
28722
28723 __asm__ __volatile__ (
28724 - "1: prefetch (%0)\n"
28725 - " prefetch 64(%0)\n"
28726 - " prefetch 128(%0)\n"
28727 - " prefetch 192(%0)\n"
28728 - " prefetch 256(%0)\n"
28729 + "1: prefetch (%1)\n"
28730 + " prefetch 64(%1)\n"
28731 + " prefetch 128(%1)\n"
28732 + " prefetch 192(%1)\n"
28733 + " prefetch 256(%1)\n"
28734 "2: \n"
28735 ".section .fixup, \"ax\"\n"
28736 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28737 + "3: \n"
28738 +
28739 +#ifdef CONFIG_PAX_KERNEXEC
28740 + " movl %%cr0, %0\n"
28741 + " movl %0, %%eax\n"
28742 + " andl $0xFFFEFFFF, %%eax\n"
28743 + " movl %%eax, %%cr0\n"
28744 +#endif
28745 +
28746 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28747 +
28748 +#ifdef CONFIG_PAX_KERNEXEC
28749 + " movl %0, %%cr0\n"
28750 +#endif
28751 +
28752 " jmp 2b\n"
28753 ".previous\n"
28754 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28755 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28756
28757 for (i = 0; i < 4096/64; i++) {
28758 __asm__ __volatile__ (
28759 - "1: prefetch 320(%0)\n"
28760 - "2: movq (%0), %%mm0\n"
28761 - " movq 8(%0), %%mm1\n"
28762 - " movq 16(%0), %%mm2\n"
28763 - " movq 24(%0), %%mm3\n"
28764 - " movq %%mm0, (%1)\n"
28765 - " movq %%mm1, 8(%1)\n"
28766 - " movq %%mm2, 16(%1)\n"
28767 - " movq %%mm3, 24(%1)\n"
28768 - " movq 32(%0), %%mm0\n"
28769 - " movq 40(%0), %%mm1\n"
28770 - " movq 48(%0), %%mm2\n"
28771 - " movq 56(%0), %%mm3\n"
28772 - " movq %%mm0, 32(%1)\n"
28773 - " movq %%mm1, 40(%1)\n"
28774 - " movq %%mm2, 48(%1)\n"
28775 - " movq %%mm3, 56(%1)\n"
28776 + "1: prefetch 320(%1)\n"
28777 + "2: movq (%1), %%mm0\n"
28778 + " movq 8(%1), %%mm1\n"
28779 + " movq 16(%1), %%mm2\n"
28780 + " movq 24(%1), %%mm3\n"
28781 + " movq %%mm0, (%2)\n"
28782 + " movq %%mm1, 8(%2)\n"
28783 + " movq %%mm2, 16(%2)\n"
28784 + " movq %%mm3, 24(%2)\n"
28785 + " movq 32(%1), %%mm0\n"
28786 + " movq 40(%1), %%mm1\n"
28787 + " movq 48(%1), %%mm2\n"
28788 + " movq 56(%1), %%mm3\n"
28789 + " movq %%mm0, 32(%2)\n"
28790 + " movq %%mm1, 40(%2)\n"
28791 + " movq %%mm2, 48(%2)\n"
28792 + " movq %%mm3, 56(%2)\n"
28793 ".section .fixup, \"ax\"\n"
28794 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28795 + "3:\n"
28796 +
28797 +#ifdef CONFIG_PAX_KERNEXEC
28798 + " movl %%cr0, %0\n"
28799 + " movl %0, %%eax\n"
28800 + " andl $0xFFFEFFFF, %%eax\n"
28801 + " movl %%eax, %%cr0\n"
28802 +#endif
28803 +
28804 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28805 +
28806 +#ifdef CONFIG_PAX_KERNEXEC
28807 + " movl %0, %%cr0\n"
28808 +#endif
28809 +
28810 " jmp 2b\n"
28811 ".previous\n"
28812 _ASM_EXTABLE(1b, 3b)
28813 - : : "r" (from), "r" (to) : "memory");
28814 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28815
28816 from += 64;
28817 to += 64;
28818 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28819 index f6d13ee..aca5f0b 100644
28820 --- a/arch/x86/lib/msr-reg.S
28821 +++ b/arch/x86/lib/msr-reg.S
28822 @@ -3,6 +3,7 @@
28823 #include <asm/dwarf2.h>
28824 #include <asm/asm.h>
28825 #include <asm/msr.h>
28826 +#include <asm/alternative-asm.h>
28827
28828 #ifdef CONFIG_X86_64
28829 /*
28830 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28831 CFI_STARTPROC
28832 pushq_cfi %rbx
28833 pushq_cfi %rbp
28834 - movq %rdi, %r10 /* Save pointer */
28835 + movq %rdi, %r9 /* Save pointer */
28836 xorl %r11d, %r11d /* Return value */
28837 movl (%rdi), %eax
28838 movl 4(%rdi), %ecx
28839 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28840 movl 28(%rdi), %edi
28841 CFI_REMEMBER_STATE
28842 1: \op
28843 -2: movl %eax, (%r10)
28844 +2: movl %eax, (%r9)
28845 movl %r11d, %eax /* Return value */
28846 - movl %ecx, 4(%r10)
28847 - movl %edx, 8(%r10)
28848 - movl %ebx, 12(%r10)
28849 - movl %ebp, 20(%r10)
28850 - movl %esi, 24(%r10)
28851 - movl %edi, 28(%r10)
28852 + movl %ecx, 4(%r9)
28853 + movl %edx, 8(%r9)
28854 + movl %ebx, 12(%r9)
28855 + movl %ebp, 20(%r9)
28856 + movl %esi, 24(%r9)
28857 + movl %edi, 28(%r9)
28858 popq_cfi %rbp
28859 popq_cfi %rbx
28860 + pax_force_retaddr
28861 ret
28862 3:
28863 CFI_RESTORE_STATE
28864 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28865 index fc6ba17..d4d989d 100644
28866 --- a/arch/x86/lib/putuser.S
28867 +++ b/arch/x86/lib/putuser.S
28868 @@ -16,7 +16,9 @@
28869 #include <asm/errno.h>
28870 #include <asm/asm.h>
28871 #include <asm/smap.h>
28872 -
28873 +#include <asm/segment.h>
28874 +#include <asm/pgtable.h>
28875 +#include <asm/alternative-asm.h>
28876
28877 /*
28878 * __put_user_X
28879 @@ -30,57 +32,125 @@
28880 * as they get called from within inline assembly.
28881 */
28882
28883 -#define ENTER CFI_STARTPROC ; \
28884 - GET_THREAD_INFO(%_ASM_BX)
28885 -#define EXIT ASM_CLAC ; \
28886 - ret ; \
28887 +#define ENTER CFI_STARTPROC
28888 +#define EXIT ASM_CLAC ; \
28889 + pax_force_retaddr ; \
28890 + ret ; \
28891 CFI_ENDPROC
28892
28893 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28894 +#define _DEST %_ASM_CX,%_ASM_BX
28895 +#else
28896 +#define _DEST %_ASM_CX
28897 +#endif
28898 +
28899 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28900 +#define __copyuser_seg gs;
28901 +#else
28902 +#define __copyuser_seg
28903 +#endif
28904 +
28905 .text
28906 ENTRY(__put_user_1)
28907 ENTER
28908 +
28909 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28910 + GET_THREAD_INFO(%_ASM_BX)
28911 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28912 jae bad_put_user
28913 ASM_STAC
28914 -1: movb %al,(%_ASM_CX)
28915 +
28916 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28917 + mov pax_user_shadow_base,%_ASM_BX
28918 + cmp %_ASM_BX,%_ASM_CX
28919 + jb 1234f
28920 + xor %ebx,%ebx
28921 +1234:
28922 +#endif
28923 +
28924 +#endif
28925 +
28926 +1: __copyuser_seg movb %al,(_DEST)
28927 xor %eax,%eax
28928 EXIT
28929 ENDPROC(__put_user_1)
28930
28931 ENTRY(__put_user_2)
28932 ENTER
28933 +
28934 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28935 + GET_THREAD_INFO(%_ASM_BX)
28936 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28937 sub $1,%_ASM_BX
28938 cmp %_ASM_BX,%_ASM_CX
28939 jae bad_put_user
28940 ASM_STAC
28941 -2: movw %ax,(%_ASM_CX)
28942 +
28943 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28944 + mov pax_user_shadow_base,%_ASM_BX
28945 + cmp %_ASM_BX,%_ASM_CX
28946 + jb 1234f
28947 + xor %ebx,%ebx
28948 +1234:
28949 +#endif
28950 +
28951 +#endif
28952 +
28953 +2: __copyuser_seg movw %ax,(_DEST)
28954 xor %eax,%eax
28955 EXIT
28956 ENDPROC(__put_user_2)
28957
28958 ENTRY(__put_user_4)
28959 ENTER
28960 +
28961 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28962 + GET_THREAD_INFO(%_ASM_BX)
28963 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28964 sub $3,%_ASM_BX
28965 cmp %_ASM_BX,%_ASM_CX
28966 jae bad_put_user
28967 ASM_STAC
28968 -3: movl %eax,(%_ASM_CX)
28969 +
28970 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28971 + mov pax_user_shadow_base,%_ASM_BX
28972 + cmp %_ASM_BX,%_ASM_CX
28973 + jb 1234f
28974 + xor %ebx,%ebx
28975 +1234:
28976 +#endif
28977 +
28978 +#endif
28979 +
28980 +3: __copyuser_seg movl %eax,(_DEST)
28981 xor %eax,%eax
28982 EXIT
28983 ENDPROC(__put_user_4)
28984
28985 ENTRY(__put_user_8)
28986 ENTER
28987 +
28988 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28989 + GET_THREAD_INFO(%_ASM_BX)
28990 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28991 sub $7,%_ASM_BX
28992 cmp %_ASM_BX,%_ASM_CX
28993 jae bad_put_user
28994 ASM_STAC
28995 -4: mov %_ASM_AX,(%_ASM_CX)
28996 +
28997 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28998 + mov pax_user_shadow_base,%_ASM_BX
28999 + cmp %_ASM_BX,%_ASM_CX
29000 + jb 1234f
29001 + xor %ebx,%ebx
29002 +1234:
29003 +#endif
29004 +
29005 +#endif
29006 +
29007 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29008 #ifdef CONFIG_X86_32
29009 -5: movl %edx,4(%_ASM_CX)
29010 +5: __copyuser_seg movl %edx,4(_DEST)
29011 #endif
29012 xor %eax,%eax
29013 EXIT
29014 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29015 index 1cad221..de671ee 100644
29016 --- a/arch/x86/lib/rwlock.S
29017 +++ b/arch/x86/lib/rwlock.S
29018 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29019 FRAME
29020 0: LOCK_PREFIX
29021 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29022 +
29023 +#ifdef CONFIG_PAX_REFCOUNT
29024 + jno 1234f
29025 + LOCK_PREFIX
29026 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29027 + int $4
29028 +1234:
29029 + _ASM_EXTABLE(1234b, 1234b)
29030 +#endif
29031 +
29032 1: rep; nop
29033 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29034 jne 1b
29035 LOCK_PREFIX
29036 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29037 +
29038 +#ifdef CONFIG_PAX_REFCOUNT
29039 + jno 1234f
29040 + LOCK_PREFIX
29041 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29042 + int $4
29043 +1234:
29044 + _ASM_EXTABLE(1234b, 1234b)
29045 +#endif
29046 +
29047 jnz 0b
29048 ENDFRAME
29049 + pax_force_retaddr
29050 ret
29051 CFI_ENDPROC
29052 END(__write_lock_failed)
29053 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29054 FRAME
29055 0: LOCK_PREFIX
29056 READ_LOCK_SIZE(inc) (%__lock_ptr)
29057 +
29058 +#ifdef CONFIG_PAX_REFCOUNT
29059 + jno 1234f
29060 + LOCK_PREFIX
29061 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29062 + int $4
29063 +1234:
29064 + _ASM_EXTABLE(1234b, 1234b)
29065 +#endif
29066 +
29067 1: rep; nop
29068 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29069 js 1b
29070 LOCK_PREFIX
29071 READ_LOCK_SIZE(dec) (%__lock_ptr)
29072 +
29073 +#ifdef CONFIG_PAX_REFCOUNT
29074 + jno 1234f
29075 + LOCK_PREFIX
29076 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29077 + int $4
29078 +1234:
29079 + _ASM_EXTABLE(1234b, 1234b)
29080 +#endif
29081 +
29082 js 0b
29083 ENDFRAME
29084 + pax_force_retaddr
29085 ret
29086 CFI_ENDPROC
29087 END(__read_lock_failed)
29088 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29089 index 5dff5f0..cadebf4 100644
29090 --- a/arch/x86/lib/rwsem.S
29091 +++ b/arch/x86/lib/rwsem.S
29092 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29093 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29094 CFI_RESTORE __ASM_REG(dx)
29095 restore_common_regs
29096 + pax_force_retaddr
29097 ret
29098 CFI_ENDPROC
29099 ENDPROC(call_rwsem_down_read_failed)
29100 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29101 movq %rax,%rdi
29102 call rwsem_down_write_failed
29103 restore_common_regs
29104 + pax_force_retaddr
29105 ret
29106 CFI_ENDPROC
29107 ENDPROC(call_rwsem_down_write_failed)
29108 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29109 movq %rax,%rdi
29110 call rwsem_wake
29111 restore_common_regs
29112 -1: ret
29113 +1: pax_force_retaddr
29114 + ret
29115 CFI_ENDPROC
29116 ENDPROC(call_rwsem_wake)
29117
29118 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29119 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29120 CFI_RESTORE __ASM_REG(dx)
29121 restore_common_regs
29122 + pax_force_retaddr
29123 ret
29124 CFI_ENDPROC
29125 ENDPROC(call_rwsem_downgrade_wake)
29126 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29127 index a63efd6..ccecad8 100644
29128 --- a/arch/x86/lib/thunk_64.S
29129 +++ b/arch/x86/lib/thunk_64.S
29130 @@ -8,6 +8,7 @@
29131 #include <linux/linkage.h>
29132 #include <asm/dwarf2.h>
29133 #include <asm/calling.h>
29134 +#include <asm/alternative-asm.h>
29135
29136 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29137 .macro THUNK name, func, put_ret_addr_in_rdi=0
29138 @@ -41,5 +42,6 @@
29139 SAVE_ARGS
29140 restore:
29141 RESTORE_ARGS
29142 + pax_force_retaddr
29143 ret
29144 CFI_ENDPROC
29145 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29146 index 3eb18ac..4b22130 100644
29147 --- a/arch/x86/lib/usercopy_32.c
29148 +++ b/arch/x86/lib/usercopy_32.c
29149 @@ -42,11 +42,13 @@ do { \
29150 int __d0; \
29151 might_fault(); \
29152 __asm__ __volatile__( \
29153 + __COPYUSER_SET_ES \
29154 ASM_STAC "\n" \
29155 "0: rep; stosl\n" \
29156 " movl %2,%0\n" \
29157 "1: rep; stosb\n" \
29158 "2: " ASM_CLAC "\n" \
29159 + __COPYUSER_RESTORE_ES \
29160 ".section .fixup,\"ax\"\n" \
29161 "3: lea 0(%2,%0,4),%0\n" \
29162 " jmp 2b\n" \
29163 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29164
29165 #ifdef CONFIG_X86_INTEL_USERCOPY
29166 static unsigned long
29167 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29168 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29169 {
29170 int d0, d1;
29171 __asm__ __volatile__(
29172 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29173 " .align 2,0x90\n"
29174 "3: movl 0(%4), %%eax\n"
29175 "4: movl 4(%4), %%edx\n"
29176 - "5: movl %%eax, 0(%3)\n"
29177 - "6: movl %%edx, 4(%3)\n"
29178 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29179 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29180 "7: movl 8(%4), %%eax\n"
29181 "8: movl 12(%4),%%edx\n"
29182 - "9: movl %%eax, 8(%3)\n"
29183 - "10: movl %%edx, 12(%3)\n"
29184 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29185 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29186 "11: movl 16(%4), %%eax\n"
29187 "12: movl 20(%4), %%edx\n"
29188 - "13: movl %%eax, 16(%3)\n"
29189 - "14: movl %%edx, 20(%3)\n"
29190 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29191 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29192 "15: movl 24(%4), %%eax\n"
29193 "16: movl 28(%4), %%edx\n"
29194 - "17: movl %%eax, 24(%3)\n"
29195 - "18: movl %%edx, 28(%3)\n"
29196 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29197 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29198 "19: movl 32(%4), %%eax\n"
29199 "20: movl 36(%4), %%edx\n"
29200 - "21: movl %%eax, 32(%3)\n"
29201 - "22: movl %%edx, 36(%3)\n"
29202 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29203 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29204 "23: movl 40(%4), %%eax\n"
29205 "24: movl 44(%4), %%edx\n"
29206 - "25: movl %%eax, 40(%3)\n"
29207 - "26: movl %%edx, 44(%3)\n"
29208 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29209 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29210 "27: movl 48(%4), %%eax\n"
29211 "28: movl 52(%4), %%edx\n"
29212 - "29: movl %%eax, 48(%3)\n"
29213 - "30: movl %%edx, 52(%3)\n"
29214 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29215 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29216 "31: movl 56(%4), %%eax\n"
29217 "32: movl 60(%4), %%edx\n"
29218 - "33: movl %%eax, 56(%3)\n"
29219 - "34: movl %%edx, 60(%3)\n"
29220 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29221 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29222 " addl $-64, %0\n"
29223 " addl $64, %4\n"
29224 " addl $64, %3\n"
29225 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29226 " shrl $2, %0\n"
29227 " andl $3, %%eax\n"
29228 " cld\n"
29229 + __COPYUSER_SET_ES
29230 "99: rep; movsl\n"
29231 "36: movl %%eax, %0\n"
29232 "37: rep; movsb\n"
29233 "100:\n"
29234 + __COPYUSER_RESTORE_ES
29235 + ".section .fixup,\"ax\"\n"
29236 + "101: lea 0(%%eax,%0,4),%0\n"
29237 + " jmp 100b\n"
29238 + ".previous\n"
29239 + _ASM_EXTABLE(1b,100b)
29240 + _ASM_EXTABLE(2b,100b)
29241 + _ASM_EXTABLE(3b,100b)
29242 + _ASM_EXTABLE(4b,100b)
29243 + _ASM_EXTABLE(5b,100b)
29244 + _ASM_EXTABLE(6b,100b)
29245 + _ASM_EXTABLE(7b,100b)
29246 + _ASM_EXTABLE(8b,100b)
29247 + _ASM_EXTABLE(9b,100b)
29248 + _ASM_EXTABLE(10b,100b)
29249 + _ASM_EXTABLE(11b,100b)
29250 + _ASM_EXTABLE(12b,100b)
29251 + _ASM_EXTABLE(13b,100b)
29252 + _ASM_EXTABLE(14b,100b)
29253 + _ASM_EXTABLE(15b,100b)
29254 + _ASM_EXTABLE(16b,100b)
29255 + _ASM_EXTABLE(17b,100b)
29256 + _ASM_EXTABLE(18b,100b)
29257 + _ASM_EXTABLE(19b,100b)
29258 + _ASM_EXTABLE(20b,100b)
29259 + _ASM_EXTABLE(21b,100b)
29260 + _ASM_EXTABLE(22b,100b)
29261 + _ASM_EXTABLE(23b,100b)
29262 + _ASM_EXTABLE(24b,100b)
29263 + _ASM_EXTABLE(25b,100b)
29264 + _ASM_EXTABLE(26b,100b)
29265 + _ASM_EXTABLE(27b,100b)
29266 + _ASM_EXTABLE(28b,100b)
29267 + _ASM_EXTABLE(29b,100b)
29268 + _ASM_EXTABLE(30b,100b)
29269 + _ASM_EXTABLE(31b,100b)
29270 + _ASM_EXTABLE(32b,100b)
29271 + _ASM_EXTABLE(33b,100b)
29272 + _ASM_EXTABLE(34b,100b)
29273 + _ASM_EXTABLE(35b,100b)
29274 + _ASM_EXTABLE(36b,100b)
29275 + _ASM_EXTABLE(37b,100b)
29276 + _ASM_EXTABLE(99b,101b)
29277 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29278 + : "1"(to), "2"(from), "0"(size)
29279 + : "eax", "edx", "memory");
29280 + return size;
29281 +}
29282 +
29283 +static unsigned long
29284 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29285 +{
29286 + int d0, d1;
29287 + __asm__ __volatile__(
29288 + " .align 2,0x90\n"
29289 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29290 + " cmpl $67, %0\n"
29291 + " jbe 3f\n"
29292 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29293 + " .align 2,0x90\n"
29294 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29295 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29296 + "5: movl %%eax, 0(%3)\n"
29297 + "6: movl %%edx, 4(%3)\n"
29298 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29299 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29300 + "9: movl %%eax, 8(%3)\n"
29301 + "10: movl %%edx, 12(%3)\n"
29302 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29303 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29304 + "13: movl %%eax, 16(%3)\n"
29305 + "14: movl %%edx, 20(%3)\n"
29306 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29307 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29308 + "17: movl %%eax, 24(%3)\n"
29309 + "18: movl %%edx, 28(%3)\n"
29310 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29311 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29312 + "21: movl %%eax, 32(%3)\n"
29313 + "22: movl %%edx, 36(%3)\n"
29314 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29315 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29316 + "25: movl %%eax, 40(%3)\n"
29317 + "26: movl %%edx, 44(%3)\n"
29318 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29319 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29320 + "29: movl %%eax, 48(%3)\n"
29321 + "30: movl %%edx, 52(%3)\n"
29322 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29323 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29324 + "33: movl %%eax, 56(%3)\n"
29325 + "34: movl %%edx, 60(%3)\n"
29326 + " addl $-64, %0\n"
29327 + " addl $64, %4\n"
29328 + " addl $64, %3\n"
29329 + " cmpl $63, %0\n"
29330 + " ja 1b\n"
29331 + "35: movl %0, %%eax\n"
29332 + " shrl $2, %0\n"
29333 + " andl $3, %%eax\n"
29334 + " cld\n"
29335 + "99: rep; "__copyuser_seg" movsl\n"
29336 + "36: movl %%eax, %0\n"
29337 + "37: rep; "__copyuser_seg" movsb\n"
29338 + "100:\n"
29339 ".section .fixup,\"ax\"\n"
29340 "101: lea 0(%%eax,%0,4),%0\n"
29341 " jmp 100b\n"
29342 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29343 int d0, d1;
29344 __asm__ __volatile__(
29345 " .align 2,0x90\n"
29346 - "0: movl 32(%4), %%eax\n"
29347 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29348 " cmpl $67, %0\n"
29349 " jbe 2f\n"
29350 - "1: movl 64(%4), %%eax\n"
29351 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29352 " .align 2,0x90\n"
29353 - "2: movl 0(%4), %%eax\n"
29354 - "21: movl 4(%4), %%edx\n"
29355 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29356 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29357 " movl %%eax, 0(%3)\n"
29358 " movl %%edx, 4(%3)\n"
29359 - "3: movl 8(%4), %%eax\n"
29360 - "31: movl 12(%4),%%edx\n"
29361 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29362 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29363 " movl %%eax, 8(%3)\n"
29364 " movl %%edx, 12(%3)\n"
29365 - "4: movl 16(%4), %%eax\n"
29366 - "41: movl 20(%4), %%edx\n"
29367 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29368 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29369 " movl %%eax, 16(%3)\n"
29370 " movl %%edx, 20(%3)\n"
29371 - "10: movl 24(%4), %%eax\n"
29372 - "51: movl 28(%4), %%edx\n"
29373 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29374 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29375 " movl %%eax, 24(%3)\n"
29376 " movl %%edx, 28(%3)\n"
29377 - "11: movl 32(%4), %%eax\n"
29378 - "61: movl 36(%4), %%edx\n"
29379 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29380 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29381 " movl %%eax, 32(%3)\n"
29382 " movl %%edx, 36(%3)\n"
29383 - "12: movl 40(%4), %%eax\n"
29384 - "71: movl 44(%4), %%edx\n"
29385 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29386 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29387 " movl %%eax, 40(%3)\n"
29388 " movl %%edx, 44(%3)\n"
29389 - "13: movl 48(%4), %%eax\n"
29390 - "81: movl 52(%4), %%edx\n"
29391 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29392 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29393 " movl %%eax, 48(%3)\n"
29394 " movl %%edx, 52(%3)\n"
29395 - "14: movl 56(%4), %%eax\n"
29396 - "91: movl 60(%4), %%edx\n"
29397 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29398 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29399 " movl %%eax, 56(%3)\n"
29400 " movl %%edx, 60(%3)\n"
29401 " addl $-64, %0\n"
29402 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29403 " shrl $2, %0\n"
29404 " andl $3, %%eax\n"
29405 " cld\n"
29406 - "6: rep; movsl\n"
29407 + "6: rep; "__copyuser_seg" movsl\n"
29408 " movl %%eax,%0\n"
29409 - "7: rep; movsb\n"
29410 + "7: rep; "__copyuser_seg" movsb\n"
29411 "8:\n"
29412 ".section .fixup,\"ax\"\n"
29413 "9: lea 0(%%eax,%0,4),%0\n"
29414 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29415
29416 __asm__ __volatile__(
29417 " .align 2,0x90\n"
29418 - "0: movl 32(%4), %%eax\n"
29419 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29420 " cmpl $67, %0\n"
29421 " jbe 2f\n"
29422 - "1: movl 64(%4), %%eax\n"
29423 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29424 " .align 2,0x90\n"
29425 - "2: movl 0(%4), %%eax\n"
29426 - "21: movl 4(%4), %%edx\n"
29427 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29428 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29429 " movnti %%eax, 0(%3)\n"
29430 " movnti %%edx, 4(%3)\n"
29431 - "3: movl 8(%4), %%eax\n"
29432 - "31: movl 12(%4),%%edx\n"
29433 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29434 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29435 " movnti %%eax, 8(%3)\n"
29436 " movnti %%edx, 12(%3)\n"
29437 - "4: movl 16(%4), %%eax\n"
29438 - "41: movl 20(%4), %%edx\n"
29439 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29440 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29441 " movnti %%eax, 16(%3)\n"
29442 " movnti %%edx, 20(%3)\n"
29443 - "10: movl 24(%4), %%eax\n"
29444 - "51: movl 28(%4), %%edx\n"
29445 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29446 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29447 " movnti %%eax, 24(%3)\n"
29448 " movnti %%edx, 28(%3)\n"
29449 - "11: movl 32(%4), %%eax\n"
29450 - "61: movl 36(%4), %%edx\n"
29451 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29452 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29453 " movnti %%eax, 32(%3)\n"
29454 " movnti %%edx, 36(%3)\n"
29455 - "12: movl 40(%4), %%eax\n"
29456 - "71: movl 44(%4), %%edx\n"
29457 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29458 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29459 " movnti %%eax, 40(%3)\n"
29460 " movnti %%edx, 44(%3)\n"
29461 - "13: movl 48(%4), %%eax\n"
29462 - "81: movl 52(%4), %%edx\n"
29463 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29464 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29465 " movnti %%eax, 48(%3)\n"
29466 " movnti %%edx, 52(%3)\n"
29467 - "14: movl 56(%4), %%eax\n"
29468 - "91: movl 60(%4), %%edx\n"
29469 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29470 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29471 " movnti %%eax, 56(%3)\n"
29472 " movnti %%edx, 60(%3)\n"
29473 " addl $-64, %0\n"
29474 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29475 " shrl $2, %0\n"
29476 " andl $3, %%eax\n"
29477 " cld\n"
29478 - "6: rep; movsl\n"
29479 + "6: rep; "__copyuser_seg" movsl\n"
29480 " movl %%eax,%0\n"
29481 - "7: rep; movsb\n"
29482 + "7: rep; "__copyuser_seg" movsb\n"
29483 "8:\n"
29484 ".section .fixup,\"ax\"\n"
29485 "9: lea 0(%%eax,%0,4),%0\n"
29486 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
29487
29488 __asm__ __volatile__(
29489 " .align 2,0x90\n"
29490 - "0: movl 32(%4), %%eax\n"
29491 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29492 " cmpl $67, %0\n"
29493 " jbe 2f\n"
29494 - "1: movl 64(%4), %%eax\n"
29495 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29496 " .align 2,0x90\n"
29497 - "2: movl 0(%4), %%eax\n"
29498 - "21: movl 4(%4), %%edx\n"
29499 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29500 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29501 " movnti %%eax, 0(%3)\n"
29502 " movnti %%edx, 4(%3)\n"
29503 - "3: movl 8(%4), %%eax\n"
29504 - "31: movl 12(%4),%%edx\n"
29505 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29506 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29507 " movnti %%eax, 8(%3)\n"
29508 " movnti %%edx, 12(%3)\n"
29509 - "4: movl 16(%4), %%eax\n"
29510 - "41: movl 20(%4), %%edx\n"
29511 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29512 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29513 " movnti %%eax, 16(%3)\n"
29514 " movnti %%edx, 20(%3)\n"
29515 - "10: movl 24(%4), %%eax\n"
29516 - "51: movl 28(%4), %%edx\n"
29517 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29518 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29519 " movnti %%eax, 24(%3)\n"
29520 " movnti %%edx, 28(%3)\n"
29521 - "11: movl 32(%4), %%eax\n"
29522 - "61: movl 36(%4), %%edx\n"
29523 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29524 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29525 " movnti %%eax, 32(%3)\n"
29526 " movnti %%edx, 36(%3)\n"
29527 - "12: movl 40(%4), %%eax\n"
29528 - "71: movl 44(%4), %%edx\n"
29529 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29530 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29531 " movnti %%eax, 40(%3)\n"
29532 " movnti %%edx, 44(%3)\n"
29533 - "13: movl 48(%4), %%eax\n"
29534 - "81: movl 52(%4), %%edx\n"
29535 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29536 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29537 " movnti %%eax, 48(%3)\n"
29538 " movnti %%edx, 52(%3)\n"
29539 - "14: movl 56(%4), %%eax\n"
29540 - "91: movl 60(%4), %%edx\n"
29541 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29542 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29543 " movnti %%eax, 56(%3)\n"
29544 " movnti %%edx, 60(%3)\n"
29545 " addl $-64, %0\n"
29546 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29547 " shrl $2, %0\n"
29548 " andl $3, %%eax\n"
29549 " cld\n"
29550 - "6: rep; movsl\n"
29551 + "6: rep; "__copyuser_seg" movsl\n"
29552 " movl %%eax,%0\n"
29553 - "7: rep; movsb\n"
29554 + "7: rep; "__copyuser_seg" movsb\n"
29555 "8:\n"
29556 ".section .fixup,\"ax\"\n"
29557 "9: lea 0(%%eax,%0,4),%0\n"
29558 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29559 */
29560 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29561 unsigned long size);
29562 -unsigned long __copy_user_intel(void __user *to, const void *from,
29563 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29564 + unsigned long size);
29565 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29566 unsigned long size);
29567 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29568 const void __user *from, unsigned long size);
29569 #endif /* CONFIG_X86_INTEL_USERCOPY */
29570
29571 /* Generic arbitrary sized copy. */
29572 -#define __copy_user(to, from, size) \
29573 +#define __copy_user(to, from, size, prefix, set, restore) \
29574 do { \
29575 int __d0, __d1, __d2; \
29576 __asm__ __volatile__( \
29577 + set \
29578 " cmp $7,%0\n" \
29579 " jbe 1f\n" \
29580 " movl %1,%0\n" \
29581 " negl %0\n" \
29582 " andl $7,%0\n" \
29583 " subl %0,%3\n" \
29584 - "4: rep; movsb\n" \
29585 + "4: rep; "prefix"movsb\n" \
29586 " movl %3,%0\n" \
29587 " shrl $2,%0\n" \
29588 " andl $3,%3\n" \
29589 " .align 2,0x90\n" \
29590 - "0: rep; movsl\n" \
29591 + "0: rep; "prefix"movsl\n" \
29592 " movl %3,%0\n" \
29593 - "1: rep; movsb\n" \
29594 + "1: rep; "prefix"movsb\n" \
29595 "2:\n" \
29596 + restore \
29597 ".section .fixup,\"ax\"\n" \
29598 "5: addl %3,%0\n" \
29599 " jmp 2b\n" \
29600 @@ -538,14 +650,14 @@ do { \
29601 " negl %0\n" \
29602 " andl $7,%0\n" \
29603 " subl %0,%3\n" \
29604 - "4: rep; movsb\n" \
29605 + "4: rep; "__copyuser_seg"movsb\n" \
29606 " movl %3,%0\n" \
29607 " shrl $2,%0\n" \
29608 " andl $3,%3\n" \
29609 " .align 2,0x90\n" \
29610 - "0: rep; movsl\n" \
29611 + "0: rep; "__copyuser_seg"movsl\n" \
29612 " movl %3,%0\n" \
29613 - "1: rep; movsb\n" \
29614 + "1: rep; "__copyuser_seg"movsb\n" \
29615 "2:\n" \
29616 ".section .fixup,\"ax\"\n" \
29617 "5: addl %3,%0\n" \
29618 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29619 {
29620 stac();
29621 if (movsl_is_ok(to, from, n))
29622 - __copy_user(to, from, n);
29623 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29624 else
29625 - n = __copy_user_intel(to, from, n);
29626 + n = __generic_copy_to_user_intel(to, from, n);
29627 clac();
29628 return n;
29629 }
29630 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29631 {
29632 stac();
29633 if (movsl_is_ok(to, from, n))
29634 - __copy_user(to, from, n);
29635 + __copy_user(to, from, n, __copyuser_seg, "", "");
29636 else
29637 - n = __copy_user_intel((void __user *)to,
29638 - (const void *)from, n);
29639 + n = __generic_copy_from_user_intel(to, from, n);
29640 clac();
29641 return n;
29642 }
29643 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29644 if (n > 64 && cpu_has_xmm2)
29645 n = __copy_user_intel_nocache(to, from, n);
29646 else
29647 - __copy_user(to, from, n);
29648 + __copy_user(to, from, n, __copyuser_seg, "", "");
29649 #else
29650 - __copy_user(to, from, n);
29651 + __copy_user(to, from, n, __copyuser_seg, "", "");
29652 #endif
29653 clac();
29654 return n;
29655 }
29656 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29657
29658 -/**
29659 - * copy_to_user: - Copy a block of data into user space.
29660 - * @to: Destination address, in user space.
29661 - * @from: Source address, in kernel space.
29662 - * @n: Number of bytes to copy.
29663 - *
29664 - * Context: User context only. This function may sleep.
29665 - *
29666 - * Copy data from kernel space to user space.
29667 - *
29668 - * Returns number of bytes that could not be copied.
29669 - * On success, this will be zero.
29670 - */
29671 -unsigned long
29672 -copy_to_user(void __user *to, const void *from, unsigned long n)
29673 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29674 +void __set_fs(mm_segment_t x)
29675 {
29676 - if (access_ok(VERIFY_WRITE, to, n))
29677 - n = __copy_to_user(to, from, n);
29678 - return n;
29679 + switch (x.seg) {
29680 + case 0:
29681 + loadsegment(gs, 0);
29682 + break;
29683 + case TASK_SIZE_MAX:
29684 + loadsegment(gs, __USER_DS);
29685 + break;
29686 + case -1UL:
29687 + loadsegment(gs, __KERNEL_DS);
29688 + break;
29689 + default:
29690 + BUG();
29691 + }
29692 }
29693 -EXPORT_SYMBOL(copy_to_user);
29694 +EXPORT_SYMBOL(__set_fs);
29695
29696 -/**
29697 - * copy_from_user: - Copy a block of data from user space.
29698 - * @to: Destination address, in kernel space.
29699 - * @from: Source address, in user space.
29700 - * @n: Number of bytes to copy.
29701 - *
29702 - * Context: User context only. This function may sleep.
29703 - *
29704 - * Copy data from user space to kernel space.
29705 - *
29706 - * Returns number of bytes that could not be copied.
29707 - * On success, this will be zero.
29708 - *
29709 - * If some data could not be copied, this function will pad the copied
29710 - * data to the requested size using zero bytes.
29711 - */
29712 -unsigned long
29713 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29714 +void set_fs(mm_segment_t x)
29715 {
29716 - if (access_ok(VERIFY_READ, from, n))
29717 - n = __copy_from_user(to, from, n);
29718 - else
29719 - memset(to, 0, n);
29720 - return n;
29721 + current_thread_info()->addr_limit = x;
29722 + __set_fs(x);
29723 }
29724 -EXPORT_SYMBOL(_copy_from_user);
29725 +EXPORT_SYMBOL(set_fs);
29726 +#endif
29727 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29728 index c905e89..01ab928 100644
29729 --- a/arch/x86/lib/usercopy_64.c
29730 +++ b/arch/x86/lib/usercopy_64.c
29731 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29732 might_fault();
29733 /* no memory constraint because it doesn't change any memory gcc knows
29734 about */
29735 + pax_open_userland();
29736 stac();
29737 asm volatile(
29738 " testq %[size8],%[size8]\n"
29739 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29740 _ASM_EXTABLE(0b,3b)
29741 _ASM_EXTABLE(1b,2b)
29742 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29743 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29744 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29745 [zero] "r" (0UL), [eight] "r" (8UL));
29746 clac();
29747 + pax_close_userland();
29748 return size;
29749 }
29750 EXPORT_SYMBOL(__clear_user);
29751 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29752 }
29753 EXPORT_SYMBOL(clear_user);
29754
29755 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29756 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29757 {
29758 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29759 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29760 - }
29761 - return len;
29762 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29763 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29764 + return len;
29765 }
29766 EXPORT_SYMBOL(copy_in_user);
29767
29768 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29769 * it is not necessary to optimize tail handling.
29770 */
29771 __visible unsigned long
29772 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29773 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29774 {
29775 char c;
29776 unsigned zero_len;
29777
29778 + clac();
29779 + pax_close_userland();
29780 for (; len; --len, to++) {
29781 if (__get_user_nocheck(c, from++, sizeof(char)))
29782 break;
29783 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29784 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29785 if (__put_user_nocheck(c, to++, sizeof(char)))
29786 break;
29787 - clac();
29788 return len;
29789 }
29790 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29791 index 23d8e5f..9ccc13a 100644
29792 --- a/arch/x86/mm/Makefile
29793 +++ b/arch/x86/mm/Makefile
29794 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29795 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29796
29797 obj-$(CONFIG_MEMTEST) += memtest.o
29798 +
29799 +quote:="
29800 +obj-$(CONFIG_X86_64) += uderef_64.o
29801 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29802 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29803 index 903ec1e..c4166b2 100644
29804 --- a/arch/x86/mm/extable.c
29805 +++ b/arch/x86/mm/extable.c
29806 @@ -6,12 +6,24 @@
29807 static inline unsigned long
29808 ex_insn_addr(const struct exception_table_entry *x)
29809 {
29810 - return (unsigned long)&x->insn + x->insn;
29811 + unsigned long reloc = 0;
29812 +
29813 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29814 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29815 +#endif
29816 +
29817 + return (unsigned long)&x->insn + x->insn + reloc;
29818 }
29819 static inline unsigned long
29820 ex_fixup_addr(const struct exception_table_entry *x)
29821 {
29822 - return (unsigned long)&x->fixup + x->fixup;
29823 + unsigned long reloc = 0;
29824 +
29825 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29826 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29827 +#endif
29828 +
29829 + return (unsigned long)&x->fixup + x->fixup + reloc;
29830 }
29831
29832 int fixup_exception(struct pt_regs *regs)
29833 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29834 unsigned long new_ip;
29835
29836 #ifdef CONFIG_PNPBIOS
29837 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29838 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29839 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29840 extern u32 pnp_bios_is_utter_crap;
29841 pnp_bios_is_utter_crap = 1;
29842 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29843 i += 4;
29844 p->fixup -= i;
29845 i += 4;
29846 +
29847 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29848 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29849 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29850 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29851 +#endif
29852 +
29853 }
29854 }
29855
29856 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29857 index 3aaeffc..42ea9fb 100644
29858 --- a/arch/x86/mm/fault.c
29859 +++ b/arch/x86/mm/fault.c
29860 @@ -14,11 +14,18 @@
29861 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29862 #include <linux/prefetch.h> /* prefetchw */
29863 #include <linux/context_tracking.h> /* exception_enter(), ... */
29864 +#include <linux/unistd.h>
29865 +#include <linux/compiler.h>
29866
29867 #include <asm/traps.h> /* dotraplinkage, ... */
29868 #include <asm/pgalloc.h> /* pgd_*(), ... */
29869 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29870 #include <asm/fixmap.h> /* VSYSCALL_START */
29871 +#include <asm/tlbflush.h>
29872 +
29873 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29874 +#include <asm/stacktrace.h>
29875 +#endif
29876
29877 /*
29878 * Page fault error code bits:
29879 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29880 int ret = 0;
29881
29882 /* kprobe_running() needs smp_processor_id() */
29883 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29884 + if (kprobes_built_in() && !user_mode(regs)) {
29885 preempt_disable();
29886 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29887 ret = 1;
29888 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29889 return !instr_lo || (instr_lo>>1) == 1;
29890 case 0x00:
29891 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29892 - if (probe_kernel_address(instr, opcode))
29893 + if (user_mode(regs)) {
29894 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29895 + return 0;
29896 + } else if (probe_kernel_address(instr, opcode))
29897 return 0;
29898
29899 *prefetch = (instr_lo == 0xF) &&
29900 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29901 while (instr < max_instr) {
29902 unsigned char opcode;
29903
29904 - if (probe_kernel_address(instr, opcode))
29905 + if (user_mode(regs)) {
29906 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29907 + break;
29908 + } else if (probe_kernel_address(instr, opcode))
29909 break;
29910
29911 instr++;
29912 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29913 force_sig_info(si_signo, &info, tsk);
29914 }
29915
29916 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29917 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29918 +#endif
29919 +
29920 +#ifdef CONFIG_PAX_EMUTRAMP
29921 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29922 +#endif
29923 +
29924 +#ifdef CONFIG_PAX_PAGEEXEC
29925 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29926 +{
29927 + pgd_t *pgd;
29928 + pud_t *pud;
29929 + pmd_t *pmd;
29930 +
29931 + pgd = pgd_offset(mm, address);
29932 + if (!pgd_present(*pgd))
29933 + return NULL;
29934 + pud = pud_offset(pgd, address);
29935 + if (!pud_present(*pud))
29936 + return NULL;
29937 + pmd = pmd_offset(pud, address);
29938 + if (!pmd_present(*pmd))
29939 + return NULL;
29940 + return pmd;
29941 +}
29942 +#endif
29943 +
29944 DEFINE_SPINLOCK(pgd_lock);
29945 LIST_HEAD(pgd_list);
29946
29947 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29948 for (address = VMALLOC_START & PMD_MASK;
29949 address >= TASK_SIZE && address < FIXADDR_TOP;
29950 address += PMD_SIZE) {
29951 +
29952 +#ifdef CONFIG_PAX_PER_CPU_PGD
29953 + unsigned long cpu;
29954 +#else
29955 struct page *page;
29956 +#endif
29957
29958 spin_lock(&pgd_lock);
29959 +
29960 +#ifdef CONFIG_PAX_PER_CPU_PGD
29961 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29962 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29963 + pmd_t *ret;
29964 +
29965 + ret = vmalloc_sync_one(pgd, address);
29966 + if (!ret)
29967 + break;
29968 + pgd = get_cpu_pgd(cpu, kernel);
29969 +#else
29970 list_for_each_entry(page, &pgd_list, lru) {
29971 + pgd_t *pgd;
29972 spinlock_t *pgt_lock;
29973 pmd_t *ret;
29974
29975 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29976 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29977
29978 spin_lock(pgt_lock);
29979 - ret = vmalloc_sync_one(page_address(page), address);
29980 + pgd = page_address(page);
29981 +#endif
29982 +
29983 + ret = vmalloc_sync_one(pgd, address);
29984 +
29985 +#ifndef CONFIG_PAX_PER_CPU_PGD
29986 spin_unlock(pgt_lock);
29987 +#endif
29988
29989 if (!ret)
29990 break;
29991 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29992 * an interrupt in the middle of a task switch..
29993 */
29994 pgd_paddr = read_cr3();
29995 +
29996 +#ifdef CONFIG_PAX_PER_CPU_PGD
29997 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29998 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29999 +#endif
30000 +
30001 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30002 if (!pmd_k)
30003 return -1;
30004 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30005 * happen within a race in page table update. In the later
30006 * case just flush:
30007 */
30008 - pgd = pgd_offset(current->active_mm, address);
30009 +
30010 pgd_ref = pgd_offset_k(address);
30011 if (pgd_none(*pgd_ref))
30012 return -1;
30013
30014 +#ifdef CONFIG_PAX_PER_CPU_PGD
30015 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30016 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30017 + if (pgd_none(*pgd)) {
30018 + set_pgd(pgd, *pgd_ref);
30019 + arch_flush_lazy_mmu_mode();
30020 + } else {
30021 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30022 + }
30023 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30024 +#else
30025 + pgd = pgd_offset(current->active_mm, address);
30026 +#endif
30027 +
30028 if (pgd_none(*pgd)) {
30029 set_pgd(pgd, *pgd_ref);
30030 arch_flush_lazy_mmu_mode();
30031 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30032 static int is_errata100(struct pt_regs *regs, unsigned long address)
30033 {
30034 #ifdef CONFIG_X86_64
30035 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30036 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30037 return 1;
30038 #endif
30039 return 0;
30040 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30041 }
30042
30043 static const char nx_warning[] = KERN_CRIT
30044 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30045 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30046
30047 static void
30048 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30049 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30050 if (!oops_may_print())
30051 return;
30052
30053 - if (error_code & PF_INSTR) {
30054 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30055 unsigned int level;
30056
30057 pte_t *pte = lookup_address(address, &level);
30058
30059 if (pte && pte_present(*pte) && !pte_exec(*pte))
30060 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30061 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30062 }
30063
30064 +#ifdef CONFIG_PAX_KERNEXEC
30065 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30066 + if (current->signal->curr_ip)
30067 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30068 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30069 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30070 + else
30071 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30072 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30073 + }
30074 +#endif
30075 +
30076 printk(KERN_ALERT "BUG: unable to handle kernel ");
30077 if (address < PAGE_SIZE)
30078 printk(KERN_CONT "NULL pointer dereference");
30079 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30080 return;
30081 }
30082 #endif
30083 +
30084 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30085 + if (pax_is_fetch_fault(regs, error_code, address)) {
30086 +
30087 +#ifdef CONFIG_PAX_EMUTRAMP
30088 + switch (pax_handle_fetch_fault(regs)) {
30089 + case 2:
30090 + return;
30091 + }
30092 +#endif
30093 +
30094 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30095 + do_group_exit(SIGKILL);
30096 + }
30097 +#endif
30098 +
30099 /* Kernel addresses are always protection faults: */
30100 if (address >= TASK_SIZE)
30101 error_code |= PF_PROT;
30102 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30103 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30104 printk(KERN_ERR
30105 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30106 - tsk->comm, tsk->pid, address);
30107 + tsk->comm, task_pid_nr(tsk), address);
30108 code = BUS_MCEERR_AR;
30109 }
30110 #endif
30111 @@ -889,6 +1001,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30112 return 1;
30113 }
30114
30115 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30116 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30117 +{
30118 + pte_t *pte;
30119 + pmd_t *pmd;
30120 + spinlock_t *ptl;
30121 + unsigned char pte_mask;
30122 +
30123 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30124 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30125 + return 0;
30126 +
30127 + /* PaX: it's our fault, let's handle it if we can */
30128 +
30129 + /* PaX: take a look at read faults before acquiring any locks */
30130 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30131 + /* instruction fetch attempt from a protected page in user mode */
30132 + up_read(&mm->mmap_sem);
30133 +
30134 +#ifdef CONFIG_PAX_EMUTRAMP
30135 + switch (pax_handle_fetch_fault(regs)) {
30136 + case 2:
30137 + return 1;
30138 + }
30139 +#endif
30140 +
30141 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30142 + do_group_exit(SIGKILL);
30143 + }
30144 +
30145 + pmd = pax_get_pmd(mm, address);
30146 + if (unlikely(!pmd))
30147 + return 0;
30148 +
30149 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30150 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30151 + pte_unmap_unlock(pte, ptl);
30152 + return 0;
30153 + }
30154 +
30155 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30156 + /* write attempt to a protected page in user mode */
30157 + pte_unmap_unlock(pte, ptl);
30158 + return 0;
30159 + }
30160 +
30161 +#ifdef CONFIG_SMP
30162 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30163 +#else
30164 + if (likely(address > get_limit(regs->cs)))
30165 +#endif
30166 + {
30167 + set_pte(pte, pte_mkread(*pte));
30168 + __flush_tlb_one(address);
30169 + pte_unmap_unlock(pte, ptl);
30170 + up_read(&mm->mmap_sem);
30171 + return 1;
30172 + }
30173 +
30174 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30175 +
30176 + /*
30177 + * PaX: fill DTLB with user rights and retry
30178 + */
30179 + __asm__ __volatile__ (
30180 + "orb %2,(%1)\n"
30181 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30182 +/*
30183 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30184 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30185 + * page fault when examined during a TLB load attempt. this is true not only
30186 + * for PTEs holding a non-present entry but also present entries that will
30187 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30188 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30189 + * for our target pages since their PTEs are simply not in the TLBs at all.
30190 +
30191 + * the best thing in omitting it is that we gain around 15-20% speed in the
30192 + * fast path of the page fault handler and can get rid of tracing since we
30193 + * can no longer flush unintended entries.
30194 + */
30195 + "invlpg (%0)\n"
30196 +#endif
30197 + __copyuser_seg"testb $0,(%0)\n"
30198 + "xorb %3,(%1)\n"
30199 + :
30200 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30201 + : "memory", "cc");
30202 + pte_unmap_unlock(pte, ptl);
30203 + up_read(&mm->mmap_sem);
30204 + return 1;
30205 +}
30206 +#endif
30207 +
30208 /*
30209 * Handle a spurious fault caused by a stale TLB entry.
30210 *
30211 @@ -955,6 +1160,9 @@ int show_unhandled_signals = 1;
30212 static inline int
30213 access_error(unsigned long error_code, struct vm_area_struct *vma)
30214 {
30215 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30216 + return 1;
30217 +
30218 if (error_code & PF_WRITE) {
30219 /* write, present and write, not present: */
30220 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30221 @@ -983,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30222 if (error_code & PF_USER)
30223 return false;
30224
30225 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30226 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30227 return false;
30228
30229 return true;
30230 @@ -1010,6 +1218,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30231 /* Get the faulting address: */
30232 address = read_cr2();
30233
30234 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30235 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30236 + if (!search_exception_tables(regs->ip)) {
30237 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30238 + bad_area_nosemaphore(regs, error_code, address);
30239 + return;
30240 + }
30241 + if (address < pax_user_shadow_base) {
30242 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30243 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30244 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30245 + } else
30246 + address -= pax_user_shadow_base;
30247 + }
30248 +#endif
30249 +
30250 /*
30251 * Detect and handle instructions that would cause a page fault for
30252 * both a tracked kernel page and a userspace page.
30253 @@ -1069,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30254 * User-mode registers count as a user access even for any
30255 * potential system fault or CPU buglet:
30256 */
30257 - if (user_mode_vm(regs)) {
30258 + if (user_mode(regs)) {
30259 local_irq_enable();
30260 error_code |= PF_USER;
30261 flags |= FAULT_FLAG_USER;
30262 @@ -1135,6 +1359,11 @@ retry:
30263 might_sleep();
30264 }
30265
30266 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30267 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30268 + return;
30269 +#endif
30270 +
30271 vma = find_vma(mm, address);
30272 if (unlikely(!vma)) {
30273 bad_area(regs, error_code, address);
30274 @@ -1146,18 +1375,24 @@ retry:
30275 bad_area(regs, error_code, address);
30276 return;
30277 }
30278 - if (error_code & PF_USER) {
30279 - /*
30280 - * Accessing the stack below %sp is always a bug.
30281 - * The large cushion allows instructions like enter
30282 - * and pusha to work. ("enter $65535, $31" pushes
30283 - * 32 pointers and then decrements %sp by 65535.)
30284 - */
30285 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30286 - bad_area(regs, error_code, address);
30287 - return;
30288 - }
30289 + /*
30290 + * Accessing the stack below %sp is always a bug.
30291 + * The large cushion allows instructions like enter
30292 + * and pusha to work. ("enter $65535, $31" pushes
30293 + * 32 pointers and then decrements %sp by 65535.)
30294 + */
30295 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30296 + bad_area(regs, error_code, address);
30297 + return;
30298 }
30299 +
30300 +#ifdef CONFIG_PAX_SEGMEXEC
30301 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30302 + bad_area(regs, error_code, address);
30303 + return;
30304 + }
30305 +#endif
30306 +
30307 if (unlikely(expand_stack(vma, address))) {
30308 bad_area(regs, error_code, address);
30309 return;
30310 @@ -1231,3 +1466,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30311 __do_page_fault(regs, error_code);
30312 exception_exit(prev_state);
30313 }
30314 +
30315 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30316 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30317 +{
30318 + struct mm_struct *mm = current->mm;
30319 + unsigned long ip = regs->ip;
30320 +
30321 + if (v8086_mode(regs))
30322 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30323 +
30324 +#ifdef CONFIG_PAX_PAGEEXEC
30325 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30326 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30327 + return true;
30328 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30329 + return true;
30330 + return false;
30331 + }
30332 +#endif
30333 +
30334 +#ifdef CONFIG_PAX_SEGMEXEC
30335 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30336 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30337 + return true;
30338 + return false;
30339 + }
30340 +#endif
30341 +
30342 + return false;
30343 +}
30344 +#endif
30345 +
30346 +#ifdef CONFIG_PAX_EMUTRAMP
30347 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30348 +{
30349 + int err;
30350 +
30351 + do { /* PaX: libffi trampoline emulation */
30352 + unsigned char mov, jmp;
30353 + unsigned int addr1, addr2;
30354 +
30355 +#ifdef CONFIG_X86_64
30356 + if ((regs->ip + 9) >> 32)
30357 + break;
30358 +#endif
30359 +
30360 + err = get_user(mov, (unsigned char __user *)regs->ip);
30361 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30362 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30363 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30364 +
30365 + if (err)
30366 + break;
30367 +
30368 + if (mov == 0xB8 && jmp == 0xE9) {
30369 + regs->ax = addr1;
30370 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30371 + return 2;
30372 + }
30373 + } while (0);
30374 +
30375 + do { /* PaX: gcc trampoline emulation #1 */
30376 + unsigned char mov1, mov2;
30377 + unsigned short jmp;
30378 + unsigned int addr1, addr2;
30379 +
30380 +#ifdef CONFIG_X86_64
30381 + if ((regs->ip + 11) >> 32)
30382 + break;
30383 +#endif
30384 +
30385 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30386 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30387 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30388 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30389 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30390 +
30391 + if (err)
30392 + break;
30393 +
30394 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30395 + regs->cx = addr1;
30396 + regs->ax = addr2;
30397 + regs->ip = addr2;
30398 + return 2;
30399 + }
30400 + } while (0);
30401 +
30402 + do { /* PaX: gcc trampoline emulation #2 */
30403 + unsigned char mov, jmp;
30404 + unsigned int addr1, addr2;
30405 +
30406 +#ifdef CONFIG_X86_64
30407 + if ((regs->ip + 9) >> 32)
30408 + break;
30409 +#endif
30410 +
30411 + err = get_user(mov, (unsigned char __user *)regs->ip);
30412 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30413 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30414 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30415 +
30416 + if (err)
30417 + break;
30418 +
30419 + if (mov == 0xB9 && jmp == 0xE9) {
30420 + regs->cx = addr1;
30421 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30422 + return 2;
30423 + }
30424 + } while (0);
30425 +
30426 + return 1; /* PaX in action */
30427 +}
30428 +
30429 +#ifdef CONFIG_X86_64
30430 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30431 +{
30432 + int err;
30433 +
30434 + do { /* PaX: libffi trampoline emulation */
30435 + unsigned short mov1, mov2, jmp1;
30436 + unsigned char stcclc, jmp2;
30437 + unsigned long addr1, addr2;
30438 +
30439 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30440 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30441 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30442 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30443 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30444 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30445 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30446 +
30447 + if (err)
30448 + break;
30449 +
30450 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30451 + regs->r11 = addr1;
30452 + regs->r10 = addr2;
30453 + if (stcclc == 0xF8)
30454 + regs->flags &= ~X86_EFLAGS_CF;
30455 + else
30456 + regs->flags |= X86_EFLAGS_CF;
30457 + regs->ip = addr1;
30458 + return 2;
30459 + }
30460 + } while (0);
30461 +
30462 + do { /* PaX: gcc trampoline emulation #1 */
30463 + unsigned short mov1, mov2, jmp1;
30464 + unsigned char jmp2;
30465 + unsigned int addr1;
30466 + unsigned long addr2;
30467 +
30468 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30469 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30470 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30471 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30472 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30473 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30474 +
30475 + if (err)
30476 + break;
30477 +
30478 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30479 + regs->r11 = addr1;
30480 + regs->r10 = addr2;
30481 + regs->ip = addr1;
30482 + return 2;
30483 + }
30484 + } while (0);
30485 +
30486 + do { /* PaX: gcc trampoline emulation #2 */
30487 + unsigned short mov1, mov2, jmp1;
30488 + unsigned char jmp2;
30489 + unsigned long addr1, addr2;
30490 +
30491 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30492 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30493 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30494 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30495 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30496 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30497 +
30498 + if (err)
30499 + break;
30500 +
30501 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30502 + regs->r11 = addr1;
30503 + regs->r10 = addr2;
30504 + regs->ip = addr1;
30505 + return 2;
30506 + }
30507 + } while (0);
30508 +
30509 + return 1; /* PaX in action */
30510 +}
30511 +#endif
30512 +
30513 +/*
30514 + * PaX: decide what to do with offenders (regs->ip = fault address)
30515 + *
30516 + * returns 1 when task should be killed
30517 + * 2 when gcc trampoline was detected
30518 + */
30519 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30520 +{
30521 + if (v8086_mode(regs))
30522 + return 1;
30523 +
30524 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30525 + return 1;
30526 +
30527 +#ifdef CONFIG_X86_32
30528 + return pax_handle_fetch_fault_32(regs);
30529 +#else
30530 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30531 + return pax_handle_fetch_fault_32(regs);
30532 + else
30533 + return pax_handle_fetch_fault_64(regs);
30534 +#endif
30535 +}
30536 +#endif
30537 +
30538 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30539 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30540 +{
30541 + long i;
30542 +
30543 + printk(KERN_ERR "PAX: bytes at PC: ");
30544 + for (i = 0; i < 20; i++) {
30545 + unsigned char c;
30546 + if (get_user(c, (unsigned char __force_user *)pc+i))
30547 + printk(KERN_CONT "?? ");
30548 + else
30549 + printk(KERN_CONT "%02x ", c);
30550 + }
30551 + printk("\n");
30552 +
30553 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30554 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30555 + unsigned long c;
30556 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30557 +#ifdef CONFIG_X86_32
30558 + printk(KERN_CONT "???????? ");
30559 +#else
30560 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30561 + printk(KERN_CONT "???????? ???????? ");
30562 + else
30563 + printk(KERN_CONT "???????????????? ");
30564 +#endif
30565 + } else {
30566 +#ifdef CONFIG_X86_64
30567 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30568 + printk(KERN_CONT "%08x ", (unsigned int)c);
30569 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30570 + } else
30571 +#endif
30572 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30573 + }
30574 + }
30575 + printk("\n");
30576 +}
30577 +#endif
30578 +
30579 +/**
30580 + * probe_kernel_write(): safely attempt to write to a location
30581 + * @dst: address to write to
30582 + * @src: pointer to the data that shall be written
30583 + * @size: size of the data chunk
30584 + *
30585 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30586 + * happens, handle that and return -EFAULT.
30587 + */
30588 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30589 +{
30590 + long ret;
30591 + mm_segment_t old_fs = get_fs();
30592 +
30593 + set_fs(KERNEL_DS);
30594 + pagefault_disable();
30595 + pax_open_kernel();
30596 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30597 + pax_close_kernel();
30598 + pagefault_enable();
30599 + set_fs(old_fs);
30600 +
30601 + return ret ? -EFAULT : 0;
30602 +}
30603 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30604 index dd74e46..7d26398 100644
30605 --- a/arch/x86/mm/gup.c
30606 +++ b/arch/x86/mm/gup.c
30607 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30608 addr = start;
30609 len = (unsigned long) nr_pages << PAGE_SHIFT;
30610 end = start + len;
30611 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30612 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30613 (void __user *)start, len)))
30614 return 0;
30615
30616 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30617 index 4500142..53a363c 100644
30618 --- a/arch/x86/mm/highmem_32.c
30619 +++ b/arch/x86/mm/highmem_32.c
30620 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30621 idx = type + KM_TYPE_NR*smp_processor_id();
30622 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30623 BUG_ON(!pte_none(*(kmap_pte-idx)));
30624 +
30625 + pax_open_kernel();
30626 set_pte(kmap_pte-idx, mk_pte(page, prot));
30627 + pax_close_kernel();
30628 +
30629 arch_flush_lazy_mmu_mode();
30630
30631 return (void *)vaddr;
30632 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30633 index 9d980d8..6bbfacb 100644
30634 --- a/arch/x86/mm/hugetlbpage.c
30635 +++ b/arch/x86/mm/hugetlbpage.c
30636 @@ -92,23 +92,30 @@ int pmd_huge_support(void)
30637 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30638 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30639 unsigned long addr, unsigned long len,
30640 - unsigned long pgoff, unsigned long flags)
30641 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30642 {
30643 struct hstate *h = hstate_file(file);
30644 struct vm_unmapped_area_info info;
30645 -
30646 +
30647 info.flags = 0;
30648 info.length = len;
30649 info.low_limit = TASK_UNMAPPED_BASE;
30650 +
30651 +#ifdef CONFIG_PAX_RANDMMAP
30652 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30653 + info.low_limit += current->mm->delta_mmap;
30654 +#endif
30655 +
30656 info.high_limit = TASK_SIZE;
30657 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30658 info.align_offset = 0;
30659 + info.threadstack_offset = offset;
30660 return vm_unmapped_area(&info);
30661 }
30662
30663 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30664 unsigned long addr0, unsigned long len,
30665 - unsigned long pgoff, unsigned long flags)
30666 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30667 {
30668 struct hstate *h = hstate_file(file);
30669 struct vm_unmapped_area_info info;
30670 @@ -120,6 +127,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30671 info.high_limit = current->mm->mmap_base;
30672 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30673 info.align_offset = 0;
30674 + info.threadstack_offset = offset;
30675 addr = vm_unmapped_area(&info);
30676
30677 /*
30678 @@ -132,6 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30679 VM_BUG_ON(addr != -ENOMEM);
30680 info.flags = 0;
30681 info.low_limit = TASK_UNMAPPED_BASE;
30682 +
30683 +#ifdef CONFIG_PAX_RANDMMAP
30684 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30685 + info.low_limit += current->mm->delta_mmap;
30686 +#endif
30687 +
30688 info.high_limit = TASK_SIZE;
30689 addr = vm_unmapped_area(&info);
30690 }
30691 @@ -146,10 +160,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30692 struct hstate *h = hstate_file(file);
30693 struct mm_struct *mm = current->mm;
30694 struct vm_area_struct *vma;
30695 + unsigned long pax_task_size = TASK_SIZE;
30696 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30697
30698 if (len & ~huge_page_mask(h))
30699 return -EINVAL;
30700 - if (len > TASK_SIZE)
30701 +
30702 +#ifdef CONFIG_PAX_SEGMEXEC
30703 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30704 + pax_task_size = SEGMEXEC_TASK_SIZE;
30705 +#endif
30706 +
30707 + pax_task_size -= PAGE_SIZE;
30708 +
30709 + if (len > pax_task_size)
30710 return -ENOMEM;
30711
30712 if (flags & MAP_FIXED) {
30713 @@ -158,19 +182,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30714 return addr;
30715 }
30716
30717 +#ifdef CONFIG_PAX_RANDMMAP
30718 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30719 +#endif
30720 +
30721 if (addr) {
30722 addr = ALIGN(addr, huge_page_size(h));
30723 vma = find_vma(mm, addr);
30724 - if (TASK_SIZE - len >= addr &&
30725 - (!vma || addr + len <= vma->vm_start))
30726 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30727 return addr;
30728 }
30729 if (mm->get_unmapped_area == arch_get_unmapped_area)
30730 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30731 - pgoff, flags);
30732 + pgoff, flags, offset);
30733 else
30734 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30735 - pgoff, flags);
30736 + pgoff, flags, offset);
30737 }
30738
30739 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30740 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30741 index 04664cd..dae6e5d 100644
30742 --- a/arch/x86/mm/init.c
30743 +++ b/arch/x86/mm/init.c
30744 @@ -4,6 +4,7 @@
30745 #include <linux/swap.h>
30746 #include <linux/memblock.h>
30747 #include <linux/bootmem.h> /* for max_low_pfn */
30748 +#include <linux/tboot.h>
30749
30750 #include <asm/cacheflush.h>
30751 #include <asm/e820.h>
30752 @@ -17,6 +18,8 @@
30753 #include <asm/proto.h>
30754 #include <asm/dma.h> /* for MAX_DMA_PFN */
30755 #include <asm/microcode.h>
30756 +#include <asm/desc.h>
30757 +#include <asm/bios_ebda.h>
30758
30759 #include "mm_internal.h"
30760
30761 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30762 early_ioremap_page_table_range_init();
30763 #endif
30764
30765 +#ifdef CONFIG_PAX_PER_CPU_PGD
30766 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30767 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30768 + KERNEL_PGD_PTRS);
30769 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30770 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30771 + KERNEL_PGD_PTRS);
30772 + load_cr3(get_cpu_pgd(0, kernel));
30773 +#else
30774 load_cr3(swapper_pg_dir);
30775 +#endif
30776 +
30777 __flush_tlb_all();
30778
30779 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30780 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30781 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30782 * mmio resources as well as potential bios/acpi data regions.
30783 */
30784 +
30785 +#ifdef CONFIG_GRKERNSEC_KMEM
30786 +static unsigned int ebda_start __read_only;
30787 +static unsigned int ebda_end __read_only;
30788 +#endif
30789 +
30790 int devmem_is_allowed(unsigned long pagenr)
30791 {
30792 - if (pagenr < 256)
30793 +#ifdef CONFIG_GRKERNSEC_KMEM
30794 + /* allow BDA */
30795 + if (!pagenr)
30796 return 1;
30797 + /* allow EBDA */
30798 + if (pagenr >= ebda_start && pagenr < ebda_end)
30799 + return 1;
30800 + /* if tboot is in use, allow access to its hardcoded serial log range */
30801 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30802 + return 1;
30803 +#else
30804 + if (!pagenr)
30805 + return 1;
30806 +#ifdef CONFIG_VM86
30807 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30808 + return 1;
30809 +#endif
30810 +#endif
30811 +
30812 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30813 + return 1;
30814 +#ifdef CONFIG_GRKERNSEC_KMEM
30815 + /* throw out everything else below 1MB */
30816 + if (pagenr <= 256)
30817 + return 0;
30818 +#endif
30819 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30820 return 0;
30821 if (!page_is_ram(pagenr))
30822 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30823 #endif
30824 }
30825
30826 +#ifdef CONFIG_GRKERNSEC_KMEM
30827 +static inline void gr_init_ebda(void)
30828 +{
30829 + unsigned int ebda_addr;
30830 + unsigned int ebda_size = 0;
30831 +
30832 + ebda_addr = get_bios_ebda();
30833 + if (ebda_addr) {
30834 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30835 + ebda_size <<= 10;
30836 + }
30837 + if (ebda_addr && ebda_size) {
30838 + ebda_start = ebda_addr >> PAGE_SHIFT;
30839 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30840 + } else {
30841 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30842 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30843 + }
30844 +}
30845 +#else
30846 +static inline void gr_init_ebda(void) { }
30847 +#endif
30848 +
30849 void free_initmem(void)
30850 {
30851 +#ifdef CONFIG_PAX_KERNEXEC
30852 +#ifdef CONFIG_X86_32
30853 + /* PaX: limit KERNEL_CS to actual size */
30854 + unsigned long addr, limit;
30855 + struct desc_struct d;
30856 + int cpu;
30857 +#else
30858 + pgd_t *pgd;
30859 + pud_t *pud;
30860 + pmd_t *pmd;
30861 + unsigned long addr, end;
30862 +#endif
30863 +#endif
30864 +
30865 + gr_init_ebda();
30866 +
30867 +#ifdef CONFIG_PAX_KERNEXEC
30868 +#ifdef CONFIG_X86_32
30869 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30870 + limit = (limit - 1UL) >> PAGE_SHIFT;
30871 +
30872 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30873 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30874 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30875 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30876 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30877 + }
30878 +
30879 + /* PaX: make KERNEL_CS read-only */
30880 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30881 + if (!paravirt_enabled())
30882 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30883 +/*
30884 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30885 + pgd = pgd_offset_k(addr);
30886 + pud = pud_offset(pgd, addr);
30887 + pmd = pmd_offset(pud, addr);
30888 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30889 + }
30890 +*/
30891 +#ifdef CONFIG_X86_PAE
30892 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30893 +/*
30894 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30895 + pgd = pgd_offset_k(addr);
30896 + pud = pud_offset(pgd, addr);
30897 + pmd = pmd_offset(pud, addr);
30898 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30899 + }
30900 +*/
30901 +#endif
30902 +
30903 +#ifdef CONFIG_MODULES
30904 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30905 +#endif
30906 +
30907 +#else
30908 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30909 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30910 + pgd = pgd_offset_k(addr);
30911 + pud = pud_offset(pgd, addr);
30912 + pmd = pmd_offset(pud, addr);
30913 + if (!pmd_present(*pmd))
30914 + continue;
30915 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30916 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30917 + else
30918 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30919 + }
30920 +
30921 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30922 + end = addr + KERNEL_IMAGE_SIZE;
30923 + for (; addr < end; addr += PMD_SIZE) {
30924 + pgd = pgd_offset_k(addr);
30925 + pud = pud_offset(pgd, addr);
30926 + pmd = pmd_offset(pud, addr);
30927 + if (!pmd_present(*pmd))
30928 + continue;
30929 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30930 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30931 + }
30932 +#endif
30933 +
30934 + flush_tlb_all();
30935 +#endif
30936 +
30937 free_init_pages("unused kernel",
30938 (unsigned long)(&__init_begin),
30939 (unsigned long)(&__init_end));
30940 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30941 index 4287f1f..3b99c71 100644
30942 --- a/arch/x86/mm/init_32.c
30943 +++ b/arch/x86/mm/init_32.c
30944 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30945 bool __read_mostly __vmalloc_start_set = false;
30946
30947 /*
30948 - * Creates a middle page table and puts a pointer to it in the
30949 - * given global directory entry. This only returns the gd entry
30950 - * in non-PAE compilation mode, since the middle layer is folded.
30951 - */
30952 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30953 -{
30954 - pud_t *pud;
30955 - pmd_t *pmd_table;
30956 -
30957 -#ifdef CONFIG_X86_PAE
30958 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30959 - pmd_table = (pmd_t *)alloc_low_page();
30960 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30961 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30962 - pud = pud_offset(pgd, 0);
30963 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30964 -
30965 - return pmd_table;
30966 - }
30967 -#endif
30968 - pud = pud_offset(pgd, 0);
30969 - pmd_table = pmd_offset(pud, 0);
30970 -
30971 - return pmd_table;
30972 -}
30973 -
30974 -/*
30975 * Create a page table and place a pointer to it in a middle page
30976 * directory entry:
30977 */
30978 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30979 pte_t *page_table = (pte_t *)alloc_low_page();
30980
30981 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30982 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30983 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30984 +#else
30985 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30986 +#endif
30987 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30988 }
30989
30990 return pte_offset_kernel(pmd, 0);
30991 }
30992
30993 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30994 +{
30995 + pud_t *pud;
30996 + pmd_t *pmd_table;
30997 +
30998 + pud = pud_offset(pgd, 0);
30999 + pmd_table = pmd_offset(pud, 0);
31000 +
31001 + return pmd_table;
31002 +}
31003 +
31004 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31005 {
31006 int pgd_idx = pgd_index(vaddr);
31007 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31008 int pgd_idx, pmd_idx;
31009 unsigned long vaddr;
31010 pgd_t *pgd;
31011 + pud_t *pud;
31012 pmd_t *pmd;
31013 pte_t *pte = NULL;
31014 unsigned long count = page_table_range_init_count(start, end);
31015 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31016 pgd = pgd_base + pgd_idx;
31017
31018 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31019 - pmd = one_md_table_init(pgd);
31020 - pmd = pmd + pmd_index(vaddr);
31021 + pud = pud_offset(pgd, vaddr);
31022 + pmd = pmd_offset(pud, vaddr);
31023 +
31024 +#ifdef CONFIG_X86_PAE
31025 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31026 +#endif
31027 +
31028 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31029 pmd++, pmd_idx++) {
31030 pte = page_table_kmap_check(one_page_table_init(pmd),
31031 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31032 }
31033 }
31034
31035 -static inline int is_kernel_text(unsigned long addr)
31036 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31037 {
31038 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31039 - return 1;
31040 - return 0;
31041 + if ((start > ktla_ktva((unsigned long)_etext) ||
31042 + end <= ktla_ktva((unsigned long)_stext)) &&
31043 + (start > ktla_ktva((unsigned long)_einittext) ||
31044 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31045 +
31046 +#ifdef CONFIG_ACPI_SLEEP
31047 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31048 +#endif
31049 +
31050 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31051 + return 0;
31052 + return 1;
31053 }
31054
31055 /*
31056 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31057 unsigned long last_map_addr = end;
31058 unsigned long start_pfn, end_pfn;
31059 pgd_t *pgd_base = swapper_pg_dir;
31060 - int pgd_idx, pmd_idx, pte_ofs;
31061 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31062 unsigned long pfn;
31063 pgd_t *pgd;
31064 + pud_t *pud;
31065 pmd_t *pmd;
31066 pte_t *pte;
31067 unsigned pages_2m, pages_4k;
31068 @@ -291,8 +295,13 @@ repeat:
31069 pfn = start_pfn;
31070 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31071 pgd = pgd_base + pgd_idx;
31072 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31073 - pmd = one_md_table_init(pgd);
31074 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31075 + pud = pud_offset(pgd, 0);
31076 + pmd = pmd_offset(pud, 0);
31077 +
31078 +#ifdef CONFIG_X86_PAE
31079 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31080 +#endif
31081
31082 if (pfn >= end_pfn)
31083 continue;
31084 @@ -304,14 +313,13 @@ repeat:
31085 #endif
31086 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31087 pmd++, pmd_idx++) {
31088 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31089 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31090
31091 /*
31092 * Map with big pages if possible, otherwise
31093 * create normal page tables:
31094 */
31095 if (use_pse) {
31096 - unsigned int addr2;
31097 pgprot_t prot = PAGE_KERNEL_LARGE;
31098 /*
31099 * first pass will use the same initial
31100 @@ -322,11 +330,7 @@ repeat:
31101 _PAGE_PSE);
31102
31103 pfn &= PMD_MASK >> PAGE_SHIFT;
31104 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31105 - PAGE_OFFSET + PAGE_SIZE-1;
31106 -
31107 - if (is_kernel_text(addr) ||
31108 - is_kernel_text(addr2))
31109 + if (is_kernel_text(address, address + PMD_SIZE))
31110 prot = PAGE_KERNEL_LARGE_EXEC;
31111
31112 pages_2m++;
31113 @@ -343,7 +347,7 @@ repeat:
31114 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31115 pte += pte_ofs;
31116 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31117 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31118 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31119 pgprot_t prot = PAGE_KERNEL;
31120 /*
31121 * first pass will use the same initial
31122 @@ -351,7 +355,7 @@ repeat:
31123 */
31124 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31125
31126 - if (is_kernel_text(addr))
31127 + if (is_kernel_text(address, address + PAGE_SIZE))
31128 prot = PAGE_KERNEL_EXEC;
31129
31130 pages_4k++;
31131 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31132
31133 pud = pud_offset(pgd, va);
31134 pmd = pmd_offset(pud, va);
31135 - if (!pmd_present(*pmd))
31136 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31137 break;
31138
31139 /* should not be large page here */
31140 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31141
31142 static void __init pagetable_init(void)
31143 {
31144 - pgd_t *pgd_base = swapper_pg_dir;
31145 -
31146 - permanent_kmaps_init(pgd_base);
31147 + permanent_kmaps_init(swapper_pg_dir);
31148 }
31149
31150 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31151 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31152 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31153
31154 /* user-defined highmem size */
31155 @@ -787,10 +789,10 @@ void __init mem_init(void)
31156 ((unsigned long)&__init_end -
31157 (unsigned long)&__init_begin) >> 10,
31158
31159 - (unsigned long)&_etext, (unsigned long)&_edata,
31160 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31161 + (unsigned long)&_sdata, (unsigned long)&_edata,
31162 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31163
31164 - (unsigned long)&_text, (unsigned long)&_etext,
31165 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31166 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31167
31168 /*
31169 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31170 if (!kernel_set_to_readonly)
31171 return;
31172
31173 + start = ktla_ktva(start);
31174 pr_debug("Set kernel text: %lx - %lx for read write\n",
31175 start, start+size);
31176
31177 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31178 if (!kernel_set_to_readonly)
31179 return;
31180
31181 + start = ktla_ktva(start);
31182 pr_debug("Set kernel text: %lx - %lx for read only\n",
31183 start, start+size);
31184
31185 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31186 unsigned long start = PFN_ALIGN(_text);
31187 unsigned long size = PFN_ALIGN(_etext) - start;
31188
31189 + start = ktla_ktva(start);
31190 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31191 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31192 size >> 10);
31193 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31194 index 104d56a..62ba13f1 100644
31195 --- a/arch/x86/mm/init_64.c
31196 +++ b/arch/x86/mm/init_64.c
31197 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31198 * around without checking the pgd every time.
31199 */
31200
31201 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31202 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31203 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31204
31205 int force_personality32;
31206 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31207
31208 for (address = start; address <= end; address += PGDIR_SIZE) {
31209 const pgd_t *pgd_ref = pgd_offset_k(address);
31210 +
31211 +#ifdef CONFIG_PAX_PER_CPU_PGD
31212 + unsigned long cpu;
31213 +#else
31214 struct page *page;
31215 +#endif
31216
31217 if (pgd_none(*pgd_ref))
31218 continue;
31219
31220 spin_lock(&pgd_lock);
31221 +
31222 +#ifdef CONFIG_PAX_PER_CPU_PGD
31223 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31224 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31225 +
31226 + if (pgd_none(*pgd))
31227 + set_pgd(pgd, *pgd_ref);
31228 + else
31229 + BUG_ON(pgd_page_vaddr(*pgd)
31230 + != pgd_page_vaddr(*pgd_ref));
31231 + pgd = pgd_offset_cpu(cpu, kernel, address);
31232 +#else
31233 list_for_each_entry(page, &pgd_list, lru) {
31234 pgd_t *pgd;
31235 spinlock_t *pgt_lock;
31236 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31237 /* the pgt_lock only for Xen */
31238 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31239 spin_lock(pgt_lock);
31240 +#endif
31241
31242 if (pgd_none(*pgd))
31243 set_pgd(pgd, *pgd_ref);
31244 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31245 BUG_ON(pgd_page_vaddr(*pgd)
31246 != pgd_page_vaddr(*pgd_ref));
31247
31248 +#ifndef CONFIG_PAX_PER_CPU_PGD
31249 spin_unlock(pgt_lock);
31250 +#endif
31251 +
31252 }
31253 spin_unlock(&pgd_lock);
31254 }
31255 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31256 {
31257 if (pgd_none(*pgd)) {
31258 pud_t *pud = (pud_t *)spp_getpage();
31259 - pgd_populate(&init_mm, pgd, pud);
31260 + pgd_populate_kernel(&init_mm, pgd, pud);
31261 if (pud != pud_offset(pgd, 0))
31262 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31263 pud, pud_offset(pgd, 0));
31264 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31265 {
31266 if (pud_none(*pud)) {
31267 pmd_t *pmd = (pmd_t *) spp_getpage();
31268 - pud_populate(&init_mm, pud, pmd);
31269 + pud_populate_kernel(&init_mm, pud, pmd);
31270 if (pmd != pmd_offset(pud, 0))
31271 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31272 pmd, pmd_offset(pud, 0));
31273 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31274 pmd = fill_pmd(pud, vaddr);
31275 pte = fill_pte(pmd, vaddr);
31276
31277 + pax_open_kernel();
31278 set_pte(pte, new_pte);
31279 + pax_close_kernel();
31280
31281 /*
31282 * It's enough to flush this one mapping.
31283 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31284 pgd = pgd_offset_k((unsigned long)__va(phys));
31285 if (pgd_none(*pgd)) {
31286 pud = (pud_t *) spp_getpage();
31287 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31288 - _PAGE_USER));
31289 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31290 }
31291 pud = pud_offset(pgd, (unsigned long)__va(phys));
31292 if (pud_none(*pud)) {
31293 pmd = (pmd_t *) spp_getpage();
31294 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31295 - _PAGE_USER));
31296 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31297 }
31298 pmd = pmd_offset(pud, phys);
31299 BUG_ON(!pmd_none(*pmd));
31300 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31301 prot);
31302
31303 spin_lock(&init_mm.page_table_lock);
31304 - pud_populate(&init_mm, pud, pmd);
31305 + pud_populate_kernel(&init_mm, pud, pmd);
31306 spin_unlock(&init_mm.page_table_lock);
31307 }
31308 __flush_tlb_all();
31309 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31310 page_size_mask);
31311
31312 spin_lock(&init_mm.page_table_lock);
31313 - pgd_populate(&init_mm, pgd, pud);
31314 + pgd_populate_kernel(&init_mm, pgd, pud);
31315 spin_unlock(&init_mm.page_table_lock);
31316 pgd_changed = true;
31317 }
31318 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31319 static struct vm_area_struct gate_vma = {
31320 .vm_start = VSYSCALL_START,
31321 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31322 - .vm_page_prot = PAGE_READONLY_EXEC,
31323 - .vm_flags = VM_READ | VM_EXEC
31324 + .vm_page_prot = PAGE_READONLY,
31325 + .vm_flags = VM_READ
31326 };
31327
31328 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31329 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31330
31331 const char *arch_vma_name(struct vm_area_struct *vma)
31332 {
31333 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31334 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31335 return "[vdso]";
31336 if (vma == &gate_vma)
31337 return "[vsyscall]";
31338 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31339 index 7b179b4..6bd17777 100644
31340 --- a/arch/x86/mm/iomap_32.c
31341 +++ b/arch/x86/mm/iomap_32.c
31342 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31343 type = kmap_atomic_idx_push();
31344 idx = type + KM_TYPE_NR * smp_processor_id();
31345 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31346 +
31347 + pax_open_kernel();
31348 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31349 + pax_close_kernel();
31350 +
31351 arch_flush_lazy_mmu_mode();
31352
31353 return (void *)vaddr;
31354 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31355 index 799580c..72f9fe0 100644
31356 --- a/arch/x86/mm/ioremap.c
31357 +++ b/arch/x86/mm/ioremap.c
31358 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31359 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31360 int is_ram = page_is_ram(pfn);
31361
31362 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31363 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31364 return NULL;
31365 WARN_ON_ONCE(is_ram);
31366 }
31367 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31368 *
31369 * Caller must ensure there is only one unmapping for the same pointer.
31370 */
31371 -void iounmap(volatile void __iomem *addr)
31372 +void iounmap(const volatile void __iomem *addr)
31373 {
31374 struct vm_struct *p, *o;
31375
31376 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31377
31378 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31379 if (page_is_ram(start >> PAGE_SHIFT))
31380 +#ifdef CONFIG_HIGHMEM
31381 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31382 +#endif
31383 return __va(phys);
31384
31385 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31386 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31387 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31388 {
31389 if (page_is_ram(phys >> PAGE_SHIFT))
31390 +#ifdef CONFIG_HIGHMEM
31391 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31392 +#endif
31393 return;
31394
31395 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31396 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31397 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31398
31399 static __initdata int after_paging_init;
31400 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31401 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31402
31403 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31404 {
31405 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31406 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31407
31408 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31409 - memset(bm_pte, 0, sizeof(bm_pte));
31410 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31411 + pmd_populate_user(&init_mm, pmd, bm_pte);
31412
31413 /*
31414 * The boot-ioremap range spans multiple pmds, for which
31415 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31416 index d87dd6d..bf3fa66 100644
31417 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31418 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31419 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31420 * memory (e.g. tracked pages)? For now, we need this to avoid
31421 * invoking kmemcheck for PnP BIOS calls.
31422 */
31423 - if (regs->flags & X86_VM_MASK)
31424 + if (v8086_mode(regs))
31425 return false;
31426 - if (regs->cs != __KERNEL_CS)
31427 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31428 return false;
31429
31430 pte = kmemcheck_pte_lookup(address);
31431 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31432 index 25e7e13..1964579 100644
31433 --- a/arch/x86/mm/mmap.c
31434 +++ b/arch/x86/mm/mmap.c
31435 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31436 * Leave an at least ~128 MB hole with possible stack randomization.
31437 */
31438 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31439 -#define MAX_GAP (TASK_SIZE/6*5)
31440 +#define MAX_GAP (pax_task_size/6*5)
31441
31442 static int mmap_is_legacy(void)
31443 {
31444 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31445 return rnd << PAGE_SHIFT;
31446 }
31447
31448 -static unsigned long mmap_base(void)
31449 +static unsigned long mmap_base(struct mm_struct *mm)
31450 {
31451 unsigned long gap = rlimit(RLIMIT_STACK);
31452 + unsigned long pax_task_size = TASK_SIZE;
31453 +
31454 +#ifdef CONFIG_PAX_SEGMEXEC
31455 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31456 + pax_task_size = SEGMEXEC_TASK_SIZE;
31457 +#endif
31458
31459 if (gap < MIN_GAP)
31460 gap = MIN_GAP;
31461 else if (gap > MAX_GAP)
31462 gap = MAX_GAP;
31463
31464 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31465 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31466 }
31467
31468 /*
31469 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31470 * does, but not when emulating X86_32
31471 */
31472 -static unsigned long mmap_legacy_base(void)
31473 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31474 {
31475 - if (mmap_is_ia32())
31476 + if (mmap_is_ia32()) {
31477 +
31478 +#ifdef CONFIG_PAX_SEGMEXEC
31479 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31480 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31481 + else
31482 +#endif
31483 +
31484 return TASK_UNMAPPED_BASE;
31485 - else
31486 + } else
31487 return TASK_UNMAPPED_BASE + mmap_rnd();
31488 }
31489
31490 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31491 */
31492 void arch_pick_mmap_layout(struct mm_struct *mm)
31493 {
31494 - mm->mmap_legacy_base = mmap_legacy_base();
31495 - mm->mmap_base = mmap_base();
31496 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31497 + mm->mmap_base = mmap_base(mm);
31498 +
31499 +#ifdef CONFIG_PAX_RANDMMAP
31500 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31501 + mm->mmap_legacy_base += mm->delta_mmap;
31502 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31503 + }
31504 +#endif
31505
31506 if (mmap_is_legacy()) {
31507 mm->mmap_base = mm->mmap_legacy_base;
31508 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31509 index 0057a7a..95c7edd 100644
31510 --- a/arch/x86/mm/mmio-mod.c
31511 +++ b/arch/x86/mm/mmio-mod.c
31512 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31513 break;
31514 default:
31515 {
31516 - unsigned char *ip = (unsigned char *)instptr;
31517 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31518 my_trace->opcode = MMIO_UNKNOWN_OP;
31519 my_trace->width = 0;
31520 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31521 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31522 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31523 void __iomem *addr)
31524 {
31525 - static atomic_t next_id;
31526 + static atomic_unchecked_t next_id;
31527 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31528 /* These are page-unaligned. */
31529 struct mmiotrace_map map = {
31530 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31531 .private = trace
31532 },
31533 .phys = offset,
31534 - .id = atomic_inc_return(&next_id)
31535 + .id = atomic_inc_return_unchecked(&next_id)
31536 };
31537 map.map_id = trace->id;
31538
31539 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31540 ioremap_trace_core(offset, size, addr);
31541 }
31542
31543 -static void iounmap_trace_core(volatile void __iomem *addr)
31544 +static void iounmap_trace_core(const volatile void __iomem *addr)
31545 {
31546 struct mmiotrace_map map = {
31547 .phys = 0,
31548 @@ -328,7 +328,7 @@ not_enabled:
31549 }
31550 }
31551
31552 -void mmiotrace_iounmap(volatile void __iomem *addr)
31553 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31554 {
31555 might_sleep();
31556 if (is_enabled()) /* recheck and proper locking in *_core() */
31557 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31558 index 8bf93ba..dbcd670 100644
31559 --- a/arch/x86/mm/numa.c
31560 +++ b/arch/x86/mm/numa.c
31561 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31562 return true;
31563 }
31564
31565 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31566 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31567 {
31568 unsigned long uninitialized_var(pfn_align);
31569 int i, nid;
31570 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31571 index d0b1773..4c3327c 100644
31572 --- a/arch/x86/mm/pageattr-test.c
31573 +++ b/arch/x86/mm/pageattr-test.c
31574 @@ -36,7 +36,7 @@ enum {
31575
31576 static int pte_testbit(pte_t pte)
31577 {
31578 - return pte_flags(pte) & _PAGE_UNUSED1;
31579 + return pte_flags(pte) & _PAGE_CPA_TEST;
31580 }
31581
31582 struct split_state {
31583 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31584 index bb32480..75f2f5e 100644
31585 --- a/arch/x86/mm/pageattr.c
31586 +++ b/arch/x86/mm/pageattr.c
31587 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31588 */
31589 #ifdef CONFIG_PCI_BIOS
31590 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31591 - pgprot_val(forbidden) |= _PAGE_NX;
31592 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31593 #endif
31594
31595 /*
31596 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31597 * Does not cover __inittext since that is gone later on. On
31598 * 64bit we do not enforce !NX on the low mapping
31599 */
31600 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31601 - pgprot_val(forbidden) |= _PAGE_NX;
31602 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31603 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31604
31605 +#ifdef CONFIG_DEBUG_RODATA
31606 /*
31607 * The .rodata section needs to be read-only. Using the pfn
31608 * catches all aliases.
31609 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31610 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31611 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31612 pgprot_val(forbidden) |= _PAGE_RW;
31613 +#endif
31614
31615 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31616 /*
31617 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31618 }
31619 #endif
31620
31621 +#ifdef CONFIG_PAX_KERNEXEC
31622 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31623 + pgprot_val(forbidden) |= _PAGE_RW;
31624 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31625 + }
31626 +#endif
31627 +
31628 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31629
31630 return prot;
31631 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31632 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31633 {
31634 /* change init_mm */
31635 + pax_open_kernel();
31636 set_pte_atomic(kpte, pte);
31637 +
31638 #ifdef CONFIG_X86_32
31639 if (!SHARED_KERNEL_PMD) {
31640 +
31641 +#ifdef CONFIG_PAX_PER_CPU_PGD
31642 + unsigned long cpu;
31643 +#else
31644 struct page *page;
31645 +#endif
31646
31647 +#ifdef CONFIG_PAX_PER_CPU_PGD
31648 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31649 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31650 +#else
31651 list_for_each_entry(page, &pgd_list, lru) {
31652 - pgd_t *pgd;
31653 + pgd_t *pgd = (pgd_t *)page_address(page);
31654 +#endif
31655 +
31656 pud_t *pud;
31657 pmd_t *pmd;
31658
31659 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31660 + pgd += pgd_index(address);
31661 pud = pud_offset(pgd, address);
31662 pmd = pmd_offset(pud, address);
31663 set_pte_atomic((pte_t *)pmd, pte);
31664 }
31665 }
31666 #endif
31667 + pax_close_kernel();
31668 }
31669
31670 static int
31671 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31672 index 6574388..87e9bef 100644
31673 --- a/arch/x86/mm/pat.c
31674 +++ b/arch/x86/mm/pat.c
31675 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31676
31677 if (!entry) {
31678 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31679 - current->comm, current->pid, start, end - 1);
31680 + current->comm, task_pid_nr(current), start, end - 1);
31681 return -EINVAL;
31682 }
31683
31684 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31685
31686 while (cursor < to) {
31687 if (!devmem_is_allowed(pfn)) {
31688 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31689 - current->comm, from, to - 1);
31690 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31691 + current->comm, from, to - 1, cursor);
31692 return 0;
31693 }
31694 cursor += PAGE_SIZE;
31695 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31696 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31697 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31698 "for [mem %#010Lx-%#010Lx]\n",
31699 - current->comm, current->pid,
31700 + current->comm, task_pid_nr(current),
31701 cattr_name(flags),
31702 base, (unsigned long long)(base + size-1));
31703 return -EINVAL;
31704 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31705 flags = lookup_memtype(paddr);
31706 if (want_flags != flags) {
31707 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31708 - current->comm, current->pid,
31709 + current->comm, task_pid_nr(current),
31710 cattr_name(want_flags),
31711 (unsigned long long)paddr,
31712 (unsigned long long)(paddr + size - 1),
31713 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31714 free_memtype(paddr, paddr + size);
31715 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31716 " for [mem %#010Lx-%#010Lx], got %s\n",
31717 - current->comm, current->pid,
31718 + current->comm, task_pid_nr(current),
31719 cattr_name(want_flags),
31720 (unsigned long long)paddr,
31721 (unsigned long long)(paddr + size - 1),
31722 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31723 index 415f6c4..d319983 100644
31724 --- a/arch/x86/mm/pat_rbtree.c
31725 +++ b/arch/x86/mm/pat_rbtree.c
31726 @@ -160,7 +160,7 @@ success:
31727
31728 failure:
31729 printk(KERN_INFO "%s:%d conflicting memory types "
31730 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31731 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31732 end, cattr_name(found_type), cattr_name(match->type));
31733 return -EBUSY;
31734 }
31735 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31736 index 9f0614d..92ae64a 100644
31737 --- a/arch/x86/mm/pf_in.c
31738 +++ b/arch/x86/mm/pf_in.c
31739 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31740 int i;
31741 enum reason_type rv = OTHERS;
31742
31743 - p = (unsigned char *)ins_addr;
31744 + p = (unsigned char *)ktla_ktva(ins_addr);
31745 p += skip_prefix(p, &prf);
31746 p += get_opcode(p, &opcode);
31747
31748 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31749 struct prefix_bits prf;
31750 int i;
31751
31752 - p = (unsigned char *)ins_addr;
31753 + p = (unsigned char *)ktla_ktva(ins_addr);
31754 p += skip_prefix(p, &prf);
31755 p += get_opcode(p, &opcode);
31756
31757 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31758 struct prefix_bits prf;
31759 int i;
31760
31761 - p = (unsigned char *)ins_addr;
31762 + p = (unsigned char *)ktla_ktva(ins_addr);
31763 p += skip_prefix(p, &prf);
31764 p += get_opcode(p, &opcode);
31765
31766 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31767 struct prefix_bits prf;
31768 int i;
31769
31770 - p = (unsigned char *)ins_addr;
31771 + p = (unsigned char *)ktla_ktva(ins_addr);
31772 p += skip_prefix(p, &prf);
31773 p += get_opcode(p, &opcode);
31774 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31775 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31776 struct prefix_bits prf;
31777 int i;
31778
31779 - p = (unsigned char *)ins_addr;
31780 + p = (unsigned char *)ktla_ktva(ins_addr);
31781 p += skip_prefix(p, &prf);
31782 p += get_opcode(p, &opcode);
31783 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31784 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31785 index dfa537a..fd45c64 100644
31786 --- a/arch/x86/mm/pgtable.c
31787 +++ b/arch/x86/mm/pgtable.c
31788 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31789 list_del(&page->lru);
31790 }
31791
31792 -#define UNSHARED_PTRS_PER_PGD \
31793 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31794 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31795 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31796
31797 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31798 +{
31799 + unsigned int count = USER_PGD_PTRS;
31800
31801 + if (!pax_user_shadow_base)
31802 + return;
31803 +
31804 + while (count--)
31805 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31806 +}
31807 +#endif
31808 +
31809 +#ifdef CONFIG_PAX_PER_CPU_PGD
31810 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31811 +{
31812 + unsigned int count = USER_PGD_PTRS;
31813 +
31814 + while (count--) {
31815 + pgd_t pgd;
31816 +
31817 +#ifdef CONFIG_X86_64
31818 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31819 +#else
31820 + pgd = *src++;
31821 +#endif
31822 +
31823 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31824 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31825 +#endif
31826 +
31827 + *dst++ = pgd;
31828 + }
31829 +
31830 +}
31831 +#endif
31832 +
31833 +#ifdef CONFIG_X86_64
31834 +#define pxd_t pud_t
31835 +#define pyd_t pgd_t
31836 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31837 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31838 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31839 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31840 +#define PYD_SIZE PGDIR_SIZE
31841 +#else
31842 +#define pxd_t pmd_t
31843 +#define pyd_t pud_t
31844 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31845 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31846 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31847 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31848 +#define PYD_SIZE PUD_SIZE
31849 +#endif
31850 +
31851 +#ifdef CONFIG_PAX_PER_CPU_PGD
31852 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31853 +static inline void pgd_dtor(pgd_t *pgd) {}
31854 +#else
31855 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31856 {
31857 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31858 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31859 pgd_list_del(pgd);
31860 spin_unlock(&pgd_lock);
31861 }
31862 +#endif
31863
31864 /*
31865 * List of all pgd's needed for non-PAE so it can invalidate entries
31866 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31867 * -- nyc
31868 */
31869
31870 -#ifdef CONFIG_X86_PAE
31871 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31872 /*
31873 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31874 * updating the top-level pagetable entries to guarantee the
31875 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31876 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31877 * and initialize the kernel pmds here.
31878 */
31879 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31880 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31881
31882 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31883 {
31884 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31885 */
31886 flush_tlb_mm(mm);
31887 }
31888 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31889 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31890 #else /* !CONFIG_X86_PAE */
31891
31892 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31893 -#define PREALLOCATED_PMDS 0
31894 +#define PREALLOCATED_PXDS 0
31895
31896 #endif /* CONFIG_X86_PAE */
31897
31898 -static void free_pmds(pmd_t *pmds[])
31899 +static void free_pxds(pxd_t *pxds[])
31900 {
31901 int i;
31902
31903 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31904 - if (pmds[i])
31905 - free_page((unsigned long)pmds[i]);
31906 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31907 + if (pxds[i])
31908 + free_page((unsigned long)pxds[i]);
31909 }
31910
31911 -static int preallocate_pmds(pmd_t *pmds[])
31912 +static int preallocate_pxds(pxd_t *pxds[])
31913 {
31914 int i;
31915 bool failed = false;
31916
31917 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31918 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31919 - if (pmd == NULL)
31920 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31921 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31922 + if (pxd == NULL)
31923 failed = true;
31924 - pmds[i] = pmd;
31925 + pxds[i] = pxd;
31926 }
31927
31928 if (failed) {
31929 - free_pmds(pmds);
31930 + free_pxds(pxds);
31931 return -ENOMEM;
31932 }
31933
31934 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31935 * preallocate which never got a corresponding vma will need to be
31936 * freed manually.
31937 */
31938 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31939 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31940 {
31941 int i;
31942
31943 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31944 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31945 pgd_t pgd = pgdp[i];
31946
31947 if (pgd_val(pgd) != 0) {
31948 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31949 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31950
31951 - pgdp[i] = native_make_pgd(0);
31952 + set_pgd(pgdp + i, native_make_pgd(0));
31953
31954 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31955 - pmd_free(mm, pmd);
31956 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31957 + pxd_free(mm, pxd);
31958 }
31959 }
31960 }
31961
31962 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31963 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31964 {
31965 - pud_t *pud;
31966 + pyd_t *pyd;
31967 int i;
31968
31969 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31970 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31971 return;
31972
31973 - pud = pud_offset(pgd, 0);
31974 -
31975 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31976 - pmd_t *pmd = pmds[i];
31977 +#ifdef CONFIG_X86_64
31978 + pyd = pyd_offset(mm, 0L);
31979 +#else
31980 + pyd = pyd_offset(pgd, 0L);
31981 +#endif
31982
31983 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
31984 + pxd_t *pxd = pxds[i];
31985 if (i >= KERNEL_PGD_BOUNDARY)
31986 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31987 - sizeof(pmd_t) * PTRS_PER_PMD);
31988 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31989 + sizeof(pxd_t) * PTRS_PER_PMD);
31990
31991 - pud_populate(mm, pud, pmd);
31992 + pyd_populate(mm, pyd, pxd);
31993 }
31994 }
31995
31996 pgd_t *pgd_alloc(struct mm_struct *mm)
31997 {
31998 pgd_t *pgd;
31999 - pmd_t *pmds[PREALLOCATED_PMDS];
32000 + pxd_t *pxds[PREALLOCATED_PXDS];
32001
32002 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32003
32004 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32005
32006 mm->pgd = pgd;
32007
32008 - if (preallocate_pmds(pmds) != 0)
32009 + if (preallocate_pxds(pxds) != 0)
32010 goto out_free_pgd;
32011
32012 if (paravirt_pgd_alloc(mm) != 0)
32013 - goto out_free_pmds;
32014 + goto out_free_pxds;
32015
32016 /*
32017 * Make sure that pre-populating the pmds is atomic with
32018 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32019 spin_lock(&pgd_lock);
32020
32021 pgd_ctor(mm, pgd);
32022 - pgd_prepopulate_pmd(mm, pgd, pmds);
32023 + pgd_prepopulate_pxd(mm, pgd, pxds);
32024
32025 spin_unlock(&pgd_lock);
32026
32027 return pgd;
32028
32029 -out_free_pmds:
32030 - free_pmds(pmds);
32031 +out_free_pxds:
32032 + free_pxds(pxds);
32033 out_free_pgd:
32034 free_page((unsigned long)pgd);
32035 out:
32036 @@ -300,7 +363,7 @@ out:
32037
32038 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32039 {
32040 - pgd_mop_up_pmds(mm, pgd);
32041 + pgd_mop_up_pxds(mm, pgd);
32042 pgd_dtor(pgd);
32043 paravirt_pgd_free(mm, pgd);
32044 free_page((unsigned long)pgd);
32045 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32046 index a69bcb8..19068ab 100644
32047 --- a/arch/x86/mm/pgtable_32.c
32048 +++ b/arch/x86/mm/pgtable_32.c
32049 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32050 return;
32051 }
32052 pte = pte_offset_kernel(pmd, vaddr);
32053 +
32054 + pax_open_kernel();
32055 if (pte_val(pteval))
32056 set_pte_at(&init_mm, vaddr, pte, pteval);
32057 else
32058 pte_clear(&init_mm, vaddr, pte);
32059 + pax_close_kernel();
32060
32061 /*
32062 * It's enough to flush this one mapping.
32063 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32064 index e666cbb..61788c45 100644
32065 --- a/arch/x86/mm/physaddr.c
32066 +++ b/arch/x86/mm/physaddr.c
32067 @@ -10,7 +10,7 @@
32068 #ifdef CONFIG_X86_64
32069
32070 #ifdef CONFIG_DEBUG_VIRTUAL
32071 -unsigned long __phys_addr(unsigned long x)
32072 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32073 {
32074 unsigned long y = x - __START_KERNEL_map;
32075
32076 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32077 #else
32078
32079 #ifdef CONFIG_DEBUG_VIRTUAL
32080 -unsigned long __phys_addr(unsigned long x)
32081 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32082 {
32083 unsigned long phys_addr = x - PAGE_OFFSET;
32084 /* VMALLOC_* aren't constants */
32085 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32086 index 90555bf..f5f1828 100644
32087 --- a/arch/x86/mm/setup_nx.c
32088 +++ b/arch/x86/mm/setup_nx.c
32089 @@ -5,8 +5,10 @@
32090 #include <asm/pgtable.h>
32091 #include <asm/proto.h>
32092
32093 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32094 static int disable_nx;
32095
32096 +#ifndef CONFIG_PAX_PAGEEXEC
32097 /*
32098 * noexec = on|off
32099 *
32100 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32101 return 0;
32102 }
32103 early_param("noexec", noexec_setup);
32104 +#endif
32105 +
32106 +#endif
32107
32108 void x86_configure_nx(void)
32109 {
32110 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32111 if (cpu_has_nx && !disable_nx)
32112 __supported_pte_mask |= _PAGE_NX;
32113 else
32114 +#endif
32115 __supported_pte_mask &= ~_PAGE_NX;
32116 }
32117
32118 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32119 index ae699b3..f1b2ad2 100644
32120 --- a/arch/x86/mm/tlb.c
32121 +++ b/arch/x86/mm/tlb.c
32122 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32123 BUG();
32124 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32125 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32126 +
32127 +#ifndef CONFIG_PAX_PER_CPU_PGD
32128 load_cr3(swapper_pg_dir);
32129 +#endif
32130 +
32131 }
32132 }
32133 EXPORT_SYMBOL_GPL(leave_mm);
32134 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32135 new file mode 100644
32136 index 0000000..dace51c
32137 --- /dev/null
32138 +++ b/arch/x86/mm/uderef_64.c
32139 @@ -0,0 +1,37 @@
32140 +#include <linux/mm.h>
32141 +#include <asm/pgtable.h>
32142 +#include <asm/uaccess.h>
32143 +
32144 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32145 +/* PaX: due to the special call convention these functions must
32146 + * - remain leaf functions under all configurations,
32147 + * - never be called directly, only dereferenced from the wrappers.
32148 + */
32149 +void __pax_open_userland(void)
32150 +{
32151 + unsigned int cpu;
32152 +
32153 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32154 + return;
32155 +
32156 + cpu = raw_get_cpu();
32157 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32158 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32159 + raw_put_cpu_no_resched();
32160 +}
32161 +EXPORT_SYMBOL(__pax_open_userland);
32162 +
32163 +void __pax_close_userland(void)
32164 +{
32165 + unsigned int cpu;
32166 +
32167 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32168 + return;
32169 +
32170 + cpu = raw_get_cpu();
32171 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32172 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32173 + raw_put_cpu_no_resched();
32174 +}
32175 +EXPORT_SYMBOL(__pax_close_userland);
32176 +#endif
32177 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32178 index 877b9a1..a8ecf42 100644
32179 --- a/arch/x86/net/bpf_jit.S
32180 +++ b/arch/x86/net/bpf_jit.S
32181 @@ -9,6 +9,7 @@
32182 */
32183 #include <linux/linkage.h>
32184 #include <asm/dwarf2.h>
32185 +#include <asm/alternative-asm.h>
32186
32187 /*
32188 * Calling convention :
32189 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32190 jle bpf_slow_path_word
32191 mov (SKBDATA,%rsi),%eax
32192 bswap %eax /* ntohl() */
32193 + pax_force_retaddr
32194 ret
32195
32196 sk_load_half:
32197 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32198 jle bpf_slow_path_half
32199 movzwl (SKBDATA,%rsi),%eax
32200 rol $8,%ax # ntohs()
32201 + pax_force_retaddr
32202 ret
32203
32204 sk_load_byte:
32205 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32206 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32207 jle bpf_slow_path_byte
32208 movzbl (SKBDATA,%rsi),%eax
32209 + pax_force_retaddr
32210 ret
32211
32212 /**
32213 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32214 movzbl (SKBDATA,%rsi),%ebx
32215 and $15,%bl
32216 shl $2,%bl
32217 + pax_force_retaddr
32218 ret
32219
32220 /* rsi contains offset and can be scratched */
32221 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32222 js bpf_error
32223 mov -12(%rbp),%eax
32224 bswap %eax
32225 + pax_force_retaddr
32226 ret
32227
32228 bpf_slow_path_half:
32229 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32230 mov -12(%rbp),%ax
32231 rol $8,%ax
32232 movzwl %ax,%eax
32233 + pax_force_retaddr
32234 ret
32235
32236 bpf_slow_path_byte:
32237 bpf_slow_path_common(1)
32238 js bpf_error
32239 movzbl -12(%rbp),%eax
32240 + pax_force_retaddr
32241 ret
32242
32243 bpf_slow_path_byte_msh:
32244 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32245 and $15,%al
32246 shl $2,%al
32247 xchg %eax,%ebx
32248 + pax_force_retaddr
32249 ret
32250
32251 #define sk_negative_common(SIZE) \
32252 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32253 sk_negative_common(4)
32254 mov (%rax), %eax
32255 bswap %eax
32256 + pax_force_retaddr
32257 ret
32258
32259 bpf_slow_path_half_neg:
32260 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32261 mov (%rax),%ax
32262 rol $8,%ax
32263 movzwl %ax,%eax
32264 + pax_force_retaddr
32265 ret
32266
32267 bpf_slow_path_byte_neg:
32268 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32269 .globl sk_load_byte_negative_offset
32270 sk_negative_common(1)
32271 movzbl (%rax), %eax
32272 + pax_force_retaddr
32273 ret
32274
32275 bpf_slow_path_byte_msh_neg:
32276 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32277 and $15,%al
32278 shl $2,%al
32279 xchg %eax,%ebx
32280 + pax_force_retaddr
32281 ret
32282
32283 bpf_error:
32284 @@ -197,4 +210,5 @@ bpf_error:
32285 xor %eax,%eax
32286 mov -8(%rbp),%rbx
32287 leaveq
32288 + pax_force_retaddr
32289 ret
32290 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32291 index 516593e..29d3c55 100644
32292 --- a/arch/x86/net/bpf_jit_comp.c
32293 +++ b/arch/x86/net/bpf_jit_comp.c
32294 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32295 return ptr + len;
32296 }
32297
32298 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32299 +#define MAX_INSTR_CODE_SIZE 96
32300 +#else
32301 +#define MAX_INSTR_CODE_SIZE 64
32302 +#endif
32303 +
32304 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32305
32306 #define EMIT1(b1) EMIT(b1, 1)
32307 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32308 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32309 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32310 +
32311 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32312 +/* original constant will appear in ecx */
32313 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32314 +do { \
32315 + /* mov ecx, randkey */ \
32316 + EMIT1(0xb9); \
32317 + EMIT(_key, 4); \
32318 + /* xor ecx, randkey ^ off */ \
32319 + EMIT2(0x81, 0xf1); \
32320 + EMIT((_key) ^ (_off), 4); \
32321 +} while (0)
32322 +
32323 +#define EMIT1_off32(b1, _off) \
32324 +do { \
32325 + switch (b1) { \
32326 + case 0x05: /* add eax, imm32 */ \
32327 + case 0x2d: /* sub eax, imm32 */ \
32328 + case 0x25: /* and eax, imm32 */ \
32329 + case 0x0d: /* or eax, imm32 */ \
32330 + case 0xb8: /* mov eax, imm32 */ \
32331 + case 0x35: /* xor eax, imm32 */ \
32332 + case 0x3d: /* cmp eax, imm32 */ \
32333 + case 0xa9: /* test eax, imm32 */ \
32334 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32335 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32336 + break; \
32337 + case 0xbb: /* mov ebx, imm32 */ \
32338 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32339 + /* mov ebx, ecx */ \
32340 + EMIT2(0x89, 0xcb); \
32341 + break; \
32342 + case 0xbe: /* mov esi, imm32 */ \
32343 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32344 + /* mov esi, ecx */ \
32345 + EMIT2(0x89, 0xce); \
32346 + break; \
32347 + case 0xe8: /* call rel imm32, always to known funcs */ \
32348 + EMIT1(b1); \
32349 + EMIT(_off, 4); \
32350 + break; \
32351 + case 0xe9: /* jmp rel imm32 */ \
32352 + EMIT1(b1); \
32353 + EMIT(_off, 4); \
32354 + /* prevent fall-through, we're not called if off = 0 */ \
32355 + EMIT(0xcccccccc, 4); \
32356 + EMIT(0xcccccccc, 4); \
32357 + break; \
32358 + default: \
32359 + BUILD_BUG(); \
32360 + } \
32361 +} while (0)
32362 +
32363 +#define EMIT2_off32(b1, b2, _off) \
32364 +do { \
32365 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32366 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32367 + EMIT(randkey, 4); \
32368 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32369 + EMIT((_off) - randkey, 4); \
32370 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32371 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32372 + /* imul eax, ecx */ \
32373 + EMIT3(0x0f, 0xaf, 0xc1); \
32374 + } else { \
32375 + BUILD_BUG(); \
32376 + } \
32377 +} while (0)
32378 +#else
32379 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32380 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32381 +#endif
32382
32383 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32384 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32385 @@ -91,6 +168,24 @@ do { \
32386 #define X86_JBE 0x76
32387 #define X86_JA 0x77
32388
32389 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32390 +#define APPEND_FLOW_VERIFY() \
32391 +do { \
32392 + /* mov ecx, randkey */ \
32393 + EMIT1(0xb9); \
32394 + EMIT(randkey, 4); \
32395 + /* cmp ecx, randkey */ \
32396 + EMIT2(0x81, 0xf9); \
32397 + EMIT(randkey, 4); \
32398 + /* jz after 8 int 3s */ \
32399 + EMIT2(0x74, 0x08); \
32400 + EMIT(0xcccccccc, 4); \
32401 + EMIT(0xcccccccc, 4); \
32402 +} while (0)
32403 +#else
32404 +#define APPEND_FLOW_VERIFY() do { } while (0)
32405 +#endif
32406 +
32407 #define EMIT_COND_JMP(op, offset) \
32408 do { \
32409 if (is_near(offset)) \
32410 @@ -98,6 +193,7 @@ do { \
32411 else { \
32412 EMIT2(0x0f, op + 0x10); \
32413 EMIT(offset, 4); /* jxx .+off32 */ \
32414 + APPEND_FLOW_VERIFY(); \
32415 } \
32416 } while (0)
32417
32418 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32419 return -1;
32420 }
32421
32422 -struct bpf_binary_header {
32423 - unsigned int pages;
32424 - /* Note : for security reasons, bpf code will follow a randomly
32425 - * sized amount of int3 instructions
32426 - */
32427 - u8 image[];
32428 -};
32429 -
32430 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32431 +/* Note : for security reasons, bpf code will follow a randomly
32432 + * sized amount of int3 instructions
32433 + */
32434 +static u8 *bpf_alloc_binary(unsigned int proglen,
32435 u8 **image_ptr)
32436 {
32437 unsigned int sz, hole;
32438 - struct bpf_binary_header *header;
32439 + u8 *header;
32440
32441 /* Most of BPF filters are really small,
32442 * but if some of them fill a page, allow at least
32443 * 128 extra bytes to insert a random section of int3
32444 */
32445 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32446 - header = module_alloc(sz);
32447 + sz = round_up(proglen + 128, PAGE_SIZE);
32448 + header = module_alloc_exec(sz);
32449 if (!header)
32450 return NULL;
32451
32452 + pax_open_kernel();
32453 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32454 + pax_close_kernel();
32455
32456 - header->pages = sz / PAGE_SIZE;
32457 - hole = sz - (proglen + sizeof(*header));
32458 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32459
32460 /* insert a random number of int3 instructions before BPF code */
32461 - *image_ptr = &header->image[prandom_u32() % hole];
32462 + *image_ptr = &header[prandom_u32() % hole];
32463 return header;
32464 }
32465
32466 void bpf_jit_compile(struct sk_filter *fp)
32467 {
32468 - u8 temp[64];
32469 + u8 temp[MAX_INSTR_CODE_SIZE];
32470 u8 *prog;
32471 unsigned int proglen, oldproglen = 0;
32472 int ilen, i;
32473 int t_offset, f_offset;
32474 u8 t_op, f_op, seen = 0, pass;
32475 u8 *image = NULL;
32476 - struct bpf_binary_header *header = NULL;
32477 + u8 *header = NULL;
32478 u8 *func;
32479 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32480 unsigned int cleanup_addr; /* epilogue code offset */
32481 unsigned int *addrs;
32482 const struct sock_filter *filter = fp->insns;
32483 int flen = fp->len;
32484 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32485 + unsigned int randkey;
32486 +#endif
32487
32488 if (!bpf_jit_enable)
32489 return;
32490 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32491 if (addrs == NULL)
32492 return;
32493
32494 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32495 + randkey = get_random_int();
32496 +#endif
32497 +
32498 /* Before first pass, make a rough estimation of addrs[]
32499 - * each bpf instruction is translated to less than 64 bytes
32500 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32501 */
32502 for (proglen = 0, i = 0; i < flen; i++) {
32503 - proglen += 64;
32504 + proglen += MAX_INSTR_CODE_SIZE;
32505 addrs[i] = proglen;
32506 }
32507 cleanup_addr = proglen; /* epilogue address */
32508 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32509 case BPF_S_ALU_MUL_K: /* A *= K */
32510 if (is_imm8(K))
32511 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32512 - else {
32513 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32514 - EMIT(K, 4);
32515 - }
32516 + else
32517 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32518 break;
32519 case BPF_S_ALU_DIV_X: /* A /= X; */
32520 seen |= SEEN_XREG;
32521 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32522 break;
32523 case BPF_S_ALU_MOD_K: /* A %= K; */
32524 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32525 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32526 + DILUTE_CONST_SEQUENCE(K, randkey);
32527 +#else
32528 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32529 +#endif
32530 EMIT2(0xf7, 0xf1); /* div %ecx */
32531 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32532 break;
32533 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32534 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32535 + DILUTE_CONST_SEQUENCE(K, randkey);
32536 + // imul rax, rcx
32537 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32538 +#else
32539 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32540 EMIT(K, 4);
32541 +#endif
32542 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32543 break;
32544 case BPF_S_ALU_AND_X:
32545 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32546 if (is_imm8(K)) {
32547 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32548 } else {
32549 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32550 - EMIT(K, 4);
32551 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32552 }
32553 } else {
32554 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32555 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32556 if (unlikely(proglen + ilen > oldproglen)) {
32557 pr_err("bpb_jit_compile fatal error\n");
32558 kfree(addrs);
32559 - module_free(NULL, header);
32560 + module_free_exec(NULL, image);
32561 return;
32562 }
32563 + pax_open_kernel();
32564 memcpy(image + proglen, temp, ilen);
32565 + pax_close_kernel();
32566 }
32567 proglen += ilen;
32568 addrs[i] = proglen;
32569 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32570
32571 if (image) {
32572 bpf_flush_icache(header, image + proglen);
32573 - set_memory_ro((unsigned long)header, header->pages);
32574 fp->bpf_func = (void *)image;
32575 }
32576 out:
32577 @@ -776,10 +883,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
32578 {
32579 struct sk_filter *fp = container_of(work, struct sk_filter, work);
32580 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32581 - struct bpf_binary_header *header = (void *)addr;
32582
32583 - set_memory_rw(addr, header->pages);
32584 - module_free(NULL, header);
32585 + set_memory_rw(addr, 1);
32586 + module_free_exec(NULL, (void *)addr);
32587 kfree(fp);
32588 }
32589
32590 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32591 index d6aa6e8..266395a 100644
32592 --- a/arch/x86/oprofile/backtrace.c
32593 +++ b/arch/x86/oprofile/backtrace.c
32594 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32595 struct stack_frame_ia32 *fp;
32596 unsigned long bytes;
32597
32598 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32599 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32600 if (bytes != sizeof(bufhead))
32601 return NULL;
32602
32603 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32604 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32605
32606 oprofile_add_trace(bufhead[0].return_address);
32607
32608 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32609 struct stack_frame bufhead[2];
32610 unsigned long bytes;
32611
32612 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32613 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32614 if (bytes != sizeof(bufhead))
32615 return NULL;
32616
32617 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32618 {
32619 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32620
32621 - if (!user_mode_vm(regs)) {
32622 + if (!user_mode(regs)) {
32623 unsigned long stack = kernel_stack_pointer(regs);
32624 if (depth)
32625 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32626 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32627 index 6890d84..1dad1f1 100644
32628 --- a/arch/x86/oprofile/nmi_int.c
32629 +++ b/arch/x86/oprofile/nmi_int.c
32630 @@ -23,6 +23,7 @@
32631 #include <asm/nmi.h>
32632 #include <asm/msr.h>
32633 #include <asm/apic.h>
32634 +#include <asm/pgtable.h>
32635
32636 #include "op_counter.h"
32637 #include "op_x86_model.h"
32638 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32639 if (ret)
32640 return ret;
32641
32642 - if (!model->num_virt_counters)
32643 - model->num_virt_counters = model->num_counters;
32644 + if (!model->num_virt_counters) {
32645 + pax_open_kernel();
32646 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32647 + pax_close_kernel();
32648 + }
32649
32650 mux_init(ops);
32651
32652 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32653 index 50d86c0..7985318 100644
32654 --- a/arch/x86/oprofile/op_model_amd.c
32655 +++ b/arch/x86/oprofile/op_model_amd.c
32656 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32657 num_counters = AMD64_NUM_COUNTERS;
32658 }
32659
32660 - op_amd_spec.num_counters = num_counters;
32661 - op_amd_spec.num_controls = num_counters;
32662 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32663 + pax_open_kernel();
32664 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32665 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32666 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32667 + pax_close_kernel();
32668
32669 return 0;
32670 }
32671 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32672 index d90528e..0127e2b 100644
32673 --- a/arch/x86/oprofile/op_model_ppro.c
32674 +++ b/arch/x86/oprofile/op_model_ppro.c
32675 @@ -19,6 +19,7 @@
32676 #include <asm/msr.h>
32677 #include <asm/apic.h>
32678 #include <asm/nmi.h>
32679 +#include <asm/pgtable.h>
32680
32681 #include "op_x86_model.h"
32682 #include "op_counter.h"
32683 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32684
32685 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32686
32687 - op_arch_perfmon_spec.num_counters = num_counters;
32688 - op_arch_perfmon_spec.num_controls = num_counters;
32689 + pax_open_kernel();
32690 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32691 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32692 + pax_close_kernel();
32693 }
32694
32695 static int arch_perfmon_init(struct oprofile_operations *ignore)
32696 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32697 index 71e8a67..6a313bb 100644
32698 --- a/arch/x86/oprofile/op_x86_model.h
32699 +++ b/arch/x86/oprofile/op_x86_model.h
32700 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32701 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32702 struct op_msrs const * const msrs);
32703 #endif
32704 -};
32705 +} __do_const;
32706
32707 struct op_counter_config;
32708
32709 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32710 index 372e9b8..e775a6c 100644
32711 --- a/arch/x86/pci/irq.c
32712 +++ b/arch/x86/pci/irq.c
32713 @@ -50,7 +50,7 @@ struct irq_router {
32714 struct irq_router_handler {
32715 u16 vendor;
32716 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32717 -};
32718 +} __do_const;
32719
32720 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32721 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32722 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32723 return 0;
32724 }
32725
32726 -static __initdata struct irq_router_handler pirq_routers[] = {
32727 +static __initconst const struct irq_router_handler pirq_routers[] = {
32728 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32729 { PCI_VENDOR_ID_AL, ali_router_probe },
32730 { PCI_VENDOR_ID_ITE, ite_router_probe },
32731 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32732 static void __init pirq_find_router(struct irq_router *r)
32733 {
32734 struct irq_routing_table *rt = pirq_table;
32735 - struct irq_router_handler *h;
32736 + const struct irq_router_handler *h;
32737
32738 #ifdef CONFIG_PCI_BIOS
32739 if (!rt->signature) {
32740 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32741 return 0;
32742 }
32743
32744 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32745 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32746 {
32747 .callback = fix_broken_hp_bios_irq9,
32748 .ident = "HP Pavilion N5400 Series Laptop",
32749 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32750 index 903fded..94b0d88 100644
32751 --- a/arch/x86/pci/mrst.c
32752 +++ b/arch/x86/pci/mrst.c
32753 @@ -241,7 +241,9 @@ int __init pci_mrst_init(void)
32754 pr_info("Intel MID platform detected, using MID PCI ops\n");
32755 pci_mmcfg_late_init();
32756 pcibios_enable_irq = mrst_pci_irq_enable;
32757 - pci_root_ops = pci_mrst_ops;
32758 + pax_open_kernel();
32759 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32760 + pax_close_kernel();
32761 pci_soc_mode = 1;
32762 /* Continue with standard init */
32763 return 1;
32764 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32765 index c77b24a..c979855 100644
32766 --- a/arch/x86/pci/pcbios.c
32767 +++ b/arch/x86/pci/pcbios.c
32768 @@ -79,7 +79,7 @@ union bios32 {
32769 static struct {
32770 unsigned long address;
32771 unsigned short segment;
32772 -} bios32_indirect = { 0, __KERNEL_CS };
32773 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32774
32775 /*
32776 * Returns the entry point for the given service, NULL on error
32777 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32778 unsigned long length; /* %ecx */
32779 unsigned long entry; /* %edx */
32780 unsigned long flags;
32781 + struct desc_struct d, *gdt;
32782
32783 local_irq_save(flags);
32784 - __asm__("lcall *(%%edi); cld"
32785 +
32786 + gdt = get_cpu_gdt_table(smp_processor_id());
32787 +
32788 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32789 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32790 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32791 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32792 +
32793 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32794 : "=a" (return_code),
32795 "=b" (address),
32796 "=c" (length),
32797 "=d" (entry)
32798 : "0" (service),
32799 "1" (0),
32800 - "D" (&bios32_indirect));
32801 + "D" (&bios32_indirect),
32802 + "r"(__PCIBIOS_DS)
32803 + : "memory");
32804 +
32805 + pax_open_kernel();
32806 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32807 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32808 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32809 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32810 + pax_close_kernel();
32811 +
32812 local_irq_restore(flags);
32813
32814 switch (return_code) {
32815 - case 0:
32816 - return address + entry;
32817 - case 0x80: /* Not present */
32818 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32819 - return 0;
32820 - default: /* Shouldn't happen */
32821 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32822 - service, return_code);
32823 + case 0: {
32824 + int cpu;
32825 + unsigned char flags;
32826 +
32827 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32828 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32829 + printk(KERN_WARNING "bios32_service: not valid\n");
32830 return 0;
32831 + }
32832 + address = address + PAGE_OFFSET;
32833 + length += 16UL; /* some BIOSs underreport this... */
32834 + flags = 4;
32835 + if (length >= 64*1024*1024) {
32836 + length >>= PAGE_SHIFT;
32837 + flags |= 8;
32838 + }
32839 +
32840 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32841 + gdt = get_cpu_gdt_table(cpu);
32842 + pack_descriptor(&d, address, length, 0x9b, flags);
32843 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32844 + pack_descriptor(&d, address, length, 0x93, flags);
32845 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32846 + }
32847 + return entry;
32848 + }
32849 + case 0x80: /* Not present */
32850 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32851 + return 0;
32852 + default: /* Shouldn't happen */
32853 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32854 + service, return_code);
32855 + return 0;
32856 }
32857 }
32858
32859 static struct {
32860 unsigned long address;
32861 unsigned short segment;
32862 -} pci_indirect = { 0, __KERNEL_CS };
32863 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32864
32865 -static int pci_bios_present;
32866 +static int pci_bios_present __read_only;
32867
32868 static int check_pcibios(void)
32869 {
32870 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32871 unsigned long flags, pcibios_entry;
32872
32873 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32874 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32875 + pci_indirect.address = pcibios_entry;
32876
32877 local_irq_save(flags);
32878 - __asm__(
32879 - "lcall *(%%edi); cld\n\t"
32880 + __asm__("movw %w6, %%ds\n\t"
32881 + "lcall *%%ss:(%%edi); cld\n\t"
32882 + "push %%ss\n\t"
32883 + "pop %%ds\n\t"
32884 "jc 1f\n\t"
32885 "xor %%ah, %%ah\n"
32886 "1:"
32887 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32888 "=b" (ebx),
32889 "=c" (ecx)
32890 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32891 - "D" (&pci_indirect)
32892 + "D" (&pci_indirect),
32893 + "r" (__PCIBIOS_DS)
32894 : "memory");
32895 local_irq_restore(flags);
32896
32897 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32898
32899 switch (len) {
32900 case 1:
32901 - __asm__("lcall *(%%esi); cld\n\t"
32902 + __asm__("movw %w6, %%ds\n\t"
32903 + "lcall *%%ss:(%%esi); cld\n\t"
32904 + "push %%ss\n\t"
32905 + "pop %%ds\n\t"
32906 "jc 1f\n\t"
32907 "xor %%ah, %%ah\n"
32908 "1:"
32909 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32910 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32911 "b" (bx),
32912 "D" ((long)reg),
32913 - "S" (&pci_indirect));
32914 + "S" (&pci_indirect),
32915 + "r" (__PCIBIOS_DS));
32916 /*
32917 * Zero-extend the result beyond 8 bits, do not trust the
32918 * BIOS having done it:
32919 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32920 *value &= 0xff;
32921 break;
32922 case 2:
32923 - __asm__("lcall *(%%esi); cld\n\t"
32924 + __asm__("movw %w6, %%ds\n\t"
32925 + "lcall *%%ss:(%%esi); cld\n\t"
32926 + "push %%ss\n\t"
32927 + "pop %%ds\n\t"
32928 "jc 1f\n\t"
32929 "xor %%ah, %%ah\n"
32930 "1:"
32931 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32932 : "1" (PCIBIOS_READ_CONFIG_WORD),
32933 "b" (bx),
32934 "D" ((long)reg),
32935 - "S" (&pci_indirect));
32936 + "S" (&pci_indirect),
32937 + "r" (__PCIBIOS_DS));
32938 /*
32939 * Zero-extend the result beyond 16 bits, do not trust the
32940 * BIOS having done it:
32941 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32942 *value &= 0xffff;
32943 break;
32944 case 4:
32945 - __asm__("lcall *(%%esi); cld\n\t"
32946 + __asm__("movw %w6, %%ds\n\t"
32947 + "lcall *%%ss:(%%esi); cld\n\t"
32948 + "push %%ss\n\t"
32949 + "pop %%ds\n\t"
32950 "jc 1f\n\t"
32951 "xor %%ah, %%ah\n"
32952 "1:"
32953 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32954 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32955 "b" (bx),
32956 "D" ((long)reg),
32957 - "S" (&pci_indirect));
32958 + "S" (&pci_indirect),
32959 + "r" (__PCIBIOS_DS));
32960 break;
32961 }
32962
32963 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32964
32965 switch (len) {
32966 case 1:
32967 - __asm__("lcall *(%%esi); cld\n\t"
32968 + __asm__("movw %w6, %%ds\n\t"
32969 + "lcall *%%ss:(%%esi); cld\n\t"
32970 + "push %%ss\n\t"
32971 + "pop %%ds\n\t"
32972 "jc 1f\n\t"
32973 "xor %%ah, %%ah\n"
32974 "1:"
32975 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32976 "c" (value),
32977 "b" (bx),
32978 "D" ((long)reg),
32979 - "S" (&pci_indirect));
32980 + "S" (&pci_indirect),
32981 + "r" (__PCIBIOS_DS));
32982 break;
32983 case 2:
32984 - __asm__("lcall *(%%esi); cld\n\t"
32985 + __asm__("movw %w6, %%ds\n\t"
32986 + "lcall *%%ss:(%%esi); cld\n\t"
32987 + "push %%ss\n\t"
32988 + "pop %%ds\n\t"
32989 "jc 1f\n\t"
32990 "xor %%ah, %%ah\n"
32991 "1:"
32992 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32993 "c" (value),
32994 "b" (bx),
32995 "D" ((long)reg),
32996 - "S" (&pci_indirect));
32997 + "S" (&pci_indirect),
32998 + "r" (__PCIBIOS_DS));
32999 break;
33000 case 4:
33001 - __asm__("lcall *(%%esi); cld\n\t"
33002 + __asm__("movw %w6, %%ds\n\t"
33003 + "lcall *%%ss:(%%esi); cld\n\t"
33004 + "push %%ss\n\t"
33005 + "pop %%ds\n\t"
33006 "jc 1f\n\t"
33007 "xor %%ah, %%ah\n"
33008 "1:"
33009 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33010 "c" (value),
33011 "b" (bx),
33012 "D" ((long)reg),
33013 - "S" (&pci_indirect));
33014 + "S" (&pci_indirect),
33015 + "r" (__PCIBIOS_DS));
33016 break;
33017 }
33018
33019 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33020
33021 DBG("PCI: Fetching IRQ routing table... ");
33022 __asm__("push %%es\n\t"
33023 + "movw %w8, %%ds\n\t"
33024 "push %%ds\n\t"
33025 "pop %%es\n\t"
33026 - "lcall *(%%esi); cld\n\t"
33027 + "lcall *%%ss:(%%esi); cld\n\t"
33028 "pop %%es\n\t"
33029 + "push %%ss\n\t"
33030 + "pop %%ds\n"
33031 "jc 1f\n\t"
33032 "xor %%ah, %%ah\n"
33033 "1:"
33034 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33035 "1" (0),
33036 "D" ((long) &opt),
33037 "S" (&pci_indirect),
33038 - "m" (opt)
33039 + "m" (opt),
33040 + "r" (__PCIBIOS_DS)
33041 : "memory");
33042 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33043 if (ret & 0xff00)
33044 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33045 {
33046 int ret;
33047
33048 - __asm__("lcall *(%%esi); cld\n\t"
33049 + __asm__("movw %w5, %%ds\n\t"
33050 + "lcall *%%ss:(%%esi); cld\n\t"
33051 + "push %%ss\n\t"
33052 + "pop %%ds\n"
33053 "jc 1f\n\t"
33054 "xor %%ah, %%ah\n"
33055 "1:"
33056 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33057 : "0" (PCIBIOS_SET_PCI_HW_INT),
33058 "b" ((dev->bus->number << 8) | dev->devfn),
33059 "c" ((irq << 8) | (pin + 10)),
33060 - "S" (&pci_indirect));
33061 + "S" (&pci_indirect),
33062 + "r" (__PCIBIOS_DS));
33063 return !(ret & 0xff00);
33064 }
33065 EXPORT_SYMBOL(pcibios_set_irq_routing);
33066 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33067 index 40e4469..d915bf9 100644
33068 --- a/arch/x86/platform/efi/efi_32.c
33069 +++ b/arch/x86/platform/efi/efi_32.c
33070 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33071 {
33072 struct desc_ptr gdt_descr;
33073
33074 +#ifdef CONFIG_PAX_KERNEXEC
33075 + struct desc_struct d;
33076 +#endif
33077 +
33078 local_irq_save(efi_rt_eflags);
33079
33080 load_cr3(initial_page_table);
33081 __flush_tlb_all();
33082
33083 +#ifdef CONFIG_PAX_KERNEXEC
33084 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33085 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33086 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33087 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33088 +#endif
33089 +
33090 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33091 gdt_descr.size = GDT_SIZE - 1;
33092 load_gdt(&gdt_descr);
33093 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33094 {
33095 struct desc_ptr gdt_descr;
33096
33097 +#ifdef CONFIG_PAX_KERNEXEC
33098 + struct desc_struct d;
33099 +
33100 + memset(&d, 0, sizeof d);
33101 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33102 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33103 +#endif
33104 +
33105 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33106 gdt_descr.size = GDT_SIZE - 1;
33107 load_gdt(&gdt_descr);
33108
33109 +#ifdef CONFIG_PAX_PER_CPU_PGD
33110 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33111 +#else
33112 load_cr3(swapper_pg_dir);
33113 +#endif
33114 +
33115 __flush_tlb_all();
33116
33117 local_irq_restore(efi_rt_eflags);
33118 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33119 index 39a0e7f1..872396e 100644
33120 --- a/arch/x86/platform/efi/efi_64.c
33121 +++ b/arch/x86/platform/efi/efi_64.c
33122 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33123 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33124 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33125 }
33126 +
33127 +#ifdef CONFIG_PAX_PER_CPU_PGD
33128 + load_cr3(swapper_pg_dir);
33129 +#endif
33130 +
33131 __flush_tlb_all();
33132 }
33133
33134 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33135 for (pgd = 0; pgd < n_pgds; pgd++)
33136 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33137 kfree(save_pgd);
33138 +
33139 +#ifdef CONFIG_PAX_PER_CPU_PGD
33140 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33141 +#endif
33142 +
33143 __flush_tlb_all();
33144 local_irq_restore(efi_flags);
33145 early_code_mapping_set_exec(0);
33146 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33147 index fbe66e6..eae5e38 100644
33148 --- a/arch/x86/platform/efi/efi_stub_32.S
33149 +++ b/arch/x86/platform/efi/efi_stub_32.S
33150 @@ -6,7 +6,9 @@
33151 */
33152
33153 #include <linux/linkage.h>
33154 +#include <linux/init.h>
33155 #include <asm/page_types.h>
33156 +#include <asm/segment.h>
33157
33158 /*
33159 * efi_call_phys(void *, ...) is a function with variable parameters.
33160 @@ -20,7 +22,7 @@
33161 * service functions will comply with gcc calling convention, too.
33162 */
33163
33164 -.text
33165 +__INIT
33166 ENTRY(efi_call_phys)
33167 /*
33168 * 0. The function can only be called in Linux kernel. So CS has been
33169 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33170 * The mapping of lower virtual memory has been created in prelog and
33171 * epilog.
33172 */
33173 - movl $1f, %edx
33174 - subl $__PAGE_OFFSET, %edx
33175 - jmp *%edx
33176 +#ifdef CONFIG_PAX_KERNEXEC
33177 + movl $(__KERNEXEC_EFI_DS), %edx
33178 + mov %edx, %ds
33179 + mov %edx, %es
33180 + mov %edx, %ss
33181 + addl $2f,(1f)
33182 + ljmp *(1f)
33183 +
33184 +__INITDATA
33185 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33186 +.previous
33187 +
33188 +2:
33189 + subl $2b,(1b)
33190 +#else
33191 + jmp 1f-__PAGE_OFFSET
33192 1:
33193 +#endif
33194
33195 /*
33196 * 2. Now on the top of stack is the return
33197 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33198 * parameter 2, ..., param n. To make things easy, we save the return
33199 * address of efi_call_phys in a global variable.
33200 */
33201 - popl %edx
33202 - movl %edx, saved_return_addr
33203 - /* get the function pointer into ECX*/
33204 - popl %ecx
33205 - movl %ecx, efi_rt_function_ptr
33206 - movl $2f, %edx
33207 - subl $__PAGE_OFFSET, %edx
33208 - pushl %edx
33209 + popl (saved_return_addr)
33210 + popl (efi_rt_function_ptr)
33211
33212 /*
33213 * 3. Clear PG bit in %CR0.
33214 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33215 /*
33216 * 5. Call the physical function.
33217 */
33218 - jmp *%ecx
33219 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33220
33221 -2:
33222 /*
33223 * 6. After EFI runtime service returns, control will return to
33224 * following instruction. We'd better readjust stack pointer first.
33225 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33226 movl %cr0, %edx
33227 orl $0x80000000, %edx
33228 movl %edx, %cr0
33229 - jmp 1f
33230 -1:
33231 +
33232 /*
33233 * 8. Now restore the virtual mode from flat mode by
33234 * adding EIP with PAGE_OFFSET.
33235 */
33236 - movl $1f, %edx
33237 - jmp *%edx
33238 +#ifdef CONFIG_PAX_KERNEXEC
33239 + movl $(__KERNEL_DS), %edx
33240 + mov %edx, %ds
33241 + mov %edx, %es
33242 + mov %edx, %ss
33243 + ljmp $(__KERNEL_CS),$1f
33244 +#else
33245 + jmp 1f+__PAGE_OFFSET
33246 +#endif
33247 1:
33248
33249 /*
33250 * 9. Balance the stack. And because EAX contain the return value,
33251 * we'd better not clobber it.
33252 */
33253 - leal efi_rt_function_ptr, %edx
33254 - movl (%edx), %ecx
33255 - pushl %ecx
33256 + pushl (efi_rt_function_ptr)
33257
33258 /*
33259 - * 10. Push the saved return address onto the stack and return.
33260 + * 10. Return to the saved return address.
33261 */
33262 - leal saved_return_addr, %edx
33263 - movl (%edx), %ecx
33264 - pushl %ecx
33265 - ret
33266 + jmpl *(saved_return_addr)
33267 ENDPROC(efi_call_phys)
33268 .previous
33269
33270 -.data
33271 +__INITDATA
33272 saved_return_addr:
33273 .long 0
33274 efi_rt_function_ptr:
33275 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33276 index 4c07cca..2c8427d 100644
33277 --- a/arch/x86/platform/efi/efi_stub_64.S
33278 +++ b/arch/x86/platform/efi/efi_stub_64.S
33279 @@ -7,6 +7,7 @@
33280 */
33281
33282 #include <linux/linkage.h>
33283 +#include <asm/alternative-asm.h>
33284
33285 #define SAVE_XMM \
33286 mov %rsp, %rax; \
33287 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33288 call *%rdi
33289 addq $32, %rsp
33290 RESTORE_XMM
33291 + pax_force_retaddr 0, 1
33292 ret
33293 ENDPROC(efi_call0)
33294
33295 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33296 call *%rdi
33297 addq $32, %rsp
33298 RESTORE_XMM
33299 + pax_force_retaddr 0, 1
33300 ret
33301 ENDPROC(efi_call1)
33302
33303 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33304 call *%rdi
33305 addq $32, %rsp
33306 RESTORE_XMM
33307 + pax_force_retaddr 0, 1
33308 ret
33309 ENDPROC(efi_call2)
33310
33311 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33312 call *%rdi
33313 addq $32, %rsp
33314 RESTORE_XMM
33315 + pax_force_retaddr 0, 1
33316 ret
33317 ENDPROC(efi_call3)
33318
33319 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33320 call *%rdi
33321 addq $32, %rsp
33322 RESTORE_XMM
33323 + pax_force_retaddr 0, 1
33324 ret
33325 ENDPROC(efi_call4)
33326
33327 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33328 call *%rdi
33329 addq $48, %rsp
33330 RESTORE_XMM
33331 + pax_force_retaddr 0, 1
33332 ret
33333 ENDPROC(efi_call5)
33334
33335 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33336 call *%rdi
33337 addq $48, %rsp
33338 RESTORE_XMM
33339 + pax_force_retaddr 0, 1
33340 ret
33341 ENDPROC(efi_call6)
33342 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33343 index 3ca5957..7909c18 100644
33344 --- a/arch/x86/platform/mrst/mrst.c
33345 +++ b/arch/x86/platform/mrst/mrst.c
33346 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33347 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33348 int sfi_mrtc_num;
33349
33350 -static void mrst_power_off(void)
33351 +static __noreturn void mrst_power_off(void)
33352 {
33353 + BUG();
33354 }
33355
33356 -static void mrst_reboot(void)
33357 +static __noreturn void mrst_reboot(void)
33358 {
33359 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33360 + BUG();
33361 }
33362
33363 /* parse all the mtimer info to a static mtimer array */
33364 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33365 index d6ee929..3637cb5 100644
33366 --- a/arch/x86/platform/olpc/olpc_dt.c
33367 +++ b/arch/x86/platform/olpc/olpc_dt.c
33368 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33369 return res;
33370 }
33371
33372 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33373 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33374 .nextprop = olpc_dt_nextprop,
33375 .getproplen = olpc_dt_getproplen,
33376 .getproperty = olpc_dt_getproperty,
33377 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33378 index 424f4c9..f2a2988 100644
33379 --- a/arch/x86/power/cpu.c
33380 +++ b/arch/x86/power/cpu.c
33381 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33382 static void fix_processor_context(void)
33383 {
33384 int cpu = smp_processor_id();
33385 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33386 -#ifdef CONFIG_X86_64
33387 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33388 - tss_desc tss;
33389 -#endif
33390 + struct tss_struct *t = init_tss + cpu;
33391 +
33392 set_tss_desc(cpu, t); /*
33393 * This just modifies memory; should not be
33394 * necessary. But... This is necessary, because
33395 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33396 */
33397
33398 #ifdef CONFIG_X86_64
33399 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33400 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33401 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33402 -
33403 syscall_init(); /* This sets MSR_*STAR and related */
33404 #endif
33405 load_TR_desc(); /* This does ltr */
33406 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33407 index a44f457..9140171 100644
33408 --- a/arch/x86/realmode/init.c
33409 +++ b/arch/x86/realmode/init.c
33410 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33411 __va(real_mode_header->trampoline_header);
33412
33413 #ifdef CONFIG_X86_32
33414 - trampoline_header->start = __pa_symbol(startup_32_smp);
33415 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33416 +
33417 +#ifdef CONFIG_PAX_KERNEXEC
33418 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33419 +#endif
33420 +
33421 + trampoline_header->boot_cs = __BOOT_CS;
33422 trampoline_header->gdt_limit = __BOOT_DS + 7;
33423 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33424 #else
33425 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33426 *trampoline_cr4_features = read_cr4();
33427
33428 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33429 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33430 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33431 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33432 #endif
33433 }
33434 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33435 index 8869287..d577672 100644
33436 --- a/arch/x86/realmode/rm/Makefile
33437 +++ b/arch/x86/realmode/rm/Makefile
33438 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33439 $(call cc-option, -fno-unit-at-a-time)) \
33440 $(call cc-option, -fno-stack-protector) \
33441 $(call cc-option, -mpreferred-stack-boundary=2)
33442 +ifdef CONSTIFY_PLUGIN
33443 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33444 +endif
33445 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33446 GCOV_PROFILE := n
33447 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33448 index a28221d..93c40f1 100644
33449 --- a/arch/x86/realmode/rm/header.S
33450 +++ b/arch/x86/realmode/rm/header.S
33451 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33452 #endif
33453 /* APM/BIOS reboot */
33454 .long pa_machine_real_restart_asm
33455 -#ifdef CONFIG_X86_64
33456 +#ifdef CONFIG_X86_32
33457 + .long __KERNEL_CS
33458 +#else
33459 .long __KERNEL32_CS
33460 #endif
33461 END(real_mode_header)
33462 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33463 index c1b2791..f9e31c7 100644
33464 --- a/arch/x86/realmode/rm/trampoline_32.S
33465 +++ b/arch/x86/realmode/rm/trampoline_32.S
33466 @@ -25,6 +25,12 @@
33467 #include <asm/page_types.h>
33468 #include "realmode.h"
33469
33470 +#ifdef CONFIG_PAX_KERNEXEC
33471 +#define ta(X) (X)
33472 +#else
33473 +#define ta(X) (pa_ ## X)
33474 +#endif
33475 +
33476 .text
33477 .code16
33478
33479 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33480
33481 cli # We should be safe anyway
33482
33483 - movl tr_start, %eax # where we need to go
33484 -
33485 movl $0xA5A5A5A5, trampoline_status
33486 # write marker for master knows we're running
33487
33488 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33489 movw $1, %dx # protected mode (PE) bit
33490 lmsw %dx # into protected mode
33491
33492 - ljmpl $__BOOT_CS, $pa_startup_32
33493 + ljmpl *(trampoline_header)
33494
33495 .section ".text32","ax"
33496 .code32
33497 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33498 .balign 8
33499 GLOBAL(trampoline_header)
33500 tr_start: .space 4
33501 - tr_gdt_pad: .space 2
33502 + tr_boot_cs: .space 2
33503 tr_gdt: .space 6
33504 END(trampoline_header)
33505
33506 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33507 index bb360dc..d0fd8f8 100644
33508 --- a/arch/x86/realmode/rm/trampoline_64.S
33509 +++ b/arch/x86/realmode/rm/trampoline_64.S
33510 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33511 movl %edx, %gs
33512
33513 movl pa_tr_cr4, %eax
33514 + andl $~X86_CR4_PCIDE, %eax
33515 movl %eax, %cr4 # Enable PAE mode
33516
33517 # Setup trampoline 4 level pagetables
33518 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33519 wrmsr
33520
33521 # Enable paging and in turn activate Long Mode
33522 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33523 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33524 movl %eax, %cr0
33525
33526 /*
33527 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33528 index e812034..c747134 100644
33529 --- a/arch/x86/tools/Makefile
33530 +++ b/arch/x86/tools/Makefile
33531 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33532
33533 $(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
33534
33535 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33536 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33537 hostprogs-y += relocs
33538 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33539 relocs: $(obj)/relocs
33540 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33541 index f7bab68..b6d9886 100644
33542 --- a/arch/x86/tools/relocs.c
33543 +++ b/arch/x86/tools/relocs.c
33544 @@ -1,5 +1,7 @@
33545 /* This is included from relocs_32/64.c */
33546
33547 +#include "../../../include/generated/autoconf.h"
33548 +
33549 #define ElfW(type) _ElfW(ELF_BITS, type)
33550 #define _ElfW(bits, type) __ElfW(bits, type)
33551 #define __ElfW(bits, type) Elf##bits##_##type
33552 @@ -11,6 +13,7 @@
33553 #define Elf_Sym ElfW(Sym)
33554
33555 static Elf_Ehdr ehdr;
33556 +static Elf_Phdr *phdr;
33557
33558 struct relocs {
33559 uint32_t *offset;
33560 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33561 }
33562 }
33563
33564 +static void read_phdrs(FILE *fp)
33565 +{
33566 + unsigned int i;
33567 +
33568 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33569 + if (!phdr) {
33570 + die("Unable to allocate %d program headers\n",
33571 + ehdr.e_phnum);
33572 + }
33573 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33574 + die("Seek to %d failed: %s\n",
33575 + ehdr.e_phoff, strerror(errno));
33576 + }
33577 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33578 + die("Cannot read ELF program headers: %s\n",
33579 + strerror(errno));
33580 + }
33581 + for(i = 0; i < ehdr.e_phnum; i++) {
33582 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33583 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33584 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33585 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33586 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33587 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33588 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33589 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33590 + }
33591 +
33592 +}
33593 +
33594 static void read_shdrs(FILE *fp)
33595 {
33596 - int i;
33597 + unsigned int i;
33598 Elf_Shdr shdr;
33599
33600 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33601 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33602
33603 static void read_strtabs(FILE *fp)
33604 {
33605 - int i;
33606 + unsigned int i;
33607 for (i = 0; i < ehdr.e_shnum; i++) {
33608 struct section *sec = &secs[i];
33609 if (sec->shdr.sh_type != SHT_STRTAB) {
33610 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33611
33612 static void read_symtabs(FILE *fp)
33613 {
33614 - int i,j;
33615 + unsigned int i,j;
33616 for (i = 0; i < ehdr.e_shnum; i++) {
33617 struct section *sec = &secs[i];
33618 if (sec->shdr.sh_type != SHT_SYMTAB) {
33619 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33620 }
33621
33622
33623 -static void read_relocs(FILE *fp)
33624 +static void read_relocs(FILE *fp, int use_real_mode)
33625 {
33626 - int i,j;
33627 + unsigned int i,j;
33628 + uint32_t base;
33629 +
33630 for (i = 0; i < ehdr.e_shnum; i++) {
33631 struct section *sec = &secs[i];
33632 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33633 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33634 die("Cannot read symbol table: %s\n",
33635 strerror(errno));
33636 }
33637 + base = 0;
33638 +
33639 +#ifdef CONFIG_X86_32
33640 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33641 + if (phdr[j].p_type != PT_LOAD )
33642 + continue;
33643 + 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)
33644 + continue;
33645 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33646 + break;
33647 + }
33648 +#endif
33649 +
33650 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33651 Elf_Rel *rel = &sec->reltab[j];
33652 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33653 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33654 rel->r_info = elf_xword_to_cpu(rel->r_info);
33655 #if (SHT_REL_TYPE == SHT_RELA)
33656 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33657 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33658
33659 static void print_absolute_symbols(void)
33660 {
33661 - int i;
33662 + unsigned int i;
33663 const char *format;
33664
33665 if (ELF_BITS == 64)
33666 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33667 for (i = 0; i < ehdr.e_shnum; i++) {
33668 struct section *sec = &secs[i];
33669 char *sym_strtab;
33670 - int j;
33671 + unsigned int j;
33672
33673 if (sec->shdr.sh_type != SHT_SYMTAB) {
33674 continue;
33675 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33676
33677 static void print_absolute_relocs(void)
33678 {
33679 - int i, printed = 0;
33680 + unsigned int i, printed = 0;
33681 const char *format;
33682
33683 if (ELF_BITS == 64)
33684 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33685 struct section *sec_applies, *sec_symtab;
33686 char *sym_strtab;
33687 Elf_Sym *sh_symtab;
33688 - int j;
33689 + unsigned int j;
33690 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33691 continue;
33692 }
33693 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33694 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33695 Elf_Sym *sym, const char *symname))
33696 {
33697 - int i;
33698 + unsigned int i;
33699 /* Walk through the relocations */
33700 for (i = 0; i < ehdr.e_shnum; i++) {
33701 char *sym_strtab;
33702 Elf_Sym *sh_symtab;
33703 struct section *sec_applies, *sec_symtab;
33704 - int j;
33705 + unsigned int j;
33706 struct section *sec = &secs[i];
33707
33708 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33709 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33710 {
33711 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33712 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33713 + char *sym_strtab = sec->link->link->strtab;
33714 +
33715 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33716 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33717 + return 0;
33718 +
33719 +#ifdef CONFIG_PAX_KERNEXEC
33720 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33721 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33722 + return 0;
33723 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33724 + return 0;
33725 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33726 + return 0;
33727 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33728 + return 0;
33729 +#endif
33730
33731 switch (r_type) {
33732 case R_386_NONE:
33733 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33734
33735 static void emit_relocs(int as_text, int use_real_mode)
33736 {
33737 - int i;
33738 + unsigned int i;
33739 int (*write_reloc)(uint32_t, FILE *) = write32;
33740 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33741 const char *symname);
33742 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33743 {
33744 regex_init(use_real_mode);
33745 read_ehdr(fp);
33746 + read_phdrs(fp);
33747 read_shdrs(fp);
33748 read_strtabs(fp);
33749 read_symtabs(fp);
33750 - read_relocs(fp);
33751 + read_relocs(fp, use_real_mode);
33752 if (ELF_BITS == 64)
33753 percpu_init();
33754 if (show_absolute_syms) {
33755 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33756 index 80ffa5b..a33bd15 100644
33757 --- a/arch/x86/um/tls_32.c
33758 +++ b/arch/x86/um/tls_32.c
33759 @@ -260,7 +260,7 @@ out:
33760 if (unlikely(task == current &&
33761 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33762 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33763 - "without flushed TLS.", current->pid);
33764 + "without flushed TLS.", task_pid_nr(current));
33765 }
33766
33767 return 0;
33768 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33769 index fd14be1..e3c79c0 100644
33770 --- a/arch/x86/vdso/Makefile
33771 +++ b/arch/x86/vdso/Makefile
33772 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33773 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33774 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33775
33776 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33777 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33778 GCOV_PROFILE := n
33779
33780 #
33781 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33782 index d6bfb87..876ee18 100644
33783 --- a/arch/x86/vdso/vdso32-setup.c
33784 +++ b/arch/x86/vdso/vdso32-setup.c
33785 @@ -25,6 +25,7 @@
33786 #include <asm/tlbflush.h>
33787 #include <asm/vdso.h>
33788 #include <asm/proto.h>
33789 +#include <asm/mman.h>
33790
33791 enum {
33792 VDSO_DISABLED = 0,
33793 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33794 void enable_sep_cpu(void)
33795 {
33796 int cpu = get_cpu();
33797 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33798 + struct tss_struct *tss = init_tss + cpu;
33799
33800 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33801 put_cpu();
33802 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33803 gate_vma.vm_start = FIXADDR_USER_START;
33804 gate_vma.vm_end = FIXADDR_USER_END;
33805 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33806 - gate_vma.vm_page_prot = __P101;
33807 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33808
33809 return 0;
33810 }
33811 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33812 if (compat)
33813 addr = VDSO_HIGH_BASE;
33814 else {
33815 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33816 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33817 if (IS_ERR_VALUE(addr)) {
33818 ret = addr;
33819 goto up_fail;
33820 }
33821 }
33822
33823 - current->mm->context.vdso = (void *)addr;
33824 + current->mm->context.vdso = addr;
33825
33826 if (compat_uses_vma || !compat) {
33827 /*
33828 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33829 }
33830
33831 current_thread_info()->sysenter_return =
33832 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33833 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33834
33835 up_fail:
33836 if (ret)
33837 - current->mm->context.vdso = NULL;
33838 + current->mm->context.vdso = 0;
33839
33840 up_write(&mm->mmap_sem);
33841
33842 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33843
33844 const char *arch_vma_name(struct vm_area_struct *vma)
33845 {
33846 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33847 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33848 return "[vdso]";
33849 +
33850 +#ifdef CONFIG_PAX_SEGMEXEC
33851 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33852 + return "[vdso]";
33853 +#endif
33854 +
33855 return NULL;
33856 }
33857
33858 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33859 * Check to see if the corresponding task was created in compat vdso
33860 * mode.
33861 */
33862 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33863 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33864 return &gate_vma;
33865 return NULL;
33866 }
33867 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33868 index 431e875..cbb23f3 100644
33869 --- a/arch/x86/vdso/vma.c
33870 +++ b/arch/x86/vdso/vma.c
33871 @@ -16,8 +16,6 @@
33872 #include <asm/vdso.h>
33873 #include <asm/page.h>
33874
33875 -unsigned int __read_mostly vdso_enabled = 1;
33876 -
33877 extern char vdso_start[], vdso_end[];
33878 extern unsigned short vdso_sync_cpuid;
33879
33880 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33881 * unaligned here as a result of stack start randomization.
33882 */
33883 addr = PAGE_ALIGN(addr);
33884 - addr = align_vdso_addr(addr);
33885
33886 return addr;
33887 }
33888 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33889 unsigned size)
33890 {
33891 struct mm_struct *mm = current->mm;
33892 - unsigned long addr;
33893 + unsigned long addr = 0;
33894 int ret;
33895
33896 - if (!vdso_enabled)
33897 - return 0;
33898 -
33899 down_write(&mm->mmap_sem);
33900 +
33901 +#ifdef CONFIG_PAX_RANDMMAP
33902 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33903 +#endif
33904 +
33905 addr = vdso_addr(mm->start_stack, size);
33906 + addr = align_vdso_addr(addr);
33907 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33908 if (IS_ERR_VALUE(addr)) {
33909 ret = addr;
33910 goto up_fail;
33911 }
33912
33913 - current->mm->context.vdso = (void *)addr;
33914 + mm->context.vdso = addr;
33915
33916 ret = install_special_mapping(mm, addr, size,
33917 VM_READ|VM_EXEC|
33918 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33919 pages);
33920 - if (ret) {
33921 - current->mm->context.vdso = NULL;
33922 - goto up_fail;
33923 - }
33924 + if (ret)
33925 + mm->context.vdso = 0;
33926
33927 up_fail:
33928 up_write(&mm->mmap_sem);
33929 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33930 vdsox32_size);
33931 }
33932 #endif
33933 -
33934 -static __init int vdso_setup(char *s)
33935 -{
33936 - vdso_enabled = simple_strtoul(s, NULL, 0);
33937 - return 0;
33938 -}
33939 -__setup("vdso=", vdso_setup);
33940 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33941 index fa6ade7..73da73a5 100644
33942 --- a/arch/x86/xen/enlighten.c
33943 +++ b/arch/x86/xen/enlighten.c
33944 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33945
33946 struct shared_info xen_dummy_shared_info;
33947
33948 -void *xen_initial_gdt;
33949 -
33950 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33951 __read_mostly int xen_have_vector_callback;
33952 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33953 @@ -541,8 +539,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33954 {
33955 unsigned long va = dtr->address;
33956 unsigned int size = dtr->size + 1;
33957 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33958 - unsigned long frames[pages];
33959 + unsigned long frames[65536 / PAGE_SIZE];
33960 int f;
33961
33962 /*
33963 @@ -590,8 +587,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33964 {
33965 unsigned long va = dtr->address;
33966 unsigned int size = dtr->size + 1;
33967 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33968 - unsigned long frames[pages];
33969 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33970 int f;
33971
33972 /*
33973 @@ -599,7 +595,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33974 * 8-byte entries, or 16 4k pages..
33975 */
33976
33977 - BUG_ON(size > 65536);
33978 + BUG_ON(size > GDT_SIZE);
33979 BUG_ON(va & ~PAGE_MASK);
33980
33981 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33982 @@ -988,7 +984,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33983 return 0;
33984 }
33985
33986 -static void set_xen_basic_apic_ops(void)
33987 +static void __init set_xen_basic_apic_ops(void)
33988 {
33989 apic->read = xen_apic_read;
33990 apic->write = xen_apic_write;
33991 @@ -1293,30 +1289,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33992 #endif
33993 };
33994
33995 -static void xen_reboot(int reason)
33996 +static __noreturn void xen_reboot(int reason)
33997 {
33998 struct sched_shutdown r = { .reason = reason };
33999
34000 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34001 - BUG();
34002 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34003 + BUG();
34004 }
34005
34006 -static void xen_restart(char *msg)
34007 +static __noreturn void xen_restart(char *msg)
34008 {
34009 xen_reboot(SHUTDOWN_reboot);
34010 }
34011
34012 -static void xen_emergency_restart(void)
34013 +static __noreturn void xen_emergency_restart(void)
34014 {
34015 xen_reboot(SHUTDOWN_reboot);
34016 }
34017
34018 -static void xen_machine_halt(void)
34019 +static __noreturn void xen_machine_halt(void)
34020 {
34021 xen_reboot(SHUTDOWN_poweroff);
34022 }
34023
34024 -static void xen_machine_power_off(void)
34025 +static __noreturn void xen_machine_power_off(void)
34026 {
34027 if (pm_power_off)
34028 pm_power_off();
34029 @@ -1467,7 +1463,17 @@ asmlinkage void __init xen_start_kernel(void)
34030 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34031
34032 /* Work out if we support NX */
34033 - x86_configure_nx();
34034 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34035 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34036 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34037 + unsigned l, h;
34038 +
34039 + __supported_pte_mask |= _PAGE_NX;
34040 + rdmsr(MSR_EFER, l, h);
34041 + l |= EFER_NX;
34042 + wrmsr(MSR_EFER, l, h);
34043 + }
34044 +#endif
34045
34046 xen_setup_features();
34047
34048 @@ -1498,13 +1504,6 @@ asmlinkage void __init xen_start_kernel(void)
34049
34050 machine_ops = xen_machine_ops;
34051
34052 - /*
34053 - * The only reliable way to retain the initial address of the
34054 - * percpu gdt_page is to remember it here, so we can go and
34055 - * mark it RW later, when the initial percpu area is freed.
34056 - */
34057 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34058 -
34059 xen_smp_init();
34060
34061 #ifdef CONFIG_ACPI_NUMA
34062 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34063 index fdc3ba2..23cae00 100644
34064 --- a/arch/x86/xen/mmu.c
34065 +++ b/arch/x86/xen/mmu.c
34066 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
34067 return val;
34068 }
34069
34070 -static pteval_t pte_pfn_to_mfn(pteval_t val)
34071 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
34072 {
34073 if (val & _PAGE_PRESENT) {
34074 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
34075 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34076 /* L3_k[510] -> level2_kernel_pgt
34077 * L3_i[511] -> level2_fixmap_pgt */
34078 convert_pfn_mfn(level3_kernel_pgt);
34079 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34080 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34081 + convert_pfn_mfn(level3_vmemmap_pgt);
34082
34083 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34084 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34085 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34086 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34087 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34088 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34089 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34090 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34091 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34092 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34093 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34094 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34095 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34096 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34097
34098 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34099 pv_mmu_ops.set_pud = xen_set_pud;
34100 #if PAGETABLE_LEVELS == 4
34101 pv_mmu_ops.set_pgd = xen_set_pgd;
34102 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34103 #endif
34104
34105 /* This will work as long as patching hasn't happened yet
34106 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34107 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34108 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34109 .set_pgd = xen_set_pgd_hyper,
34110 + .set_pgd_batched = xen_set_pgd_hyper,
34111
34112 .alloc_pud = xen_alloc_pmd_init,
34113 .release_pud = xen_release_pmd_init,
34114 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34115 index 31d0475..51af671 100644
34116 --- a/arch/x86/xen/smp.c
34117 +++ b/arch/x86/xen/smp.c
34118 @@ -274,17 +274,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
34119 native_smp_prepare_boot_cpu();
34120
34121 if (xen_pv_domain()) {
34122 - /* We've switched to the "real" per-cpu gdt, so make sure the
34123 - old memory can be recycled */
34124 - make_lowmem_page_readwrite(xen_initial_gdt);
34125 -
34126 #ifdef CONFIG_X86_32
34127 /*
34128 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
34129 * expects __USER_DS
34130 */
34131 - loadsegment(ds, __USER_DS);
34132 - loadsegment(es, __USER_DS);
34133 + loadsegment(ds, __KERNEL_DS);
34134 + loadsegment(es, __KERNEL_DS);
34135 #endif
34136
34137 xen_filter_cpu_maps();
34138 @@ -364,7 +360,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34139 ctxt->user_regs.ss = __KERNEL_DS;
34140 #ifdef CONFIG_X86_32
34141 ctxt->user_regs.fs = __KERNEL_PERCPU;
34142 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34143 + savesegment(gs, ctxt->user_regs.gs);
34144 #else
34145 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34146 #endif
34147 @@ -374,8 +370,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34148
34149 {
34150 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34151 - ctxt->user_regs.ds = __USER_DS;
34152 - ctxt->user_regs.es = __USER_DS;
34153 + ctxt->user_regs.ds = __KERNEL_DS;
34154 + ctxt->user_regs.es = __KERNEL_DS;
34155
34156 xen_copy_trap_info(ctxt->trap_ctxt);
34157
34158 @@ -420,13 +416,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34159 int rc;
34160
34161 per_cpu(current_task, cpu) = idle;
34162 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34163 #ifdef CONFIG_X86_32
34164 irq_ctx_init(cpu);
34165 #else
34166 clear_tsk_thread_flag(idle, TIF_FORK);
34167 - per_cpu(kernel_stack, cpu) =
34168 - (unsigned long)task_stack_page(idle) -
34169 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34170 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34171 #endif
34172 xen_setup_runstate_info(cpu);
34173 xen_setup_timer(cpu);
34174 @@ -702,7 +697,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34175
34176 void __init xen_smp_init(void)
34177 {
34178 - smp_ops = xen_smp_ops;
34179 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34180 xen_fill_possible_map();
34181 }
34182
34183 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34184 index 33ca6e4..0ded929 100644
34185 --- a/arch/x86/xen/xen-asm_32.S
34186 +++ b/arch/x86/xen/xen-asm_32.S
34187 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34188 ESP_OFFSET=4 # bytes pushed onto stack
34189
34190 /*
34191 - * Store vcpu_info pointer for easy access. Do it this way to
34192 - * avoid having to reload %fs
34193 + * Store vcpu_info pointer for easy access.
34194 */
34195 #ifdef CONFIG_SMP
34196 - GET_THREAD_INFO(%eax)
34197 - movl %ss:TI_cpu(%eax), %eax
34198 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34199 - mov %ss:xen_vcpu(%eax), %eax
34200 + push %fs
34201 + mov $(__KERNEL_PERCPU), %eax
34202 + mov %eax, %fs
34203 + mov PER_CPU_VAR(xen_vcpu), %eax
34204 + pop %fs
34205 #else
34206 movl %ss:xen_vcpu, %eax
34207 #endif
34208 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34209 index 7faed58..ba4427c 100644
34210 --- a/arch/x86/xen/xen-head.S
34211 +++ b/arch/x86/xen/xen-head.S
34212 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34213 #ifdef CONFIG_X86_32
34214 mov %esi,xen_start_info
34215 mov $init_thread_union+THREAD_SIZE,%esp
34216 +#ifdef CONFIG_SMP
34217 + movl $cpu_gdt_table,%edi
34218 + movl $__per_cpu_load,%eax
34219 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34220 + rorl $16,%eax
34221 + movb %al,__KERNEL_PERCPU + 4(%edi)
34222 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34223 + movl $__per_cpu_end - 1,%eax
34224 + subl $__per_cpu_start,%eax
34225 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34226 +#endif
34227 #else
34228 mov %rsi,xen_start_info
34229 mov $init_thread_union+THREAD_SIZE,%rsp
34230 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34231 index 95f8c61..611d6e8 100644
34232 --- a/arch/x86/xen/xen-ops.h
34233 +++ b/arch/x86/xen/xen-ops.h
34234 @@ -10,8 +10,6 @@
34235 extern const char xen_hypervisor_callback[];
34236 extern const char xen_failsafe_callback[];
34237
34238 -extern void *xen_initial_gdt;
34239 -
34240 struct trap_info;
34241 void xen_copy_trap_info(struct trap_info *traps);
34242
34243 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34244 index 525bd3d..ef888b1 100644
34245 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34246 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34247 @@ -119,9 +119,9 @@
34248 ----------------------------------------------------------------------*/
34249
34250 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34251 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34252 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34253 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34254 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34255
34256 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34257 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34258 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34259 index 2f33760..835e50a 100644
34260 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34261 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34262 @@ -11,6 +11,7 @@
34263 #ifndef _XTENSA_CORE_H
34264 #define _XTENSA_CORE_H
34265
34266 +#include <linux/const.h>
34267
34268 /****************************************************************************
34269 Parameters Useful for Any Code, USER or PRIVILEGED
34270 @@ -112,9 +113,9 @@
34271 ----------------------------------------------------------------------*/
34272
34273 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34274 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34275 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34276 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34277 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34278
34279 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34280 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34281 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34282 index af00795..2bb8105 100644
34283 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34284 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34285 @@ -11,6 +11,7 @@
34286 #ifndef _XTENSA_CORE_CONFIGURATION_H
34287 #define _XTENSA_CORE_CONFIGURATION_H
34288
34289 +#include <linux/const.h>
34290
34291 /****************************************************************************
34292 Parameters Useful for Any Code, USER or PRIVILEGED
34293 @@ -118,9 +119,9 @@
34294 ----------------------------------------------------------------------*/
34295
34296 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34297 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34298 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34299 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34300 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34301
34302 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34303 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34304 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34305 index 4e491d9..c8e18e4 100644
34306 --- a/block/blk-cgroup.c
34307 +++ b/block/blk-cgroup.c
34308 @@ -812,7 +812,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
34309 static struct cgroup_subsys_state *
34310 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34311 {
34312 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34313 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34314 struct blkcg *blkcg;
34315
34316 if (!parent_css) {
34317 @@ -826,7 +826,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34318
34319 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34320 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34321 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34322 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34323 done:
34324 spin_lock_init(&blkcg->lock);
34325 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34326 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34327 index 4b8d9b54..a7178c0 100644
34328 --- a/block/blk-iopoll.c
34329 +++ b/block/blk-iopoll.c
34330 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34331 }
34332 EXPORT_SYMBOL(blk_iopoll_complete);
34333
34334 -static void blk_iopoll_softirq(struct softirq_action *h)
34335 +static __latent_entropy void blk_iopoll_softirq(void)
34336 {
34337 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34338 int rearm = 0, budget = blk_iopoll_budget;
34339 diff --git a/block/blk-map.c b/block/blk-map.c
34340 index 623e1cd..ca1e109 100644
34341 --- a/block/blk-map.c
34342 +++ b/block/blk-map.c
34343 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34344 if (!len || !kbuf)
34345 return -EINVAL;
34346
34347 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34348 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34349 if (do_copy)
34350 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34351 else
34352 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34353 index ec9e606..3f38839 100644
34354 --- a/block/blk-softirq.c
34355 +++ b/block/blk-softirq.c
34356 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34357 * Softirq action handler - move entries to local list and loop over them
34358 * while passing them to the queue registered handler.
34359 */
34360 -static void blk_done_softirq(struct softirq_action *h)
34361 +static __latent_entropy void blk_done_softirq(void)
34362 {
34363 struct list_head *cpu_list, local_list;
34364
34365 diff --git a/block/bsg.c b/block/bsg.c
34366 index 420a5a9..23834aa 100644
34367 --- a/block/bsg.c
34368 +++ b/block/bsg.c
34369 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34370 struct sg_io_v4 *hdr, struct bsg_device *bd,
34371 fmode_t has_write_perm)
34372 {
34373 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34374 + unsigned char *cmdptr;
34375 +
34376 if (hdr->request_len > BLK_MAX_CDB) {
34377 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34378 if (!rq->cmd)
34379 return -ENOMEM;
34380 - }
34381 + cmdptr = rq->cmd;
34382 + } else
34383 + cmdptr = tmpcmd;
34384
34385 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34386 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34387 hdr->request_len))
34388 return -EFAULT;
34389
34390 + if (cmdptr != rq->cmd)
34391 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34392 +
34393 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34394 if (blk_verify_command(rq->cmd, has_write_perm))
34395 return -EPERM;
34396 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34397 index fbd5a67..5d631b5 100644
34398 --- a/block/compat_ioctl.c
34399 +++ b/block/compat_ioctl.c
34400 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34401 err |= __get_user(f->spec1, &uf->spec1);
34402 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34403 err |= __get_user(name, &uf->name);
34404 - f->name = compat_ptr(name);
34405 + f->name = (void __force_kernel *)compat_ptr(name);
34406 if (err) {
34407 err = -EFAULT;
34408 goto out;
34409 diff --git a/block/genhd.c b/block/genhd.c
34410 index 791f419..89f21c4 100644
34411 --- a/block/genhd.c
34412 +++ b/block/genhd.c
34413 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34414
34415 /*
34416 * Register device numbers dev..(dev+range-1)
34417 - * range must be nonzero
34418 + * Noop if @range is zero.
34419 * The hash chain is sorted on range, so that subranges can override.
34420 */
34421 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34422 struct kobject *(*probe)(dev_t, int *, void *),
34423 int (*lock)(dev_t, void *), void *data)
34424 {
34425 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34426 + if (range)
34427 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34428 }
34429
34430 EXPORT_SYMBOL(blk_register_region);
34431
34432 +/* undo blk_register_region(), noop if @range is zero */
34433 void blk_unregister_region(dev_t devt, unsigned long range)
34434 {
34435 - kobj_unmap(bdev_map, devt, range);
34436 + if (range)
34437 + kobj_unmap(bdev_map, devt, range);
34438 }
34439
34440 EXPORT_SYMBOL(blk_unregister_region);
34441 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34442 index a8287b4..241a48e 100644
34443 --- a/block/partitions/efi.c
34444 +++ b/block/partitions/efi.c
34445 @@ -292,14 +292,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34446 if (!gpt)
34447 return NULL;
34448
34449 + if (!le32_to_cpu(gpt->num_partition_entries))
34450 + return NULL;
34451 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34452 + if (!pte)
34453 + return NULL;
34454 +
34455 count = le32_to_cpu(gpt->num_partition_entries) *
34456 le32_to_cpu(gpt->sizeof_partition_entry);
34457 - if (!count)
34458 - return NULL;
34459 - pte = kmalloc(count, GFP_KERNEL);
34460 - if (!pte)
34461 - return NULL;
34462 -
34463 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34464 (u8 *) pte, count) < count) {
34465 kfree(pte);
34466 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34467 index a5ffcc9..e057498 100644
34468 --- a/block/scsi_ioctl.c
34469 +++ b/block/scsi_ioctl.c
34470 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
34471 return put_user(0, p);
34472 }
34473
34474 -static int sg_get_timeout(struct request_queue *q)
34475 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
34476 {
34477 return jiffies_to_clock_t(q->sg_timeout);
34478 }
34479 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34480 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34481 struct sg_io_hdr *hdr, fmode_t mode)
34482 {
34483 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34484 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34485 + unsigned char *cmdptr;
34486 +
34487 + if (rq->cmd != rq->__cmd)
34488 + cmdptr = rq->cmd;
34489 + else
34490 + cmdptr = tmpcmd;
34491 +
34492 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34493 return -EFAULT;
34494 +
34495 + if (cmdptr != rq->cmd)
34496 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34497 +
34498 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34499 return -EPERM;
34500
34501 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34502 int err;
34503 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34504 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34505 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34506 + unsigned char *cmdptr;
34507
34508 if (!sic)
34509 return -EINVAL;
34510 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34511 */
34512 err = -EFAULT;
34513 rq->cmd_len = cmdlen;
34514 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34515 +
34516 + if (rq->cmd != rq->__cmd)
34517 + cmdptr = rq->cmd;
34518 + else
34519 + cmdptr = tmpcmd;
34520 +
34521 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34522 goto error;
34523
34524 + if (rq->cmd != cmdptr)
34525 + memcpy(rq->cmd, cmdptr, cmdlen);
34526 +
34527 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34528 goto error;
34529
34530 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34531 index 7bdd61b..afec999 100644
34532 --- a/crypto/cryptd.c
34533 +++ b/crypto/cryptd.c
34534 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34535
34536 struct cryptd_blkcipher_request_ctx {
34537 crypto_completion_t complete;
34538 -};
34539 +} __no_const;
34540
34541 struct cryptd_hash_ctx {
34542 struct crypto_shash *child;
34543 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34544
34545 struct cryptd_aead_request_ctx {
34546 crypto_completion_t complete;
34547 -};
34548 +} __no_const;
34549
34550 static void cryptd_queue_worker(struct work_struct *work);
34551
34552 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34553 index f8c920c..ab2cb5a 100644
34554 --- a/crypto/pcrypt.c
34555 +++ b/crypto/pcrypt.c
34556 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34557 int ret;
34558
34559 pinst->kobj.kset = pcrypt_kset;
34560 - ret = kobject_add(&pinst->kobj, NULL, name);
34561 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34562 if (!ret)
34563 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34564
34565 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34566 index f220d64..d359ad6 100644
34567 --- a/drivers/acpi/apei/apei-internal.h
34568 +++ b/drivers/acpi/apei/apei-internal.h
34569 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34570 struct apei_exec_ins_type {
34571 u32 flags;
34572 apei_exec_ins_func_t run;
34573 -};
34574 +} __do_const;
34575
34576 struct apei_exec_context {
34577 u32 ip;
34578 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34579 index 33dc6a0..4b24b47 100644
34580 --- a/drivers/acpi/apei/cper.c
34581 +++ b/drivers/acpi/apei/cper.c
34582 @@ -39,12 +39,12 @@
34583 */
34584 u64 cper_next_record_id(void)
34585 {
34586 - static atomic64_t seq;
34587 + static atomic64_unchecked_t seq;
34588
34589 - if (!atomic64_read(&seq))
34590 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34591 + if (!atomic64_read_unchecked(&seq))
34592 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34593
34594 - return atomic64_inc_return(&seq);
34595 + return atomic64_inc_return_unchecked(&seq);
34596 }
34597 EXPORT_SYMBOL_GPL(cper_next_record_id);
34598
34599 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34600 index 8ec37bb..b0716e5 100644
34601 --- a/drivers/acpi/apei/ghes.c
34602 +++ b/drivers/acpi/apei/ghes.c
34603 @@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
34604 const struct acpi_hest_generic *generic,
34605 const struct acpi_hest_generic_status *estatus)
34606 {
34607 - static atomic_t seqno;
34608 + static atomic_unchecked_t seqno;
34609 unsigned int curr_seqno;
34610 char pfx_seq[64];
34611
34612 @@ -509,7 +509,7 @@ static void __ghes_print_estatus(const char *pfx,
34613 else
34614 pfx = KERN_ERR;
34615 }
34616 - curr_seqno = atomic_inc_return(&seqno);
34617 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34618 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34619 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34620 pfx_seq, generic->header.source_id);
34621 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34622 index a83e3c6..c3d617f 100644
34623 --- a/drivers/acpi/bgrt.c
34624 +++ b/drivers/acpi/bgrt.c
34625 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
34626 if (!bgrt_image)
34627 return -ENODEV;
34628
34629 - bin_attr_image.private = bgrt_image;
34630 - bin_attr_image.size = bgrt_image_size;
34631 + pax_open_kernel();
34632 + *(void **)&bin_attr_image.private = bgrt_image;
34633 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
34634 + pax_close_kernel();
34635
34636 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34637 if (!bgrt_kobj)
34638 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34639 index 9515f18..4b149c9 100644
34640 --- a/drivers/acpi/blacklist.c
34641 +++ b/drivers/acpi/blacklist.c
34642 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34643 u32 is_critical_error;
34644 };
34645
34646 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34647 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34648
34649 /*
34650 * POLICY: If *anything* doesn't work, put it on the blacklist.
34651 @@ -199,7 +199,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
34652 return 0;
34653 }
34654
34655 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34656 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34657 {
34658 .callback = dmi_disable_osi_vista,
34659 .ident = "Fujitsu Siemens",
34660 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34661 index f98dd00..7b69865 100644
34662 --- a/drivers/acpi/processor_idle.c
34663 +++ b/drivers/acpi/processor_idle.c
34664 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34665 {
34666 int i, count = CPUIDLE_DRIVER_STATE_START;
34667 struct acpi_processor_cx *cx;
34668 - struct cpuidle_state *state;
34669 + cpuidle_state_no_const *state;
34670 struct cpuidle_driver *drv = &acpi_idle_driver;
34671
34672 if (!pr->flags.power_setup_done)
34673 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34674 index 05306a5..733d1f0 100644
34675 --- a/drivers/acpi/sysfs.c
34676 +++ b/drivers/acpi/sysfs.c
34677 @@ -423,11 +423,11 @@ static u32 num_counters;
34678 static struct attribute **all_attrs;
34679 static u32 acpi_gpe_count;
34680
34681 -static struct attribute_group interrupt_stats_attr_group = {
34682 +static attribute_group_no_const interrupt_stats_attr_group = {
34683 .name = "interrupts",
34684 };
34685
34686 -static struct kobj_attribute *counter_attrs;
34687 +static kobj_attribute_no_const *counter_attrs;
34688
34689 static void delete_gpe_attr_array(void)
34690 {
34691 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34692 index aaac4fb..e325c00 100644
34693 --- a/drivers/ata/libahci.c
34694 +++ b/drivers/ata/libahci.c
34695 @@ -1239,7 +1239,7 @@ int ahci_kick_engine(struct ata_port *ap)
34696 }
34697 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34698
34699 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34700 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34701 struct ata_taskfile *tf, int is_cmd, u16 flags,
34702 unsigned long timeout_msec)
34703 {
34704 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34705 index 83b1a9f..005b1ec 100644
34706 --- a/drivers/ata/libata-core.c
34707 +++ b/drivers/ata/libata-core.c
34708 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34709 static void ata_dev_xfermask(struct ata_device *dev);
34710 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34711
34712 -atomic_t ata_print_id = ATOMIC_INIT(0);
34713 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34714
34715 struct ata_force_param {
34716 const char *name;
34717 @@ -4808,7 +4808,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34718 struct ata_port *ap;
34719 unsigned int tag;
34720
34721 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34722 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34723 ap = qc->ap;
34724
34725 qc->flags = 0;
34726 @@ -4824,7 +4824,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34727 struct ata_port *ap;
34728 struct ata_link *link;
34729
34730 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34731 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34732 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34733 ap = qc->ap;
34734 link = qc->dev->link;
34735 @@ -5943,6 +5943,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34736 return;
34737
34738 spin_lock(&lock);
34739 + pax_open_kernel();
34740
34741 for (cur = ops->inherits; cur; cur = cur->inherits) {
34742 void **inherit = (void **)cur;
34743 @@ -5956,8 +5957,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34744 if (IS_ERR(*pp))
34745 *pp = NULL;
34746
34747 - ops->inherits = NULL;
34748 + *(struct ata_port_operations **)&ops->inherits = NULL;
34749
34750 + pax_close_kernel();
34751 spin_unlock(&lock);
34752 }
34753
34754 @@ -6150,7 +6152,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34755
34756 /* give ports names and add SCSI hosts */
34757 for (i = 0; i < host->n_ports; i++) {
34758 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34759 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34760 host->ports[i]->local_port_no = i + 1;
34761 }
34762
34763 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34764 index db6dfcf..770d1f0 100644
34765 --- a/drivers/ata/libata-scsi.c
34766 +++ b/drivers/ata/libata-scsi.c
34767 @@ -4113,7 +4113,7 @@ int ata_sas_port_init(struct ata_port *ap)
34768
34769 if (rc)
34770 return rc;
34771 - ap->print_id = atomic_inc_return(&ata_print_id);
34772 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34773 return 0;
34774 }
34775 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34776 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34777 index 45b5ab3..98446b8 100644
34778 --- a/drivers/ata/libata.h
34779 +++ b/drivers/ata/libata.h
34780 @@ -53,7 +53,7 @@ enum {
34781 ATA_DNXFER_QUIET = (1 << 31),
34782 };
34783
34784 -extern atomic_t ata_print_id;
34785 +extern atomic_unchecked_t ata_print_id;
34786 extern int atapi_passthru16;
34787 extern int libata_fua;
34788 extern int libata_noacpi;
34789 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34790 index 853f610..97d24da 100644
34791 --- a/drivers/ata/pata_arasan_cf.c
34792 +++ b/drivers/ata/pata_arasan_cf.c
34793 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34794 /* Handle platform specific quirks */
34795 if (quirk) {
34796 if (quirk & CF_BROKEN_PIO) {
34797 - ap->ops->set_piomode = NULL;
34798 + pax_open_kernel();
34799 + *(void **)&ap->ops->set_piomode = NULL;
34800 + pax_close_kernel();
34801 ap->pio_mask = 0;
34802 }
34803 if (quirk & CF_BROKEN_MWDMA)
34804 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34805 index f9b983a..887b9d8 100644
34806 --- a/drivers/atm/adummy.c
34807 +++ b/drivers/atm/adummy.c
34808 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34809 vcc->pop(vcc, skb);
34810 else
34811 dev_kfree_skb_any(skb);
34812 - atomic_inc(&vcc->stats->tx);
34813 + atomic_inc_unchecked(&vcc->stats->tx);
34814
34815 return 0;
34816 }
34817 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34818 index 62a7607..cc4be104 100644
34819 --- a/drivers/atm/ambassador.c
34820 +++ b/drivers/atm/ambassador.c
34821 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34822 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34823
34824 // VC layer stats
34825 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34826 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34827
34828 // free the descriptor
34829 kfree (tx_descr);
34830 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34831 dump_skb ("<<<", vc, skb);
34832
34833 // VC layer stats
34834 - atomic_inc(&atm_vcc->stats->rx);
34835 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34836 __net_timestamp(skb);
34837 // end of our responsibility
34838 atm_vcc->push (atm_vcc, skb);
34839 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34840 } else {
34841 PRINTK (KERN_INFO, "dropped over-size frame");
34842 // should we count this?
34843 - atomic_inc(&atm_vcc->stats->rx_drop);
34844 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34845 }
34846
34847 } else {
34848 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34849 }
34850
34851 if (check_area (skb->data, skb->len)) {
34852 - atomic_inc(&atm_vcc->stats->tx_err);
34853 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34854 return -ENOMEM; // ?
34855 }
34856
34857 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34858 index 0e3f8f9..765a7a5 100644
34859 --- a/drivers/atm/atmtcp.c
34860 +++ b/drivers/atm/atmtcp.c
34861 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34862 if (vcc->pop) vcc->pop(vcc,skb);
34863 else dev_kfree_skb(skb);
34864 if (dev_data) return 0;
34865 - atomic_inc(&vcc->stats->tx_err);
34866 + atomic_inc_unchecked(&vcc->stats->tx_err);
34867 return -ENOLINK;
34868 }
34869 size = skb->len+sizeof(struct atmtcp_hdr);
34870 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34871 if (!new_skb) {
34872 if (vcc->pop) vcc->pop(vcc,skb);
34873 else dev_kfree_skb(skb);
34874 - atomic_inc(&vcc->stats->tx_err);
34875 + atomic_inc_unchecked(&vcc->stats->tx_err);
34876 return -ENOBUFS;
34877 }
34878 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34879 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34880 if (vcc->pop) vcc->pop(vcc,skb);
34881 else dev_kfree_skb(skb);
34882 out_vcc->push(out_vcc,new_skb);
34883 - atomic_inc(&vcc->stats->tx);
34884 - atomic_inc(&out_vcc->stats->rx);
34885 + atomic_inc_unchecked(&vcc->stats->tx);
34886 + atomic_inc_unchecked(&out_vcc->stats->rx);
34887 return 0;
34888 }
34889
34890 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34891 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34892 read_unlock(&vcc_sklist_lock);
34893 if (!out_vcc) {
34894 - atomic_inc(&vcc->stats->tx_err);
34895 + atomic_inc_unchecked(&vcc->stats->tx_err);
34896 goto done;
34897 }
34898 skb_pull(skb,sizeof(struct atmtcp_hdr));
34899 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34900 __net_timestamp(new_skb);
34901 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34902 out_vcc->push(out_vcc,new_skb);
34903 - atomic_inc(&vcc->stats->tx);
34904 - atomic_inc(&out_vcc->stats->rx);
34905 + atomic_inc_unchecked(&vcc->stats->tx);
34906 + atomic_inc_unchecked(&out_vcc->stats->rx);
34907 done:
34908 if (vcc->pop) vcc->pop(vcc,skb);
34909 else dev_kfree_skb(skb);
34910 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34911 index b1955ba..b179940 100644
34912 --- a/drivers/atm/eni.c
34913 +++ b/drivers/atm/eni.c
34914 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34915 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34916 vcc->dev->number);
34917 length = 0;
34918 - atomic_inc(&vcc->stats->rx_err);
34919 + atomic_inc_unchecked(&vcc->stats->rx_err);
34920 }
34921 else {
34922 length = ATM_CELL_SIZE-1; /* no HEC */
34923 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34924 size);
34925 }
34926 eff = length = 0;
34927 - atomic_inc(&vcc->stats->rx_err);
34928 + atomic_inc_unchecked(&vcc->stats->rx_err);
34929 }
34930 else {
34931 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34932 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34933 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34934 vcc->dev->number,vcc->vci,length,size << 2,descr);
34935 length = eff = 0;
34936 - atomic_inc(&vcc->stats->rx_err);
34937 + atomic_inc_unchecked(&vcc->stats->rx_err);
34938 }
34939 }
34940 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34941 @@ -767,7 +767,7 @@ rx_dequeued++;
34942 vcc->push(vcc,skb);
34943 pushed++;
34944 }
34945 - atomic_inc(&vcc->stats->rx);
34946 + atomic_inc_unchecked(&vcc->stats->rx);
34947 }
34948 wake_up(&eni_dev->rx_wait);
34949 }
34950 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34951 PCI_DMA_TODEVICE);
34952 if (vcc->pop) vcc->pop(vcc,skb);
34953 else dev_kfree_skb_irq(skb);
34954 - atomic_inc(&vcc->stats->tx);
34955 + atomic_inc_unchecked(&vcc->stats->tx);
34956 wake_up(&eni_dev->tx_wait);
34957 dma_complete++;
34958 }
34959 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34960 index b41c948..a002b17 100644
34961 --- a/drivers/atm/firestream.c
34962 +++ b/drivers/atm/firestream.c
34963 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34964 }
34965 }
34966
34967 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34968 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34969
34970 fs_dprintk (FS_DEBUG_TXMEM, "i");
34971 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34972 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34973 #endif
34974 skb_put (skb, qe->p1 & 0xffff);
34975 ATM_SKB(skb)->vcc = atm_vcc;
34976 - atomic_inc(&atm_vcc->stats->rx);
34977 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34978 __net_timestamp(skb);
34979 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34980 atm_vcc->push (atm_vcc, skb);
34981 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34982 kfree (pe);
34983 }
34984 if (atm_vcc)
34985 - atomic_inc(&atm_vcc->stats->rx_drop);
34986 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34987 break;
34988 case 0x1f: /* Reassembly abort: no buffers. */
34989 /* Silently increment error counter. */
34990 if (atm_vcc)
34991 - atomic_inc(&atm_vcc->stats->rx_drop);
34992 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34993 break;
34994 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34995 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34996 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34997 index 204814e..cede831 100644
34998 --- a/drivers/atm/fore200e.c
34999 +++ b/drivers/atm/fore200e.c
35000 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35001 #endif
35002 /* check error condition */
35003 if (*entry->status & STATUS_ERROR)
35004 - atomic_inc(&vcc->stats->tx_err);
35005 + atomic_inc_unchecked(&vcc->stats->tx_err);
35006 else
35007 - atomic_inc(&vcc->stats->tx);
35008 + atomic_inc_unchecked(&vcc->stats->tx);
35009 }
35010 }
35011
35012 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35013 if (skb == NULL) {
35014 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35015
35016 - atomic_inc(&vcc->stats->rx_drop);
35017 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35018 return -ENOMEM;
35019 }
35020
35021 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35022
35023 dev_kfree_skb_any(skb);
35024
35025 - atomic_inc(&vcc->stats->rx_drop);
35026 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35027 return -ENOMEM;
35028 }
35029
35030 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35031
35032 vcc->push(vcc, skb);
35033 - atomic_inc(&vcc->stats->rx);
35034 + atomic_inc_unchecked(&vcc->stats->rx);
35035
35036 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35037
35038 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35039 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35040 fore200e->atm_dev->number,
35041 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35042 - atomic_inc(&vcc->stats->rx_err);
35043 + atomic_inc_unchecked(&vcc->stats->rx_err);
35044 }
35045 }
35046
35047 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35048 goto retry_here;
35049 }
35050
35051 - atomic_inc(&vcc->stats->tx_err);
35052 + atomic_inc_unchecked(&vcc->stats->tx_err);
35053
35054 fore200e->tx_sat++;
35055 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35056 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35057 index 8557adc..3fb5d55 100644
35058 --- a/drivers/atm/he.c
35059 +++ b/drivers/atm/he.c
35060 @@ -1691,7 +1691,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35061
35062 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35063 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35064 - atomic_inc(&vcc->stats->rx_drop);
35065 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35066 goto return_host_buffers;
35067 }
35068
35069 @@ -1718,7 +1718,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35070 RBRQ_LEN_ERR(he_dev->rbrq_head)
35071 ? "LEN_ERR" : "",
35072 vcc->vpi, vcc->vci);
35073 - atomic_inc(&vcc->stats->rx_err);
35074 + atomic_inc_unchecked(&vcc->stats->rx_err);
35075 goto return_host_buffers;
35076 }
35077
35078 @@ -1770,7 +1770,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35079 vcc->push(vcc, skb);
35080 spin_lock(&he_dev->global_lock);
35081
35082 - atomic_inc(&vcc->stats->rx);
35083 + atomic_inc_unchecked(&vcc->stats->rx);
35084
35085 return_host_buffers:
35086 ++pdus_assembled;
35087 @@ -2096,7 +2096,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35088 tpd->vcc->pop(tpd->vcc, tpd->skb);
35089 else
35090 dev_kfree_skb_any(tpd->skb);
35091 - atomic_inc(&tpd->vcc->stats->tx_err);
35092 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35093 }
35094 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35095 return;
35096 @@ -2508,7 +2508,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35097 vcc->pop(vcc, skb);
35098 else
35099 dev_kfree_skb_any(skb);
35100 - atomic_inc(&vcc->stats->tx_err);
35101 + atomic_inc_unchecked(&vcc->stats->tx_err);
35102 return -EINVAL;
35103 }
35104
35105 @@ -2519,7 +2519,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35106 vcc->pop(vcc, skb);
35107 else
35108 dev_kfree_skb_any(skb);
35109 - atomic_inc(&vcc->stats->tx_err);
35110 + atomic_inc_unchecked(&vcc->stats->tx_err);
35111 return -EINVAL;
35112 }
35113 #endif
35114 @@ -2531,7 +2531,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35115 vcc->pop(vcc, skb);
35116 else
35117 dev_kfree_skb_any(skb);
35118 - atomic_inc(&vcc->stats->tx_err);
35119 + atomic_inc_unchecked(&vcc->stats->tx_err);
35120 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35121 return -ENOMEM;
35122 }
35123 @@ -2573,7 +2573,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35124 vcc->pop(vcc, skb);
35125 else
35126 dev_kfree_skb_any(skb);
35127 - atomic_inc(&vcc->stats->tx_err);
35128 + atomic_inc_unchecked(&vcc->stats->tx_err);
35129 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35130 return -ENOMEM;
35131 }
35132 @@ -2604,7 +2604,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35133 __enqueue_tpd(he_dev, tpd, cid);
35134 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35135
35136 - atomic_inc(&vcc->stats->tx);
35137 + atomic_inc_unchecked(&vcc->stats->tx);
35138
35139 return 0;
35140 }
35141 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35142 index 1dc0519..1aadaf7 100644
35143 --- a/drivers/atm/horizon.c
35144 +++ b/drivers/atm/horizon.c
35145 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35146 {
35147 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35148 // VC layer stats
35149 - atomic_inc(&vcc->stats->rx);
35150 + atomic_inc_unchecked(&vcc->stats->rx);
35151 __net_timestamp(skb);
35152 // end of our responsibility
35153 vcc->push (vcc, skb);
35154 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35155 dev->tx_iovec = NULL;
35156
35157 // VC layer stats
35158 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35159 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35160
35161 // free the skb
35162 hrz_kfree_skb (skb);
35163 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35164 index 272f009..a18ba55 100644
35165 --- a/drivers/atm/idt77252.c
35166 +++ b/drivers/atm/idt77252.c
35167 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35168 else
35169 dev_kfree_skb(skb);
35170
35171 - atomic_inc(&vcc->stats->tx);
35172 + atomic_inc_unchecked(&vcc->stats->tx);
35173 }
35174
35175 atomic_dec(&scq->used);
35176 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35177 if ((sb = dev_alloc_skb(64)) == NULL) {
35178 printk("%s: Can't allocate buffers for aal0.\n",
35179 card->name);
35180 - atomic_add(i, &vcc->stats->rx_drop);
35181 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35182 break;
35183 }
35184 if (!atm_charge(vcc, sb->truesize)) {
35185 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35186 card->name);
35187 - atomic_add(i - 1, &vcc->stats->rx_drop);
35188 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35189 dev_kfree_skb(sb);
35190 break;
35191 }
35192 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35193 ATM_SKB(sb)->vcc = vcc;
35194 __net_timestamp(sb);
35195 vcc->push(vcc, sb);
35196 - atomic_inc(&vcc->stats->rx);
35197 + atomic_inc_unchecked(&vcc->stats->rx);
35198
35199 cell += ATM_CELL_PAYLOAD;
35200 }
35201 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35202 "(CDC: %08x)\n",
35203 card->name, len, rpp->len, readl(SAR_REG_CDC));
35204 recycle_rx_pool_skb(card, rpp);
35205 - atomic_inc(&vcc->stats->rx_err);
35206 + atomic_inc_unchecked(&vcc->stats->rx_err);
35207 return;
35208 }
35209 if (stat & SAR_RSQE_CRC) {
35210 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35211 recycle_rx_pool_skb(card, rpp);
35212 - atomic_inc(&vcc->stats->rx_err);
35213 + atomic_inc_unchecked(&vcc->stats->rx_err);
35214 return;
35215 }
35216 if (skb_queue_len(&rpp->queue) > 1) {
35217 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35218 RXPRINTK("%s: Can't alloc RX skb.\n",
35219 card->name);
35220 recycle_rx_pool_skb(card, rpp);
35221 - atomic_inc(&vcc->stats->rx_err);
35222 + atomic_inc_unchecked(&vcc->stats->rx_err);
35223 return;
35224 }
35225 if (!atm_charge(vcc, skb->truesize)) {
35226 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35227 __net_timestamp(skb);
35228
35229 vcc->push(vcc, skb);
35230 - atomic_inc(&vcc->stats->rx);
35231 + atomic_inc_unchecked(&vcc->stats->rx);
35232
35233 return;
35234 }
35235 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35236 __net_timestamp(skb);
35237
35238 vcc->push(vcc, skb);
35239 - atomic_inc(&vcc->stats->rx);
35240 + atomic_inc_unchecked(&vcc->stats->rx);
35241
35242 if (skb->truesize > SAR_FB_SIZE_3)
35243 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35244 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35245 if (vcc->qos.aal != ATM_AAL0) {
35246 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35247 card->name, vpi, vci);
35248 - atomic_inc(&vcc->stats->rx_drop);
35249 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35250 goto drop;
35251 }
35252
35253 if ((sb = dev_alloc_skb(64)) == NULL) {
35254 printk("%s: Can't allocate buffers for AAL0.\n",
35255 card->name);
35256 - atomic_inc(&vcc->stats->rx_err);
35257 + atomic_inc_unchecked(&vcc->stats->rx_err);
35258 goto drop;
35259 }
35260
35261 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35262 ATM_SKB(sb)->vcc = vcc;
35263 __net_timestamp(sb);
35264 vcc->push(vcc, sb);
35265 - atomic_inc(&vcc->stats->rx);
35266 + atomic_inc_unchecked(&vcc->stats->rx);
35267
35268 drop:
35269 skb_pull(queue, 64);
35270 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35271
35272 if (vc == NULL) {
35273 printk("%s: NULL connection in send().\n", card->name);
35274 - atomic_inc(&vcc->stats->tx_err);
35275 + atomic_inc_unchecked(&vcc->stats->tx_err);
35276 dev_kfree_skb(skb);
35277 return -EINVAL;
35278 }
35279 if (!test_bit(VCF_TX, &vc->flags)) {
35280 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35281 - atomic_inc(&vcc->stats->tx_err);
35282 + atomic_inc_unchecked(&vcc->stats->tx_err);
35283 dev_kfree_skb(skb);
35284 return -EINVAL;
35285 }
35286 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35287 break;
35288 default:
35289 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35290 - atomic_inc(&vcc->stats->tx_err);
35291 + atomic_inc_unchecked(&vcc->stats->tx_err);
35292 dev_kfree_skb(skb);
35293 return -EINVAL;
35294 }
35295
35296 if (skb_shinfo(skb)->nr_frags != 0) {
35297 printk("%s: No scatter-gather yet.\n", card->name);
35298 - atomic_inc(&vcc->stats->tx_err);
35299 + atomic_inc_unchecked(&vcc->stats->tx_err);
35300 dev_kfree_skb(skb);
35301 return -EINVAL;
35302 }
35303 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35304
35305 err = queue_skb(card, vc, skb, oam);
35306 if (err) {
35307 - atomic_inc(&vcc->stats->tx_err);
35308 + atomic_inc_unchecked(&vcc->stats->tx_err);
35309 dev_kfree_skb(skb);
35310 return err;
35311 }
35312 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35313 skb = dev_alloc_skb(64);
35314 if (!skb) {
35315 printk("%s: Out of memory in send_oam().\n", card->name);
35316 - atomic_inc(&vcc->stats->tx_err);
35317 + atomic_inc_unchecked(&vcc->stats->tx_err);
35318 return -ENOMEM;
35319 }
35320 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35321 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35322 index 4217f29..88f547a 100644
35323 --- a/drivers/atm/iphase.c
35324 +++ b/drivers/atm/iphase.c
35325 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35326 status = (u_short) (buf_desc_ptr->desc_mode);
35327 if (status & (RX_CER | RX_PTE | RX_OFL))
35328 {
35329 - atomic_inc(&vcc->stats->rx_err);
35330 + atomic_inc_unchecked(&vcc->stats->rx_err);
35331 IF_ERR(printk("IA: bad packet, dropping it");)
35332 if (status & RX_CER) {
35333 IF_ERR(printk(" cause: packet CRC error\n");)
35334 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35335 len = dma_addr - buf_addr;
35336 if (len > iadev->rx_buf_sz) {
35337 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35338 - atomic_inc(&vcc->stats->rx_err);
35339 + atomic_inc_unchecked(&vcc->stats->rx_err);
35340 goto out_free_desc;
35341 }
35342
35343 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35344 ia_vcc = INPH_IA_VCC(vcc);
35345 if (ia_vcc == NULL)
35346 {
35347 - atomic_inc(&vcc->stats->rx_err);
35348 + atomic_inc_unchecked(&vcc->stats->rx_err);
35349 atm_return(vcc, skb->truesize);
35350 dev_kfree_skb_any(skb);
35351 goto INCR_DLE;
35352 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35353 if ((length > iadev->rx_buf_sz) || (length >
35354 (skb->len - sizeof(struct cpcs_trailer))))
35355 {
35356 - atomic_inc(&vcc->stats->rx_err);
35357 + atomic_inc_unchecked(&vcc->stats->rx_err);
35358 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35359 length, skb->len);)
35360 atm_return(vcc, skb->truesize);
35361 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35362
35363 IF_RX(printk("rx_dle_intr: skb push");)
35364 vcc->push(vcc,skb);
35365 - atomic_inc(&vcc->stats->rx);
35366 + atomic_inc_unchecked(&vcc->stats->rx);
35367 iadev->rx_pkt_cnt++;
35368 }
35369 INCR_DLE:
35370 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35371 {
35372 struct k_sonet_stats *stats;
35373 stats = &PRIV(_ia_dev[board])->sonet_stats;
35374 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35375 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35376 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35377 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35378 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35379 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35380 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35381 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35382 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35383 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35384 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35385 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35386 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35387 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35388 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35389 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35390 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35391 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35392 }
35393 ia_cmds.status = 0;
35394 break;
35395 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35396 if ((desc == 0) || (desc > iadev->num_tx_desc))
35397 {
35398 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35399 - atomic_inc(&vcc->stats->tx);
35400 + atomic_inc_unchecked(&vcc->stats->tx);
35401 if (vcc->pop)
35402 vcc->pop(vcc, skb);
35403 else
35404 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35405 ATM_DESC(skb) = vcc->vci;
35406 skb_queue_tail(&iadev->tx_dma_q, skb);
35407
35408 - atomic_inc(&vcc->stats->tx);
35409 + atomic_inc_unchecked(&vcc->stats->tx);
35410 iadev->tx_pkt_cnt++;
35411 /* Increment transaction counter */
35412 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35413
35414 #if 0
35415 /* add flow control logic */
35416 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35417 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35418 if (iavcc->vc_desc_cnt > 10) {
35419 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35420 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35421 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35422 index fa7d701..1e404c7 100644
35423 --- a/drivers/atm/lanai.c
35424 +++ b/drivers/atm/lanai.c
35425 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35426 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35427 lanai_endtx(lanai, lvcc);
35428 lanai_free_skb(lvcc->tx.atmvcc, skb);
35429 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35430 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35431 }
35432
35433 /* Try to fill the buffer - don't call unless there is backlog */
35434 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35435 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35436 __net_timestamp(skb);
35437 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35438 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35439 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35440 out:
35441 lvcc->rx.buf.ptr = end;
35442 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35443 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35444 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35445 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35446 lanai->stats.service_rxnotaal5++;
35447 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35448 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35449 return 0;
35450 }
35451 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35452 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35453 int bytes;
35454 read_unlock(&vcc_sklist_lock);
35455 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35456 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35457 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35458 lvcc->stats.x.aal5.service_trash++;
35459 bytes = (SERVICE_GET_END(s) * 16) -
35460 (((unsigned long) lvcc->rx.buf.ptr) -
35461 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35462 }
35463 if (s & SERVICE_STREAM) {
35464 read_unlock(&vcc_sklist_lock);
35465 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35466 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35467 lvcc->stats.x.aal5.service_stream++;
35468 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35469 "PDU on VCI %d!\n", lanai->number, vci);
35470 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35471 return 0;
35472 }
35473 DPRINTK("got rx crc error on vci %d\n", vci);
35474 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35475 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35476 lvcc->stats.x.aal5.service_rxcrc++;
35477 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35478 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35479 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35480 index 5aca5f4..ce3a6b0 100644
35481 --- a/drivers/atm/nicstar.c
35482 +++ b/drivers/atm/nicstar.c
35483 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35484 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35485 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35486 card->index);
35487 - atomic_inc(&vcc->stats->tx_err);
35488 + atomic_inc_unchecked(&vcc->stats->tx_err);
35489 dev_kfree_skb_any(skb);
35490 return -EINVAL;
35491 }
35492 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35493 if (!vc->tx) {
35494 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35495 card->index);
35496 - atomic_inc(&vcc->stats->tx_err);
35497 + atomic_inc_unchecked(&vcc->stats->tx_err);
35498 dev_kfree_skb_any(skb);
35499 return -EINVAL;
35500 }
35501 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35502 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35503 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35504 card->index);
35505 - atomic_inc(&vcc->stats->tx_err);
35506 + atomic_inc_unchecked(&vcc->stats->tx_err);
35507 dev_kfree_skb_any(skb);
35508 return -EINVAL;
35509 }
35510
35511 if (skb_shinfo(skb)->nr_frags != 0) {
35512 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35513 - atomic_inc(&vcc->stats->tx_err);
35514 + atomic_inc_unchecked(&vcc->stats->tx_err);
35515 dev_kfree_skb_any(skb);
35516 return -EINVAL;
35517 }
35518 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35519 }
35520
35521 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35522 - atomic_inc(&vcc->stats->tx_err);
35523 + atomic_inc_unchecked(&vcc->stats->tx_err);
35524 dev_kfree_skb_any(skb);
35525 return -EIO;
35526 }
35527 - atomic_inc(&vcc->stats->tx);
35528 + atomic_inc_unchecked(&vcc->stats->tx);
35529
35530 return 0;
35531 }
35532 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35533 printk
35534 ("nicstar%d: Can't allocate buffers for aal0.\n",
35535 card->index);
35536 - atomic_add(i, &vcc->stats->rx_drop);
35537 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35538 break;
35539 }
35540 if (!atm_charge(vcc, sb->truesize)) {
35541 RXPRINTK
35542 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35543 card->index);
35544 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35545 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35546 dev_kfree_skb_any(sb);
35547 break;
35548 }
35549 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35550 ATM_SKB(sb)->vcc = vcc;
35551 __net_timestamp(sb);
35552 vcc->push(vcc, sb);
35553 - atomic_inc(&vcc->stats->rx);
35554 + atomic_inc_unchecked(&vcc->stats->rx);
35555 cell += ATM_CELL_PAYLOAD;
35556 }
35557
35558 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35559 if (iovb == NULL) {
35560 printk("nicstar%d: Out of iovec buffers.\n",
35561 card->index);
35562 - atomic_inc(&vcc->stats->rx_drop);
35563 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35564 recycle_rx_buf(card, skb);
35565 return;
35566 }
35567 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35568 small or large buffer itself. */
35569 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35570 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35571 - atomic_inc(&vcc->stats->rx_err);
35572 + atomic_inc_unchecked(&vcc->stats->rx_err);
35573 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35574 NS_MAX_IOVECS);
35575 NS_PRV_IOVCNT(iovb) = 0;
35576 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35577 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35578 card->index);
35579 which_list(card, skb);
35580 - atomic_inc(&vcc->stats->rx_err);
35581 + atomic_inc_unchecked(&vcc->stats->rx_err);
35582 recycle_rx_buf(card, skb);
35583 vc->rx_iov = NULL;
35584 recycle_iov_buf(card, iovb);
35585 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35586 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35587 card->index);
35588 which_list(card, skb);
35589 - atomic_inc(&vcc->stats->rx_err);
35590 + atomic_inc_unchecked(&vcc->stats->rx_err);
35591 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35592 NS_PRV_IOVCNT(iovb));
35593 vc->rx_iov = NULL;
35594 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35595 printk(" - PDU size mismatch.\n");
35596 else
35597 printk(".\n");
35598 - atomic_inc(&vcc->stats->rx_err);
35599 + atomic_inc_unchecked(&vcc->stats->rx_err);
35600 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35601 NS_PRV_IOVCNT(iovb));
35602 vc->rx_iov = NULL;
35603 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35604 /* skb points to a small buffer */
35605 if (!atm_charge(vcc, skb->truesize)) {
35606 push_rxbufs(card, skb);
35607 - atomic_inc(&vcc->stats->rx_drop);
35608 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35609 } else {
35610 skb_put(skb, len);
35611 dequeue_sm_buf(card, skb);
35612 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35613 ATM_SKB(skb)->vcc = vcc;
35614 __net_timestamp(skb);
35615 vcc->push(vcc, skb);
35616 - atomic_inc(&vcc->stats->rx);
35617 + atomic_inc_unchecked(&vcc->stats->rx);
35618 }
35619 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35620 struct sk_buff *sb;
35621 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35622 if (len <= NS_SMBUFSIZE) {
35623 if (!atm_charge(vcc, sb->truesize)) {
35624 push_rxbufs(card, sb);
35625 - atomic_inc(&vcc->stats->rx_drop);
35626 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35627 } else {
35628 skb_put(sb, len);
35629 dequeue_sm_buf(card, sb);
35630 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35631 ATM_SKB(sb)->vcc = vcc;
35632 __net_timestamp(sb);
35633 vcc->push(vcc, sb);
35634 - atomic_inc(&vcc->stats->rx);
35635 + atomic_inc_unchecked(&vcc->stats->rx);
35636 }
35637
35638 push_rxbufs(card, skb);
35639 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35640
35641 if (!atm_charge(vcc, skb->truesize)) {
35642 push_rxbufs(card, skb);
35643 - atomic_inc(&vcc->stats->rx_drop);
35644 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35645 } else {
35646 dequeue_lg_buf(card, skb);
35647 #ifdef NS_USE_DESTRUCTORS
35648 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35649 ATM_SKB(skb)->vcc = vcc;
35650 __net_timestamp(skb);
35651 vcc->push(vcc, skb);
35652 - atomic_inc(&vcc->stats->rx);
35653 + atomic_inc_unchecked(&vcc->stats->rx);
35654 }
35655
35656 push_rxbufs(card, sb);
35657 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35658 printk
35659 ("nicstar%d: Out of huge buffers.\n",
35660 card->index);
35661 - atomic_inc(&vcc->stats->rx_drop);
35662 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35663 recycle_iovec_rx_bufs(card,
35664 (struct iovec *)
35665 iovb->data,
35666 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35667 card->hbpool.count++;
35668 } else
35669 dev_kfree_skb_any(hb);
35670 - atomic_inc(&vcc->stats->rx_drop);
35671 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35672 } else {
35673 /* Copy the small buffer to the huge buffer */
35674 sb = (struct sk_buff *)iov->iov_base;
35675 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35676 #endif /* NS_USE_DESTRUCTORS */
35677 __net_timestamp(hb);
35678 vcc->push(vcc, hb);
35679 - atomic_inc(&vcc->stats->rx);
35680 + atomic_inc_unchecked(&vcc->stats->rx);
35681 }
35682 }
35683
35684 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35685 index 32784d1..4a8434a 100644
35686 --- a/drivers/atm/solos-pci.c
35687 +++ b/drivers/atm/solos-pci.c
35688 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35689 }
35690 atm_charge(vcc, skb->truesize);
35691 vcc->push(vcc, skb);
35692 - atomic_inc(&vcc->stats->rx);
35693 + atomic_inc_unchecked(&vcc->stats->rx);
35694 break;
35695
35696 case PKT_STATUS:
35697 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35698 vcc = SKB_CB(oldskb)->vcc;
35699
35700 if (vcc) {
35701 - atomic_inc(&vcc->stats->tx);
35702 + atomic_inc_unchecked(&vcc->stats->tx);
35703 solos_pop(vcc, oldskb);
35704 } else {
35705 dev_kfree_skb_irq(oldskb);
35706 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35707 index 0215934..ce9f5b1 100644
35708 --- a/drivers/atm/suni.c
35709 +++ b/drivers/atm/suni.c
35710 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35711
35712
35713 #define ADD_LIMITED(s,v) \
35714 - atomic_add((v),&stats->s); \
35715 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35716 + atomic_add_unchecked((v),&stats->s); \
35717 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35718
35719
35720 static void suni_hz(unsigned long from_timer)
35721 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35722 index 5120a96..e2572bd 100644
35723 --- a/drivers/atm/uPD98402.c
35724 +++ b/drivers/atm/uPD98402.c
35725 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35726 struct sonet_stats tmp;
35727 int error = 0;
35728
35729 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35730 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35731 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35732 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35733 if (zero && !error) {
35734 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35735
35736
35737 #define ADD_LIMITED(s,v) \
35738 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35739 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35740 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35741 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35742 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35743 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35744
35745
35746 static void stat_event(struct atm_dev *dev)
35747 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35748 if (reason & uPD98402_INT_PFM) stat_event(dev);
35749 if (reason & uPD98402_INT_PCO) {
35750 (void) GET(PCOCR); /* clear interrupt cause */
35751 - atomic_add(GET(HECCT),
35752 + atomic_add_unchecked(GET(HECCT),
35753 &PRIV(dev)->sonet_stats.uncorr_hcs);
35754 }
35755 if ((reason & uPD98402_INT_RFO) &&
35756 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35757 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35758 uPD98402_INT_LOS),PIMR); /* enable them */
35759 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35760 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35761 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35762 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35763 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35764 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35765 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35766 return 0;
35767 }
35768
35769 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35770 index 969c3c2..9b72956 100644
35771 --- a/drivers/atm/zatm.c
35772 +++ b/drivers/atm/zatm.c
35773 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35774 }
35775 if (!size) {
35776 dev_kfree_skb_irq(skb);
35777 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35778 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35779 continue;
35780 }
35781 if (!atm_charge(vcc,skb->truesize)) {
35782 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35783 skb->len = size;
35784 ATM_SKB(skb)->vcc = vcc;
35785 vcc->push(vcc,skb);
35786 - atomic_inc(&vcc->stats->rx);
35787 + atomic_inc_unchecked(&vcc->stats->rx);
35788 }
35789 zout(pos & 0xffff,MTA(mbx));
35790 #if 0 /* probably a stupid idea */
35791 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35792 skb_queue_head(&zatm_vcc->backlog,skb);
35793 break;
35794 }
35795 - atomic_inc(&vcc->stats->tx);
35796 + atomic_inc_unchecked(&vcc->stats->tx);
35797 wake_up(&zatm_vcc->tx_wait);
35798 }
35799
35800 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35801 index 4c289ab..de1c333 100644
35802 --- a/drivers/base/bus.c
35803 +++ b/drivers/base/bus.c
35804 @@ -1193,7 +1193,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35805 return -EINVAL;
35806
35807 mutex_lock(&subsys->p->mutex);
35808 - list_add_tail(&sif->node, &subsys->p->interfaces);
35809 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35810 if (sif->add_dev) {
35811 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35812 while ((dev = subsys_dev_iter_next(&iter)))
35813 @@ -1218,7 +1218,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35814 subsys = sif->subsys;
35815
35816 mutex_lock(&subsys->p->mutex);
35817 - list_del_init(&sif->node);
35818 + pax_list_del_init((struct list_head *)&sif->node);
35819 if (sif->remove_dev) {
35820 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35821 while ((dev = subsys_dev_iter_next(&iter)))
35822 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35823 index 7413d06..79155fa 100644
35824 --- a/drivers/base/devtmpfs.c
35825 +++ b/drivers/base/devtmpfs.c
35826 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35827 if (!thread)
35828 return 0;
35829
35830 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35831 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35832 if (err)
35833 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35834 else
35835 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35836 *err = sys_unshare(CLONE_NEWNS);
35837 if (*err)
35838 goto out;
35839 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35840 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35841 if (*err)
35842 goto out;
35843 - sys_chdir("/.."); /* will traverse into overmounted root */
35844 - sys_chroot(".");
35845 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35846 + sys_chroot((char __force_user *)".");
35847 complete(&setup_done);
35848 while (1) {
35849 spin_lock(&req_lock);
35850 diff --git a/drivers/base/node.c b/drivers/base/node.c
35851 index bc9f43b..29703b8 100644
35852 --- a/drivers/base/node.c
35853 +++ b/drivers/base/node.c
35854 @@ -620,7 +620,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35855 struct node_attr {
35856 struct device_attribute attr;
35857 enum node_states state;
35858 -};
35859 +} __do_const;
35860
35861 static ssize_t show_node_state(struct device *dev,
35862 struct device_attribute *attr, char *buf)
35863 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35864 index bfb8955..42c9b9a 100644
35865 --- a/drivers/base/power/domain.c
35866 +++ b/drivers/base/power/domain.c
35867 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35868 {
35869 struct cpuidle_driver *cpuidle_drv;
35870 struct gpd_cpu_data *cpu_data;
35871 - struct cpuidle_state *idle_state;
35872 + cpuidle_state_no_const *idle_state;
35873 int ret = 0;
35874
35875 if (IS_ERR_OR_NULL(genpd) || state < 0)
35876 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35877 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35878 {
35879 struct gpd_cpu_data *cpu_data;
35880 - struct cpuidle_state *idle_state;
35881 + cpuidle_state_no_const *idle_state;
35882 int ret = 0;
35883
35884 if (IS_ERR_OR_NULL(genpd))
35885 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35886 index 03e089a..0e9560c 100644
35887 --- a/drivers/base/power/sysfs.c
35888 +++ b/drivers/base/power/sysfs.c
35889 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35890 return -EIO;
35891 }
35892 }
35893 - return sprintf(buf, p);
35894 + return sprintf(buf, "%s", p);
35895 }
35896
35897 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35898 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35899 index 2d56f41..8830f19 100644
35900 --- a/drivers/base/power/wakeup.c
35901 +++ b/drivers/base/power/wakeup.c
35902 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35903 * They need to be modified together atomically, so it's better to use one
35904 * atomic variable to hold them both.
35905 */
35906 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35907 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35908
35909 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35910 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35911
35912 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35913 {
35914 - unsigned int comb = atomic_read(&combined_event_count);
35915 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35916
35917 *cnt = (comb >> IN_PROGRESS_BITS);
35918 *inpr = comb & MAX_IN_PROGRESS;
35919 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35920 ws->start_prevent_time = ws->last_time;
35921
35922 /* Increment the counter of events in progress. */
35923 - cec = atomic_inc_return(&combined_event_count);
35924 + cec = atomic_inc_return_unchecked(&combined_event_count);
35925
35926 trace_wakeup_source_activate(ws->name, cec);
35927 }
35928 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35929 * Increment the counter of registered wakeup events and decrement the
35930 * couter of wakeup events in progress simultaneously.
35931 */
35932 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35933 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35934 trace_wakeup_source_deactivate(ws->name, cec);
35935
35936 split_counters(&cnt, &inpr);
35937 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35938 index e8d11b6..7b1b36f 100644
35939 --- a/drivers/base/syscore.c
35940 +++ b/drivers/base/syscore.c
35941 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35942 void register_syscore_ops(struct syscore_ops *ops)
35943 {
35944 mutex_lock(&syscore_ops_lock);
35945 - list_add_tail(&ops->node, &syscore_ops_list);
35946 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35947 mutex_unlock(&syscore_ops_lock);
35948 }
35949 EXPORT_SYMBOL_GPL(register_syscore_ops);
35950 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35951 void unregister_syscore_ops(struct syscore_ops *ops)
35952 {
35953 mutex_lock(&syscore_ops_lock);
35954 - list_del(&ops->node);
35955 + pax_list_del((struct list_head *)&ops->node);
35956 mutex_unlock(&syscore_ops_lock);
35957 }
35958 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35959 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35960 index edfa251..1734d4d 100644
35961 --- a/drivers/block/cciss.c
35962 +++ b/drivers/block/cciss.c
35963 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35964 while (!list_empty(&h->reqQ)) {
35965 c = list_entry(h->reqQ.next, CommandList_struct, list);
35966 /* can't do anything if fifo is full */
35967 - if ((h->access.fifo_full(h))) {
35968 + if ((h->access->fifo_full(h))) {
35969 dev_warn(&h->pdev->dev, "fifo full\n");
35970 break;
35971 }
35972 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35973 h->Qdepth--;
35974
35975 /* Tell the controller execute command */
35976 - h->access.submit_command(h, c);
35977 + h->access->submit_command(h, c);
35978
35979 /* Put job onto the completed Q */
35980 addQ(&h->cmpQ, c);
35981 @@ -3447,17 +3447,17 @@ startio:
35982
35983 static inline unsigned long get_next_completion(ctlr_info_t *h)
35984 {
35985 - return h->access.command_completed(h);
35986 + return h->access->command_completed(h);
35987 }
35988
35989 static inline int interrupt_pending(ctlr_info_t *h)
35990 {
35991 - return h->access.intr_pending(h);
35992 + return h->access->intr_pending(h);
35993 }
35994
35995 static inline long interrupt_not_for_us(ctlr_info_t *h)
35996 {
35997 - return ((h->access.intr_pending(h) == 0) ||
35998 + return ((h->access->intr_pending(h) == 0) ||
35999 (h->interrupts_enabled == 0));
36000 }
36001
36002 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36003 u32 a;
36004
36005 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36006 - return h->access.command_completed(h);
36007 + return h->access->command_completed(h);
36008
36009 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36010 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36011 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36012 trans_support & CFGTBL_Trans_use_short_tags);
36013
36014 /* Change the access methods to the performant access methods */
36015 - h->access = SA5_performant_access;
36016 + h->access = &SA5_performant_access;
36017 h->transMethod = CFGTBL_Trans_Performant;
36018
36019 return;
36020 @@ -4327,7 +4327,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36021 if (prod_index < 0)
36022 return -ENODEV;
36023 h->product_name = products[prod_index].product_name;
36024 - h->access = *(products[prod_index].access);
36025 + h->access = products[prod_index].access;
36026
36027 if (cciss_board_disabled(h)) {
36028 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36029 @@ -5059,7 +5059,7 @@ reinit_after_soft_reset:
36030 }
36031
36032 /* make sure the board interrupts are off */
36033 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36034 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36035 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36036 if (rc)
36037 goto clean2;
36038 @@ -5109,7 +5109,7 @@ reinit_after_soft_reset:
36039 * fake ones to scoop up any residual completions.
36040 */
36041 spin_lock_irqsave(&h->lock, flags);
36042 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36043 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36044 spin_unlock_irqrestore(&h->lock, flags);
36045 free_irq(h->intr[h->intr_mode], h);
36046 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36047 @@ -5129,9 +5129,9 @@ reinit_after_soft_reset:
36048 dev_info(&h->pdev->dev, "Board READY.\n");
36049 dev_info(&h->pdev->dev,
36050 "Waiting for stale completions to drain.\n");
36051 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36052 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36053 msleep(10000);
36054 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36055 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36056
36057 rc = controller_reset_failed(h->cfgtable);
36058 if (rc)
36059 @@ -5154,7 +5154,7 @@ reinit_after_soft_reset:
36060 cciss_scsi_setup(h);
36061
36062 /* Turn the interrupts on so we can service requests */
36063 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36064 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36065
36066 /* Get the firmware version */
36067 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36068 @@ -5226,7 +5226,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36069 kfree(flush_buf);
36070 if (return_code != IO_OK)
36071 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36072 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36073 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36074 free_irq(h->intr[h->intr_mode], h);
36075 }
36076
36077 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36078 index 7fda30e..eb5dfe0 100644
36079 --- a/drivers/block/cciss.h
36080 +++ b/drivers/block/cciss.h
36081 @@ -101,7 +101,7 @@ struct ctlr_info
36082 /* information about each logical volume */
36083 drive_info_struct *drv[CISS_MAX_LUN];
36084
36085 - struct access_method access;
36086 + struct access_method *access;
36087
36088 /* queue and queue Info */
36089 struct list_head reqQ;
36090 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36091 index 2b94403..fd6ad1f 100644
36092 --- a/drivers/block/cpqarray.c
36093 +++ b/drivers/block/cpqarray.c
36094 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36095 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36096 goto Enomem4;
36097 }
36098 - hba[i]->access.set_intr_mask(hba[i], 0);
36099 + hba[i]->access->set_intr_mask(hba[i], 0);
36100 if (request_irq(hba[i]->intr, do_ida_intr,
36101 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36102 {
36103 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36104 add_timer(&hba[i]->timer);
36105
36106 /* Enable IRQ now that spinlock and rate limit timer are set up */
36107 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36108 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36109
36110 for(j=0; j<NWD; j++) {
36111 struct gendisk *disk = ida_gendisk[i][j];
36112 @@ -694,7 +694,7 @@ DBGINFO(
36113 for(i=0; i<NR_PRODUCTS; i++) {
36114 if (board_id == products[i].board_id) {
36115 c->product_name = products[i].product_name;
36116 - c->access = *(products[i].access);
36117 + c->access = products[i].access;
36118 break;
36119 }
36120 }
36121 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36122 hba[ctlr]->intr = intr;
36123 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36124 hba[ctlr]->product_name = products[j].product_name;
36125 - hba[ctlr]->access = *(products[j].access);
36126 + hba[ctlr]->access = products[j].access;
36127 hba[ctlr]->ctlr = ctlr;
36128 hba[ctlr]->board_id = board_id;
36129 hba[ctlr]->pci_dev = NULL; /* not PCI */
36130 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36131
36132 while((c = h->reqQ) != NULL) {
36133 /* Can't do anything if we're busy */
36134 - if (h->access.fifo_full(h) == 0)
36135 + if (h->access->fifo_full(h) == 0)
36136 return;
36137
36138 /* Get the first entry from the request Q */
36139 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36140 h->Qdepth--;
36141
36142 /* Tell the controller to do our bidding */
36143 - h->access.submit_command(h, c);
36144 + h->access->submit_command(h, c);
36145
36146 /* Get onto the completion Q */
36147 addQ(&h->cmpQ, c);
36148 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36149 unsigned long flags;
36150 __u32 a,a1;
36151
36152 - istat = h->access.intr_pending(h);
36153 + istat = h->access->intr_pending(h);
36154 /* Is this interrupt for us? */
36155 if (istat == 0)
36156 return IRQ_NONE;
36157 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36158 */
36159 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36160 if (istat & FIFO_NOT_EMPTY) {
36161 - while((a = h->access.command_completed(h))) {
36162 + while((a = h->access->command_completed(h))) {
36163 a1 = a; a &= ~3;
36164 if ((c = h->cmpQ) == NULL)
36165 {
36166 @@ -1448,11 +1448,11 @@ static int sendcmd(
36167 /*
36168 * Disable interrupt
36169 */
36170 - info_p->access.set_intr_mask(info_p, 0);
36171 + info_p->access->set_intr_mask(info_p, 0);
36172 /* Make sure there is room in the command FIFO */
36173 /* Actually it should be completely empty at this time. */
36174 for (i = 200000; i > 0; i--) {
36175 - temp = info_p->access.fifo_full(info_p);
36176 + temp = info_p->access->fifo_full(info_p);
36177 if (temp != 0) {
36178 break;
36179 }
36180 @@ -1465,7 +1465,7 @@ DBG(
36181 /*
36182 * Send the cmd
36183 */
36184 - info_p->access.submit_command(info_p, c);
36185 + info_p->access->submit_command(info_p, c);
36186 complete = pollcomplete(ctlr);
36187
36188 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36189 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36190 * we check the new geometry. Then turn interrupts back on when
36191 * we're done.
36192 */
36193 - host->access.set_intr_mask(host, 0);
36194 + host->access->set_intr_mask(host, 0);
36195 getgeometry(ctlr);
36196 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36197 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36198
36199 for(i=0; i<NWD; i++) {
36200 struct gendisk *disk = ida_gendisk[ctlr][i];
36201 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36202 /* Wait (up to 2 seconds) for a command to complete */
36203
36204 for (i = 200000; i > 0; i--) {
36205 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36206 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36207 if (done == 0) {
36208 udelay(10); /* a short fixed delay */
36209 } else
36210 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36211 index be73e9d..7fbf140 100644
36212 --- a/drivers/block/cpqarray.h
36213 +++ b/drivers/block/cpqarray.h
36214 @@ -99,7 +99,7 @@ struct ctlr_info {
36215 drv_info_t drv[NWD];
36216 struct proc_dir_entry *proc;
36217
36218 - struct access_method access;
36219 + struct access_method *access;
36220
36221 cmdlist_t *reqQ;
36222 cmdlist_t *cmpQ;
36223 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36224 index 2d7f608..11245fe 100644
36225 --- a/drivers/block/drbd/drbd_int.h
36226 +++ b/drivers/block/drbd/drbd_int.h
36227 @@ -582,7 +582,7 @@ struct drbd_epoch {
36228 struct drbd_tconn *tconn;
36229 struct list_head list;
36230 unsigned int barrier_nr;
36231 - atomic_t epoch_size; /* increased on every request added. */
36232 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36233 atomic_t active; /* increased on every req. added, and dec on every finished. */
36234 unsigned long flags;
36235 };
36236 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36237 unsigned int al_tr_number;
36238 int al_tr_cycle;
36239 wait_queue_head_t seq_wait;
36240 - atomic_t packet_seq;
36241 + atomic_unchecked_t packet_seq;
36242 unsigned int peer_seq;
36243 spinlock_t peer_seq_lock;
36244 unsigned int minor;
36245 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36246 char __user *uoptval;
36247 int err;
36248
36249 - uoptval = (char __user __force *)optval;
36250 + uoptval = (char __force_user *)optval;
36251
36252 set_fs(KERNEL_DS);
36253 if (level == SOL_SOCKET)
36254 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36255 index 55635ed..40e837c 100644
36256 --- a/drivers/block/drbd/drbd_main.c
36257 +++ b/drivers/block/drbd/drbd_main.c
36258 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36259 p->sector = sector;
36260 p->block_id = block_id;
36261 p->blksize = blksize;
36262 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36263 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36264 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36265 }
36266
36267 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36268 return -EIO;
36269 p->sector = cpu_to_be64(req->i.sector);
36270 p->block_id = (unsigned long)req;
36271 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36272 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36273 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36274 if (mdev->state.conn >= C_SYNC_SOURCE &&
36275 mdev->state.conn <= C_PAUSED_SYNC_T)
36276 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36277 {
36278 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36279
36280 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36281 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36282 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36283 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36284 kfree(tconn->current_epoch);
36285
36286 idr_destroy(&tconn->volumes);
36287 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36288 index 8cc1e64..ba7ffa9 100644
36289 --- a/drivers/block/drbd/drbd_nl.c
36290 +++ b/drivers/block/drbd/drbd_nl.c
36291 @@ -3440,7 +3440,7 @@ out:
36292
36293 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36294 {
36295 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36296 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36297 struct sk_buff *msg;
36298 struct drbd_genlmsghdr *d_out;
36299 unsigned seq;
36300 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36301 return;
36302 }
36303
36304 - seq = atomic_inc_return(&drbd_genl_seq);
36305 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36306 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36307 if (!msg)
36308 goto failed;
36309 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36310 index cc29cd3..d4b058b 100644
36311 --- a/drivers/block/drbd/drbd_receiver.c
36312 +++ b/drivers/block/drbd/drbd_receiver.c
36313 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36314 {
36315 int err;
36316
36317 - atomic_set(&mdev->packet_seq, 0);
36318 + atomic_set_unchecked(&mdev->packet_seq, 0);
36319 mdev->peer_seq = 0;
36320
36321 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36322 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36323 do {
36324 next_epoch = NULL;
36325
36326 - epoch_size = atomic_read(&epoch->epoch_size);
36327 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36328
36329 switch (ev & ~EV_CLEANUP) {
36330 case EV_PUT:
36331 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36332 rv = FE_DESTROYED;
36333 } else {
36334 epoch->flags = 0;
36335 - atomic_set(&epoch->epoch_size, 0);
36336 + atomic_set_unchecked(&epoch->epoch_size, 0);
36337 /* atomic_set(&epoch->active, 0); is already zero */
36338 if (rv == FE_STILL_LIVE)
36339 rv = FE_RECYCLED;
36340 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36341 conn_wait_active_ee_empty(tconn);
36342 drbd_flush(tconn);
36343
36344 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36345 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36346 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36347 if (epoch)
36348 break;
36349 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36350 }
36351
36352 epoch->flags = 0;
36353 - atomic_set(&epoch->epoch_size, 0);
36354 + atomic_set_unchecked(&epoch->epoch_size, 0);
36355 atomic_set(&epoch->active, 0);
36356
36357 spin_lock(&tconn->epoch_lock);
36358 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36359 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36360 list_add(&epoch->list, &tconn->current_epoch->list);
36361 tconn->current_epoch = epoch;
36362 tconn->epochs++;
36363 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36364
36365 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36366 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36367 - atomic_inc(&tconn->current_epoch->epoch_size);
36368 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36369 err2 = drbd_drain_block(mdev, pi->size);
36370 if (!err)
36371 err = err2;
36372 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36373
36374 spin_lock(&tconn->epoch_lock);
36375 peer_req->epoch = tconn->current_epoch;
36376 - atomic_inc(&peer_req->epoch->epoch_size);
36377 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36378 atomic_inc(&peer_req->epoch->active);
36379 spin_unlock(&tconn->epoch_lock);
36380
36381 @@ -4347,7 +4347,7 @@ struct data_cmd {
36382 int expect_payload;
36383 size_t pkt_size;
36384 int (*fn)(struct drbd_tconn *, struct packet_info *);
36385 -};
36386 +} __do_const;
36387
36388 static struct data_cmd drbd_cmd_handler[] = {
36389 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36390 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36391 if (!list_empty(&tconn->current_epoch->list))
36392 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36393 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36394 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36395 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36396 tconn->send.seen_any_write_yet = false;
36397
36398 conn_info(tconn, "Connection closed\n");
36399 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36400 struct asender_cmd {
36401 size_t pkt_size;
36402 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36403 -};
36404 +} __do_const;
36405
36406 static struct asender_cmd asender_tbl[] = {
36407 [P_PING] = { 0, got_Ping },
36408 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36409 index 40e7155..df5c79a 100644
36410 --- a/drivers/block/loop.c
36411 +++ b/drivers/block/loop.c
36412 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36413
36414 file_start_write(file);
36415 set_fs(get_ds());
36416 - bw = file->f_op->write(file, buf, len, &pos);
36417 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36418 set_fs(old_fs);
36419 file_end_write(file);
36420 if (likely(bw == len))
36421 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36422 index 5618847..5a46f3b 100644
36423 --- a/drivers/block/pktcdvd.c
36424 +++ b/drivers/block/pktcdvd.c
36425 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
36426
36427 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
36428 {
36429 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
36430 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
36431 }
36432
36433 /*
36434 @@ -1897,7 +1897,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
36435 return -EROFS;
36436 }
36437 pd->settings.fp = ti.fp;
36438 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
36439 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
36440
36441 if (ti.nwa_v) {
36442 pd->nwa = be32_to_cpu(ti.next_writable);
36443 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
36444 index 60abf59..80789e1 100644
36445 --- a/drivers/bluetooth/btwilink.c
36446 +++ b/drivers/bluetooth/btwilink.c
36447 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
36448
36449 static int bt_ti_probe(struct platform_device *pdev)
36450 {
36451 - static struct ti_st *hst;
36452 + struct ti_st *hst;
36453 struct hci_dev *hdev;
36454 int err;
36455
36456 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36457 index 2009266..7be9ca2 100644
36458 --- a/drivers/bus/arm-cci.c
36459 +++ b/drivers/bus/arm-cci.c
36460 @@ -405,7 +405,7 @@ static int __init cci_probe(void)
36461
36462 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36463
36464 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36465 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36466 if (!ports)
36467 return -ENOMEM;
36468
36469 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36470 index 8a3aff7..d7538c2 100644
36471 --- a/drivers/cdrom/cdrom.c
36472 +++ b/drivers/cdrom/cdrom.c
36473 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36474 ENSURE(reset, CDC_RESET);
36475 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36476 cdi->mc_flags = 0;
36477 - cdo->n_minors = 0;
36478 cdi->options = CDO_USE_FFLAGS;
36479
36480 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36481 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36482 else
36483 cdi->cdda_method = CDDA_OLD;
36484
36485 - if (!cdo->generic_packet)
36486 - cdo->generic_packet = cdrom_dummy_generic_packet;
36487 + if (!cdo->generic_packet) {
36488 + pax_open_kernel();
36489 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36490 + pax_close_kernel();
36491 + }
36492
36493 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36494 mutex_lock(&cdrom_mutex);
36495 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36496 if (cdi->exit)
36497 cdi->exit(cdi);
36498
36499 - cdi->ops->n_minors--;
36500 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36501 }
36502
36503 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36504 */
36505 nr = nframes;
36506 do {
36507 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36508 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36509 if (cgc.buffer)
36510 break;
36511
36512 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36513 struct cdrom_device_info *cdi;
36514 int ret;
36515
36516 - ret = scnprintf(info + *pos, max_size - *pos, header);
36517 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36518 if (!ret)
36519 return 1;
36520
36521 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36522 index 5980cb9..6d7bd7e 100644
36523 --- a/drivers/cdrom/gdrom.c
36524 +++ b/drivers/cdrom/gdrom.c
36525 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36526 .audio_ioctl = gdrom_audio_ioctl,
36527 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36528 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36529 - .n_minors = 1,
36530 };
36531
36532 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36533 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36534 index 1421997..33f5d6d 100644
36535 --- a/drivers/char/Kconfig
36536 +++ b/drivers/char/Kconfig
36537 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36538
36539 config DEVKMEM
36540 bool "/dev/kmem virtual device support"
36541 - default y
36542 + default n
36543 + depends on !GRKERNSEC_KMEM
36544 help
36545 Say Y here if you want to support the /dev/kmem device. The
36546 /dev/kmem device is rarely used, but can be used for certain
36547 @@ -570,6 +571,7 @@ config DEVPORT
36548 bool
36549 depends on !M68K
36550 depends on ISA || PCI
36551 + depends on !GRKERNSEC_KMEM
36552 default y
36553
36554 source "drivers/s390/char/Kconfig"
36555 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36556 index a48e05b..6bac831 100644
36557 --- a/drivers/char/agp/compat_ioctl.c
36558 +++ b/drivers/char/agp/compat_ioctl.c
36559 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36560 return -ENOMEM;
36561 }
36562
36563 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36564 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36565 sizeof(*usegment) * ureserve.seg_count)) {
36566 kfree(usegment);
36567 kfree(ksegment);
36568 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36569 index 1b19239..b87b143 100644
36570 --- a/drivers/char/agp/frontend.c
36571 +++ b/drivers/char/agp/frontend.c
36572 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36573 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36574 return -EFAULT;
36575
36576 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36577 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36578 return -EFAULT;
36579
36580 client = agp_find_client_by_pid(reserve.pid);
36581 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36582 if (segment == NULL)
36583 return -ENOMEM;
36584
36585 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36586 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36587 sizeof(struct agp_segment) * reserve.seg_count)) {
36588 kfree(segment);
36589 return -EFAULT;
36590 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36591 index 4f94375..413694e 100644
36592 --- a/drivers/char/genrtc.c
36593 +++ b/drivers/char/genrtc.c
36594 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36595 switch (cmd) {
36596
36597 case RTC_PLL_GET:
36598 + memset(&pll, 0, sizeof(pll));
36599 if (get_rtc_pll(&pll))
36600 return -EINVAL;
36601 else
36602 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36603 index 448ce5e..3a76625 100644
36604 --- a/drivers/char/hpet.c
36605 +++ b/drivers/char/hpet.c
36606 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36607 }
36608
36609 static int
36610 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36611 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36612 struct hpet_info *info)
36613 {
36614 struct hpet_timer __iomem *timer;
36615 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36616 index 86fe45c..c0ea948 100644
36617 --- a/drivers/char/hw_random/intel-rng.c
36618 +++ b/drivers/char/hw_random/intel-rng.c
36619 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36620
36621 if (no_fwh_detect)
36622 return -ENODEV;
36623 - printk(warning);
36624 + printk("%s", warning);
36625 return -EBUSY;
36626 }
36627
36628 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36629 index ec4e10f..f2a763b 100644
36630 --- a/drivers/char/ipmi/ipmi_msghandler.c
36631 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36632 @@ -420,7 +420,7 @@ struct ipmi_smi {
36633 struct proc_dir_entry *proc_dir;
36634 char proc_dir_name[10];
36635
36636 - atomic_t stats[IPMI_NUM_STATS];
36637 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36638
36639 /*
36640 * run_to_completion duplicate of smb_info, smi_info
36641 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36642
36643
36644 #define ipmi_inc_stat(intf, stat) \
36645 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36646 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36647 #define ipmi_get_stat(intf, stat) \
36648 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36649 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36650
36651 static int is_lan_addr(struct ipmi_addr *addr)
36652 {
36653 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36654 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36655 init_waitqueue_head(&intf->waitq);
36656 for (i = 0; i < IPMI_NUM_STATS; i++)
36657 - atomic_set(&intf->stats[i], 0);
36658 + atomic_set_unchecked(&intf->stats[i], 0);
36659
36660 intf->proc_dir = NULL;
36661
36662 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36663 index 15e4a60..b046093 100644
36664 --- a/drivers/char/ipmi/ipmi_si_intf.c
36665 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36666 @@ -280,7 +280,7 @@ struct smi_info {
36667 unsigned char slave_addr;
36668
36669 /* Counters and things for the proc filesystem. */
36670 - atomic_t stats[SI_NUM_STATS];
36671 + atomic_unchecked_t stats[SI_NUM_STATS];
36672
36673 struct task_struct *thread;
36674
36675 @@ -289,9 +289,9 @@ struct smi_info {
36676 };
36677
36678 #define smi_inc_stat(smi, stat) \
36679 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36680 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36681 #define smi_get_stat(smi, stat) \
36682 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36683 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36684
36685 #define SI_MAX_PARMS 4
36686
36687 @@ -3324,7 +3324,7 @@ static int try_smi_init(struct smi_info *new_smi)
36688 atomic_set(&new_smi->req_events, 0);
36689 new_smi->run_to_completion = 0;
36690 for (i = 0; i < SI_NUM_STATS; i++)
36691 - atomic_set(&new_smi->stats[i], 0);
36692 + atomic_set_unchecked(&new_smi->stats[i], 0);
36693
36694 new_smi->interrupt_disabled = 1;
36695 atomic_set(&new_smi->stop_operation, 0);
36696 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36697 index f895a8c..2bc9147 100644
36698 --- a/drivers/char/mem.c
36699 +++ b/drivers/char/mem.c
36700 @@ -18,6 +18,7 @@
36701 #include <linux/raw.h>
36702 #include <linux/tty.h>
36703 #include <linux/capability.h>
36704 +#include <linux/security.h>
36705 #include <linux/ptrace.h>
36706 #include <linux/device.h>
36707 #include <linux/highmem.h>
36708 @@ -37,6 +38,10 @@
36709
36710 #define DEVPORT_MINOR 4
36711
36712 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36713 +extern const struct file_operations grsec_fops;
36714 +#endif
36715 +
36716 static inline unsigned long size_inside_page(unsigned long start,
36717 unsigned long size)
36718 {
36719 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36720
36721 while (cursor < to) {
36722 if (!devmem_is_allowed(pfn)) {
36723 +#ifdef CONFIG_GRKERNSEC_KMEM
36724 + gr_handle_mem_readwrite(from, to);
36725 +#else
36726 printk(KERN_INFO
36727 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36728 current->comm, from, to);
36729 +#endif
36730 return 0;
36731 }
36732 cursor += PAGE_SIZE;
36733 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36734 }
36735 return 1;
36736 }
36737 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36738 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36739 +{
36740 + return 0;
36741 +}
36742 #else
36743 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36744 {
36745 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36746
36747 while (count > 0) {
36748 unsigned long remaining;
36749 + char *temp;
36750
36751 sz = size_inside_page(p, count);
36752
36753 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36754 if (!ptr)
36755 return -EFAULT;
36756
36757 - remaining = copy_to_user(buf, ptr, sz);
36758 +#ifdef CONFIG_PAX_USERCOPY
36759 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36760 + if (!temp) {
36761 + unxlate_dev_mem_ptr(p, ptr);
36762 + return -ENOMEM;
36763 + }
36764 + memcpy(temp, ptr, sz);
36765 +#else
36766 + temp = ptr;
36767 +#endif
36768 +
36769 + remaining = copy_to_user(buf, temp, sz);
36770 +
36771 +#ifdef CONFIG_PAX_USERCOPY
36772 + kfree(temp);
36773 +#endif
36774 +
36775 unxlate_dev_mem_ptr(p, ptr);
36776 if (remaining)
36777 return -EFAULT;
36778 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36779 size_t count, loff_t *ppos)
36780 {
36781 unsigned long p = *ppos;
36782 - ssize_t low_count, read, sz;
36783 + ssize_t low_count, read, sz, err = 0;
36784 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36785 - int err = 0;
36786
36787 read = 0;
36788 if (p < (unsigned long) high_memory) {
36789 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36790 }
36791 #endif
36792 while (low_count > 0) {
36793 + char *temp;
36794 +
36795 sz = size_inside_page(p, low_count);
36796
36797 /*
36798 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36799 */
36800 kbuf = xlate_dev_kmem_ptr((char *)p);
36801
36802 - if (copy_to_user(buf, kbuf, sz))
36803 +#ifdef CONFIG_PAX_USERCOPY
36804 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36805 + if (!temp)
36806 + return -ENOMEM;
36807 + memcpy(temp, kbuf, sz);
36808 +#else
36809 + temp = kbuf;
36810 +#endif
36811 +
36812 + err = copy_to_user(buf, temp, sz);
36813 +
36814 +#ifdef CONFIG_PAX_USERCOPY
36815 + kfree(temp);
36816 +#endif
36817 +
36818 + if (err)
36819 return -EFAULT;
36820 buf += sz;
36821 p += sz;
36822 @@ -822,6 +869,9 @@ static const struct memdev {
36823 #ifdef CONFIG_PRINTK
36824 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36825 #endif
36826 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36827 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36828 +#endif
36829 };
36830
36831 static int memory_open(struct inode *inode, struct file *filp)
36832 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36833 continue;
36834
36835 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36836 - NULL, devlist[minor].name);
36837 + NULL, "%s", devlist[minor].name);
36838 }
36839
36840 return tty_init();
36841 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36842 index 9df78e2..01ba9ae 100644
36843 --- a/drivers/char/nvram.c
36844 +++ b/drivers/char/nvram.c
36845 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36846
36847 spin_unlock_irq(&rtc_lock);
36848
36849 - if (copy_to_user(buf, contents, tmp - contents))
36850 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36851 return -EFAULT;
36852
36853 *ppos = i;
36854 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36855 index d39cca6..8c1e269 100644
36856 --- a/drivers/char/pcmcia/synclink_cs.c
36857 +++ b/drivers/char/pcmcia/synclink_cs.c
36858 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36859
36860 if (debug_level >= DEBUG_LEVEL_INFO)
36861 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36862 - __FILE__, __LINE__, info->device_name, port->count);
36863 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36864
36865 - WARN_ON(!port->count);
36866 + WARN_ON(!atomic_read(&port->count));
36867
36868 if (tty_port_close_start(port, tty, filp) == 0)
36869 goto cleanup;
36870 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36871 cleanup:
36872 if (debug_level >= DEBUG_LEVEL_INFO)
36873 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36874 - tty->driver->name, port->count);
36875 + tty->driver->name, atomic_read(&port->count));
36876 }
36877
36878 /* Wait until the transmitter is empty.
36879 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36880
36881 if (debug_level >= DEBUG_LEVEL_INFO)
36882 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36883 - __FILE__, __LINE__, tty->driver->name, port->count);
36884 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36885
36886 /* If port is closing, signal caller to try again */
36887 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36888 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36889 goto cleanup;
36890 }
36891 spin_lock(&port->lock);
36892 - port->count++;
36893 + atomic_inc(&port->count);
36894 spin_unlock(&port->lock);
36895 spin_unlock_irqrestore(&info->netlock, flags);
36896
36897 - if (port->count == 1) {
36898 + if (atomic_read(&port->count) == 1) {
36899 /* 1st open on this device, init hardware */
36900 retval = startup(info, tty);
36901 if (retval < 0)
36902 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36903 unsigned short new_crctype;
36904
36905 /* return error if TTY interface open */
36906 - if (info->port.count)
36907 + if (atomic_read(&info->port.count))
36908 return -EBUSY;
36909
36910 switch (encoding)
36911 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36912
36913 /* arbitrate between network and tty opens */
36914 spin_lock_irqsave(&info->netlock, flags);
36915 - if (info->port.count != 0 || info->netcount != 0) {
36916 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36917 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36918 spin_unlock_irqrestore(&info->netlock, flags);
36919 return -EBUSY;
36920 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36921 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36922
36923 /* return error if TTY interface open */
36924 - if (info->port.count)
36925 + if (atomic_read(&info->port.count))
36926 return -EBUSY;
36927
36928 if (cmd != SIOCWANDEV)
36929 diff --git a/drivers/char/random.c b/drivers/char/random.c
36930 index 7a744d3..35a177ee 100644
36931 --- a/drivers/char/random.c
36932 +++ b/drivers/char/random.c
36933 @@ -269,8 +269,13 @@
36934 /*
36935 * Configuration information
36936 */
36937 +#ifdef CONFIG_GRKERNSEC_RANDNET
36938 +#define INPUT_POOL_WORDS 512
36939 +#define OUTPUT_POOL_WORDS 128
36940 +#else
36941 #define INPUT_POOL_WORDS 128
36942 #define OUTPUT_POOL_WORDS 32
36943 +#endif
36944 #define SEC_XFER_SIZE 512
36945 #define EXTRACT_SIZE 10
36946
36947 @@ -310,10 +315,17 @@ static struct poolinfo {
36948 int poolwords;
36949 int tap1, tap2, tap3, tap4, tap5;
36950 } poolinfo_table[] = {
36951 +#ifdef CONFIG_GRKERNSEC_RANDNET
36952 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36953 + { 512, 411, 308, 208, 104, 1 },
36954 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36955 + { 128, 103, 76, 51, 25, 1 },
36956 +#else
36957 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36958 { 128, 103, 76, 51, 25, 1 },
36959 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36960 { 32, 26, 20, 14, 7, 1 },
36961 +#endif
36962 #if 0
36963 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36964 { 2048, 1638, 1231, 819, 411, 1 },
36965 @@ -521,8 +533,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36966 input_rotate += i ? 7 : 14;
36967 }
36968
36969 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36970 - ACCESS_ONCE(r->add_ptr) = i;
36971 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36972 + ACCESS_ONCE_RW(r->add_ptr) = i;
36973 smp_wmb();
36974
36975 if (out)
36976 @@ -1029,7 +1041,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36977
36978 extract_buf(r, tmp);
36979 i = min_t(int, nbytes, EXTRACT_SIZE);
36980 - if (copy_to_user(buf, tmp, i)) {
36981 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36982 ret = -EFAULT;
36983 break;
36984 }
36985 @@ -1365,7 +1377,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36986 #include <linux/sysctl.h>
36987
36988 static int min_read_thresh = 8, min_write_thresh;
36989 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36990 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36991 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36992 static char sysctl_bootid[16];
36993
36994 @@ -1381,7 +1393,7 @@ static char sysctl_bootid[16];
36995 static int proc_do_uuid(struct ctl_table *table, int write,
36996 void __user *buffer, size_t *lenp, loff_t *ppos)
36997 {
36998 - struct ctl_table fake_table;
36999 + ctl_table_no_const fake_table;
37000 unsigned char buf[64], tmp_uuid[16], *uuid;
37001
37002 uuid = table->data;
37003 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37004 index 7cc1fe22..b602d6b 100644
37005 --- a/drivers/char/sonypi.c
37006 +++ b/drivers/char/sonypi.c
37007 @@ -54,6 +54,7 @@
37008
37009 #include <asm/uaccess.h>
37010 #include <asm/io.h>
37011 +#include <asm/local.h>
37012
37013 #include <linux/sonypi.h>
37014
37015 @@ -490,7 +491,7 @@ static struct sonypi_device {
37016 spinlock_t fifo_lock;
37017 wait_queue_head_t fifo_proc_list;
37018 struct fasync_struct *fifo_async;
37019 - int open_count;
37020 + local_t open_count;
37021 int model;
37022 struct input_dev *input_jog_dev;
37023 struct input_dev *input_key_dev;
37024 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37025 static int sonypi_misc_release(struct inode *inode, struct file *file)
37026 {
37027 mutex_lock(&sonypi_device.lock);
37028 - sonypi_device.open_count--;
37029 + local_dec(&sonypi_device.open_count);
37030 mutex_unlock(&sonypi_device.lock);
37031 return 0;
37032 }
37033 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37034 {
37035 mutex_lock(&sonypi_device.lock);
37036 /* Flush input queue on first open */
37037 - if (!sonypi_device.open_count)
37038 + if (!local_read(&sonypi_device.open_count))
37039 kfifo_reset(&sonypi_device.fifo);
37040 - sonypi_device.open_count++;
37041 + local_inc(&sonypi_device.open_count);
37042 mutex_unlock(&sonypi_device.lock);
37043
37044 return 0;
37045 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37046 index 64420b3..5c40b56 100644
37047 --- a/drivers/char/tpm/tpm_acpi.c
37048 +++ b/drivers/char/tpm/tpm_acpi.c
37049 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37050 virt = acpi_os_map_memory(start, len);
37051 if (!virt) {
37052 kfree(log->bios_event_log);
37053 + log->bios_event_log = NULL;
37054 printk("%s: ERROR - Unable to map memory\n", __func__);
37055 return -EIO;
37056 }
37057
37058 - memcpy_fromio(log->bios_event_log, virt, len);
37059 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37060
37061 acpi_os_unmap_memory(virt, len);
37062 return 0;
37063 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37064 index 84ddc55..1d32f1e 100644
37065 --- a/drivers/char/tpm/tpm_eventlog.c
37066 +++ b/drivers/char/tpm/tpm_eventlog.c
37067 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37068 event = addr;
37069
37070 if ((event->event_type == 0 && event->event_size == 0) ||
37071 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37072 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37073 return NULL;
37074
37075 return addr;
37076 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37077 return NULL;
37078
37079 if ((event->event_type == 0 && event->event_size == 0) ||
37080 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37081 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37082 return NULL;
37083
37084 (*pos)++;
37085 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37086 int i;
37087
37088 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37089 - seq_putc(m, data[i]);
37090 + if (!seq_putc(m, data[i]))
37091 + return -EFAULT;
37092
37093 return 0;
37094 }
37095 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37096 index b79cf3e..de172d64f 100644
37097 --- a/drivers/char/virtio_console.c
37098 +++ b/drivers/char/virtio_console.c
37099 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37100 if (to_user) {
37101 ssize_t ret;
37102
37103 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37104 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37105 if (ret)
37106 return -EFAULT;
37107 } else {
37108 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37109 if (!port_has_data(port) && !port->host_connected)
37110 return 0;
37111
37112 - return fill_readbuf(port, ubuf, count, true);
37113 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37114 }
37115
37116 static int wait_port_writable(struct port *port, bool nonblock)
37117 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37118 index a33f46f..a720eed 100644
37119 --- a/drivers/clk/clk-composite.c
37120 +++ b/drivers/clk/clk-composite.c
37121 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37122 struct clk *clk;
37123 struct clk_init_data init;
37124 struct clk_composite *composite;
37125 - struct clk_ops *clk_composite_ops;
37126 + clk_ops_no_const *clk_composite_ops;
37127
37128 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37129 if (!composite) {
37130 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37131 index 81dd31a..ef5c542 100644
37132 --- a/drivers/clk/socfpga/clk.c
37133 +++ b/drivers/clk/socfpga/clk.c
37134 @@ -22,6 +22,7 @@
37135 #include <linux/clk-provider.h>
37136 #include <linux/io.h>
37137 #include <linux/of.h>
37138 +#include <asm/pgtable.h>
37139
37140 /* Clock Manager offsets */
37141 #define CLKMGR_CTRL 0x0
37142 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37143 streq(clk_name, "periph_pll") ||
37144 streq(clk_name, "sdram_pll")) {
37145 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37146 - clk_pll_ops.enable = clk_gate_ops.enable;
37147 - clk_pll_ops.disable = clk_gate_ops.disable;
37148 + pax_open_kernel();
37149 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37150 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37151 + pax_close_kernel();
37152 }
37153
37154 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37155 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37156 return parent_rate / div;
37157 }
37158
37159 -static struct clk_ops gateclk_ops = {
37160 +static clk_ops_no_const gateclk_ops __read_only = {
37161 .recalc_rate = socfpga_clk_recalc_rate,
37162 .get_parent = socfpga_clk_get_parent,
37163 .set_parent = socfpga_clk_set_parent,
37164 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37165 index 506fd23..01a593f 100644
37166 --- a/drivers/cpufreq/acpi-cpufreq.c
37167 +++ b/drivers/cpufreq/acpi-cpufreq.c
37168 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37169 return sprintf(buf, "%u\n", boost_enabled);
37170 }
37171
37172 -static struct global_attr global_boost = __ATTR(boost, 0644,
37173 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37174 show_global_boost,
37175 store_global_boost);
37176
37177 @@ -721,8 +721,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37178 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37179 per_cpu(acfreq_data, cpu) = data;
37180
37181 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37182 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37183 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37184 + pax_open_kernel();
37185 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37186 + pax_close_kernel();
37187 + }
37188
37189 result = acpi_processor_register_performance(data->acpi_data, cpu);
37190 if (result)
37191 @@ -850,7 +853,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37192 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37193 break;
37194 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37195 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37196 + pax_open_kernel();
37197 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37198 + pax_close_kernel();
37199 policy->cur = get_cur_freq_on_cpu(cpu);
37200 break;
37201 default:
37202 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37203 index 04548f7..457a342 100644
37204 --- a/drivers/cpufreq/cpufreq.c
37205 +++ b/drivers/cpufreq/cpufreq.c
37206 @@ -2069,7 +2069,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37207 return NOTIFY_OK;
37208 }
37209
37210 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37211 +static struct notifier_block cpufreq_cpu_notifier = {
37212 .notifier_call = cpufreq_cpu_callback,
37213 };
37214
37215 @@ -2101,8 +2101,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37216
37217 pr_debug("trying to register driver %s\n", driver_data->name);
37218
37219 - if (driver_data->setpolicy)
37220 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37221 + if (driver_data->setpolicy) {
37222 + pax_open_kernel();
37223 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37224 + pax_close_kernel();
37225 + }
37226
37227 write_lock_irqsave(&cpufreq_driver_lock, flags);
37228 if (cpufreq_driver) {
37229 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37230 index 0806c31..6a73276 100644
37231 --- a/drivers/cpufreq/cpufreq_governor.c
37232 +++ b/drivers/cpufreq/cpufreq_governor.c
37233 @@ -187,7 +187,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37234 struct dbs_data *dbs_data;
37235 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37236 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37237 - struct od_ops *od_ops = NULL;
37238 + const struct od_ops *od_ops = NULL;
37239 struct od_dbs_tuners *od_tuners = NULL;
37240 struct cs_dbs_tuners *cs_tuners = NULL;
37241 struct cpu_dbs_common_info *cpu_cdbs;
37242 @@ -253,7 +253,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37243
37244 if ((cdata->governor == GOV_CONSERVATIVE) &&
37245 (!policy->governor->initialized)) {
37246 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37247 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37248
37249 cpufreq_register_notifier(cs_ops->notifier_block,
37250 CPUFREQ_TRANSITION_NOTIFIER);
37251 @@ -273,7 +273,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37252
37253 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37254 (policy->governor->initialized == 1)) {
37255 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37256 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37257
37258 cpufreq_unregister_notifier(cs_ops->notifier_block,
37259 CPUFREQ_TRANSITION_NOTIFIER);
37260 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37261 index 88cd39f..87f0393 100644
37262 --- a/drivers/cpufreq/cpufreq_governor.h
37263 +++ b/drivers/cpufreq/cpufreq_governor.h
37264 @@ -202,7 +202,7 @@ struct common_dbs_data {
37265 void (*exit)(struct dbs_data *dbs_data);
37266
37267 /* Governor specific ops, see below */
37268 - void *gov_ops;
37269 + const void *gov_ops;
37270 };
37271
37272 /* Governor Per policy data */
37273 @@ -222,7 +222,7 @@ struct od_ops {
37274 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37275 unsigned int freq_next, unsigned int relation);
37276 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
37277 -};
37278 +} __no_const;
37279
37280 struct cs_ops {
37281 struct notifier_block *notifier_block;
37282 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37283 index 32f26f6..feb657b 100644
37284 --- a/drivers/cpufreq/cpufreq_ondemand.c
37285 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37286 @@ -522,7 +522,7 @@ static void od_exit(struct dbs_data *dbs_data)
37287
37288 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37289
37290 -static struct od_ops od_ops = {
37291 +static struct od_ops od_ops __read_only = {
37292 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37293 .powersave_bias_target = generic_powersave_bias_target,
37294 .freq_increase = dbs_freq_increase,
37295 @@ -577,14 +577,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37296 (struct cpufreq_policy *, unsigned int, unsigned int),
37297 unsigned int powersave_bias)
37298 {
37299 - od_ops.powersave_bias_target = f;
37300 + pax_open_kernel();
37301 + *(void **)&od_ops.powersave_bias_target = f;
37302 + pax_close_kernel();
37303 od_set_powersave_bias(powersave_bias);
37304 }
37305 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37306
37307 void od_unregister_powersave_bias_handler(void)
37308 {
37309 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37310 + pax_open_kernel();
37311 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37312 + pax_close_kernel();
37313 od_set_powersave_bias(0);
37314 }
37315 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37316 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37317 index 4cf0d28..5830372 100644
37318 --- a/drivers/cpufreq/cpufreq_stats.c
37319 +++ b/drivers/cpufreq/cpufreq_stats.c
37320 @@ -352,7 +352,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37321 }
37322
37323 /* priority=1 so this will get called before cpufreq_remove_dev */
37324 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37325 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37326 .notifier_call = cpufreq_stat_cpu_callback,
37327 .priority = 1,
37328 };
37329 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37330 index 2f0a2a6..93d728e 100644
37331 --- a/drivers/cpufreq/p4-clockmod.c
37332 +++ b/drivers/cpufreq/p4-clockmod.c
37333 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37334 case 0x0F: /* Core Duo */
37335 case 0x16: /* Celeron Core */
37336 case 0x1C: /* Atom */
37337 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37338 + pax_open_kernel();
37339 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37340 + pax_close_kernel();
37341 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37342 case 0x0D: /* Pentium M (Dothan) */
37343 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37344 + pax_open_kernel();
37345 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37346 + pax_close_kernel();
37347 /* fall through */
37348 case 0x09: /* Pentium M (Banias) */
37349 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37350 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37351
37352 /* on P-4s, the TSC runs with constant frequency independent whether
37353 * throttling is active or not. */
37354 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37355 + pax_open_kernel();
37356 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37357 + pax_close_kernel();
37358
37359 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37360 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37361 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37362 index ac76b48..2445bc6 100644
37363 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37364 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37365 @@ -18,14 +18,12 @@
37366 #include <asm/head.h>
37367 #include <asm/timer.h>
37368
37369 -static struct cpufreq_driver *cpufreq_us3_driver;
37370 -
37371 struct us3_freq_percpu_info {
37372 struct cpufreq_frequency_table table[4];
37373 };
37374
37375 /* Indexed by cpu number. */
37376 -static struct us3_freq_percpu_info *us3_freq_table;
37377 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37378
37379 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37380 * in the Safari config register.
37381 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37382
37383 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37384 {
37385 - if (cpufreq_us3_driver)
37386 - us3_set_cpu_divider_index(policy, 0);
37387 + us3_set_cpu_divider_index(policy->cpu, 0);
37388
37389 return 0;
37390 }
37391
37392 +static int __init us3_freq_init(void);
37393 +static void __exit us3_freq_exit(void);
37394 +
37395 +static struct cpufreq_driver cpufreq_us3_driver = {
37396 + .init = us3_freq_cpu_init,
37397 + .verify = us3_freq_verify,
37398 + .target = us3_freq_target,
37399 + .get = us3_freq_get,
37400 + .exit = us3_freq_cpu_exit,
37401 + .owner = THIS_MODULE,
37402 + .name = "UltraSPARC-III",
37403 +
37404 +};
37405 +
37406 static int __init us3_freq_init(void)
37407 {
37408 unsigned long manuf, impl, ver;
37409 @@ -208,55 +219,15 @@ static int __init us3_freq_init(void)
37410 (impl == CHEETAH_IMPL ||
37411 impl == CHEETAH_PLUS_IMPL ||
37412 impl == JAGUAR_IMPL ||
37413 - impl == PANTHER_IMPL)) {
37414 - struct cpufreq_driver *driver;
37415 -
37416 - ret = -ENOMEM;
37417 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
37418 - if (!driver)
37419 - goto err_out;
37420 -
37421 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
37422 - GFP_KERNEL);
37423 - if (!us3_freq_table)
37424 - goto err_out;
37425 -
37426 - driver->init = us3_freq_cpu_init;
37427 - driver->verify = us3_freq_verify;
37428 - driver->target = us3_freq_target;
37429 - driver->get = us3_freq_get;
37430 - driver->exit = us3_freq_cpu_exit;
37431 - strcpy(driver->name, "UltraSPARC-III");
37432 -
37433 - cpufreq_us3_driver = driver;
37434 - ret = cpufreq_register_driver(driver);
37435 - if (ret)
37436 - goto err_out;
37437 -
37438 - return 0;
37439 -
37440 -err_out:
37441 - if (driver) {
37442 - kfree(driver);
37443 - cpufreq_us3_driver = NULL;
37444 - }
37445 - kfree(us3_freq_table);
37446 - us3_freq_table = NULL;
37447 - return ret;
37448 - }
37449 + impl == PANTHER_IMPL))
37450 + return cpufreq_register_driver(&cpufreq_us3_driver);
37451
37452 return -ENODEV;
37453 }
37454
37455 static void __exit us3_freq_exit(void)
37456 {
37457 - if (cpufreq_us3_driver) {
37458 - cpufreq_unregister_driver(cpufreq_us3_driver);
37459 - kfree(cpufreq_us3_driver);
37460 - cpufreq_us3_driver = NULL;
37461 - kfree(us3_freq_table);
37462 - us3_freq_table = NULL;
37463 - }
37464 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37465 }
37466
37467 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37468 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37469 index f897d51..15da295 100644
37470 --- a/drivers/cpufreq/speedstep-centrino.c
37471 +++ b/drivers/cpufreq/speedstep-centrino.c
37472 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37473 !cpu_has(cpu, X86_FEATURE_EST))
37474 return -ENODEV;
37475
37476 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37477 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37478 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37479 + pax_open_kernel();
37480 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37481 + pax_close_kernel();
37482 + }
37483
37484 if (policy->cpu != 0)
37485 return -ENODEV;
37486 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37487 index d75040d..4738ca5 100644
37488 --- a/drivers/cpuidle/cpuidle.c
37489 +++ b/drivers/cpuidle/cpuidle.c
37490 @@ -252,7 +252,7 @@ static int poll_idle(struct cpuidle_device *dev,
37491
37492 static void poll_idle_init(struct cpuidle_driver *drv)
37493 {
37494 - struct cpuidle_state *state = &drv->states[0];
37495 + cpuidle_state_no_const *state = &drv->states[0];
37496
37497 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37498 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37499 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37500 index ea2f8e7..70ac501 100644
37501 --- a/drivers/cpuidle/governor.c
37502 +++ b/drivers/cpuidle/governor.c
37503 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37504 mutex_lock(&cpuidle_lock);
37505 if (__cpuidle_find_governor(gov->name) == NULL) {
37506 ret = 0;
37507 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37508 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37509 if (!cpuidle_curr_governor ||
37510 cpuidle_curr_governor->rating < gov->rating)
37511 cpuidle_switch_governor(gov);
37512 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37513 new_gov = cpuidle_replace_governor(gov->rating);
37514 cpuidle_switch_governor(new_gov);
37515 }
37516 - list_del(&gov->governor_list);
37517 + pax_list_del((struct list_head *)&gov->governor_list);
37518 mutex_unlock(&cpuidle_lock);
37519 }
37520
37521 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37522 index 8739cc0..dc859d0 100644
37523 --- a/drivers/cpuidle/sysfs.c
37524 +++ b/drivers/cpuidle/sysfs.c
37525 @@ -134,7 +134,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37526 NULL
37527 };
37528
37529 -static struct attribute_group cpuidle_attr_group = {
37530 +static attribute_group_no_const cpuidle_attr_group = {
37531 .attrs = cpuidle_default_attrs,
37532 .name = "cpuidle",
37533 };
37534 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37535 index 12fea3e..1e28f47 100644
37536 --- a/drivers/crypto/hifn_795x.c
37537 +++ b/drivers/crypto/hifn_795x.c
37538 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37539 MODULE_PARM_DESC(hifn_pll_ref,
37540 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37541
37542 -static atomic_t hifn_dev_number;
37543 +static atomic_unchecked_t hifn_dev_number;
37544
37545 #define ACRYPTO_OP_DECRYPT 0
37546 #define ACRYPTO_OP_ENCRYPT 1
37547 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37548 goto err_out_disable_pci_device;
37549
37550 snprintf(name, sizeof(name), "hifn%d",
37551 - atomic_inc_return(&hifn_dev_number)-1);
37552 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37553
37554 err = pci_request_regions(pdev, name);
37555 if (err)
37556 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37557 index c99c00d..990a4b2 100644
37558 --- a/drivers/devfreq/devfreq.c
37559 +++ b/drivers/devfreq/devfreq.c
37560 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37561 goto err_out;
37562 }
37563
37564 - list_add(&governor->node, &devfreq_governor_list);
37565 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37566
37567 list_for_each_entry(devfreq, &devfreq_list, node) {
37568 int ret = 0;
37569 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37570 }
37571 }
37572
37573 - list_del(&governor->node);
37574 + pax_list_del((struct list_head *)&governor->node);
37575 err_out:
37576 mutex_unlock(&devfreq_list_lock);
37577
37578 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
37579 index 1069e88..dfcd642 100644
37580 --- a/drivers/dma/sh/shdmac.c
37581 +++ b/drivers/dma/sh/shdmac.c
37582 @@ -511,7 +511,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37583 return ret;
37584 }
37585
37586 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37587 +static struct notifier_block sh_dmae_nmi_notifier = {
37588 .notifier_call = sh_dmae_nmi_handler,
37589
37590 /* Run before NMI debug handler and KGDB */
37591 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37592 index 211021d..201d47f 100644
37593 --- a/drivers/edac/edac_device.c
37594 +++ b/drivers/edac/edac_device.c
37595 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37596 */
37597 int edac_device_alloc_index(void)
37598 {
37599 - static atomic_t device_indexes = ATOMIC_INIT(0);
37600 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37601
37602 - return atomic_inc_return(&device_indexes) - 1;
37603 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37604 }
37605 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37606
37607 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37608 index 9f7e0e60..348c875 100644
37609 --- a/drivers/edac/edac_mc_sysfs.c
37610 +++ b/drivers/edac/edac_mc_sysfs.c
37611 @@ -150,7 +150,7 @@ static const char * const edac_caps[] = {
37612 struct dev_ch_attribute {
37613 struct device_attribute attr;
37614 int channel;
37615 -};
37616 +} __do_const;
37617
37618 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37619 struct dev_ch_attribute dev_attr_legacy_##_name = \
37620 @@ -1007,14 +1007,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37621 }
37622
37623 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37624 + pax_open_kernel();
37625 if (mci->get_sdram_scrub_rate) {
37626 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37627 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37628 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37629 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37630 }
37631 if (mci->set_sdram_scrub_rate) {
37632 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37633 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37634 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37635 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37636 }
37637 + pax_close_kernel();
37638 err = device_create_file(&mci->dev,
37639 &dev_attr_sdram_scrub_rate);
37640 if (err) {
37641 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37642 index dd370f9..0281629 100644
37643 --- a/drivers/edac/edac_pci.c
37644 +++ b/drivers/edac/edac_pci.c
37645 @@ -29,7 +29,7 @@
37646
37647 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37648 static LIST_HEAD(edac_pci_list);
37649 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37650 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37651
37652 /*
37653 * edac_pci_alloc_ctl_info
37654 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37655 */
37656 int edac_pci_alloc_index(void)
37657 {
37658 - return atomic_inc_return(&pci_indexes) - 1;
37659 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37660 }
37661 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37662
37663 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37664 index e8658e4..22746d6 100644
37665 --- a/drivers/edac/edac_pci_sysfs.c
37666 +++ b/drivers/edac/edac_pci_sysfs.c
37667 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37668 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37669 static int edac_pci_poll_msec = 1000; /* one second workq period */
37670
37671 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37672 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37673 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37674 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37675
37676 static struct kobject *edac_pci_top_main_kobj;
37677 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37678 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37679 void *value;
37680 ssize_t(*show) (void *, char *);
37681 ssize_t(*store) (void *, const char *, size_t);
37682 -};
37683 +} __do_const;
37684
37685 /* Set of show/store abstract level functions for PCI Parity object */
37686 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37687 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37688 edac_printk(KERN_CRIT, EDAC_PCI,
37689 "Signaled System Error on %s\n",
37690 pci_name(dev));
37691 - atomic_inc(&pci_nonparity_count);
37692 + atomic_inc_unchecked(&pci_nonparity_count);
37693 }
37694
37695 if (status & (PCI_STATUS_PARITY)) {
37696 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37697 "Master Data Parity Error on %s\n",
37698 pci_name(dev));
37699
37700 - atomic_inc(&pci_parity_count);
37701 + atomic_inc_unchecked(&pci_parity_count);
37702 }
37703
37704 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37705 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37706 "Detected Parity Error on %s\n",
37707 pci_name(dev));
37708
37709 - atomic_inc(&pci_parity_count);
37710 + atomic_inc_unchecked(&pci_parity_count);
37711 }
37712 }
37713
37714 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37715 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37716 "Signaled System Error on %s\n",
37717 pci_name(dev));
37718 - atomic_inc(&pci_nonparity_count);
37719 + atomic_inc_unchecked(&pci_nonparity_count);
37720 }
37721
37722 if (status & (PCI_STATUS_PARITY)) {
37723 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37724 "Master Data Parity Error on "
37725 "%s\n", pci_name(dev));
37726
37727 - atomic_inc(&pci_parity_count);
37728 + atomic_inc_unchecked(&pci_parity_count);
37729 }
37730
37731 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37732 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37733 "Detected Parity Error on %s\n",
37734 pci_name(dev));
37735
37736 - atomic_inc(&pci_parity_count);
37737 + atomic_inc_unchecked(&pci_parity_count);
37738 }
37739 }
37740 }
37741 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37742 if (!check_pci_errors)
37743 return;
37744
37745 - before_count = atomic_read(&pci_parity_count);
37746 + before_count = atomic_read_unchecked(&pci_parity_count);
37747
37748 /* scan all PCI devices looking for a Parity Error on devices and
37749 * bridges.
37750 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37751 /* Only if operator has selected panic on PCI Error */
37752 if (edac_pci_get_panic_on_pe()) {
37753 /* If the count is different 'after' from 'before' */
37754 - if (before_count != atomic_read(&pci_parity_count))
37755 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37756 panic("EDAC: PCI Parity Error");
37757 }
37758 }
37759 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37760 index 51b7e3a..aa8a3e8 100644
37761 --- a/drivers/edac/mce_amd.h
37762 +++ b/drivers/edac/mce_amd.h
37763 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37764 bool (*mc0_mce)(u16, u8);
37765 bool (*mc1_mce)(u16, u8);
37766 bool (*mc2_mce)(u16, u8);
37767 -};
37768 +} __no_const;
37769
37770 void amd_report_gart_errors(bool);
37771 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37772 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37773 index 57ea7f4..af06b76 100644
37774 --- a/drivers/firewire/core-card.c
37775 +++ b/drivers/firewire/core-card.c
37776 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37777 const struct fw_card_driver *driver,
37778 struct device *device)
37779 {
37780 - static atomic_t index = ATOMIC_INIT(-1);
37781 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37782
37783 - card->index = atomic_inc_return(&index);
37784 + card->index = atomic_inc_return_unchecked(&index);
37785 card->driver = driver;
37786 card->device = device;
37787 card->current_tlabel = 0;
37788 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37789
37790 void fw_core_remove_card(struct fw_card *card)
37791 {
37792 - struct fw_card_driver dummy_driver = dummy_driver_template;
37793 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37794
37795 card->driver->update_phy_reg(card, 4,
37796 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37797 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37798 index de4aa40..49ab1f2 100644
37799 --- a/drivers/firewire/core-device.c
37800 +++ b/drivers/firewire/core-device.c
37801 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37802 struct config_rom_attribute {
37803 struct device_attribute attr;
37804 u32 key;
37805 -};
37806 +} __do_const;
37807
37808 static ssize_t show_immediate(struct device *dev,
37809 struct device_attribute *dattr, char *buf)
37810 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37811 index e5af0e3..d318058 100644
37812 --- a/drivers/firewire/core-transaction.c
37813 +++ b/drivers/firewire/core-transaction.c
37814 @@ -38,6 +38,7 @@
37815 #include <linux/timer.h>
37816 #include <linux/types.h>
37817 #include <linux/workqueue.h>
37818 +#include <linux/sched.h>
37819
37820 #include <asm/byteorder.h>
37821
37822 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37823 index 515a42c..5ecf3ba 100644
37824 --- a/drivers/firewire/core.h
37825 +++ b/drivers/firewire/core.h
37826 @@ -111,6 +111,7 @@ struct fw_card_driver {
37827
37828 int (*stop_iso)(struct fw_iso_context *ctx);
37829 };
37830 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37831
37832 void fw_card_initialize(struct fw_card *card,
37833 const struct fw_card_driver *driver, struct device *device);
37834 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37835 index 94a58a0..f5eba42 100644
37836 --- a/drivers/firmware/dmi-id.c
37837 +++ b/drivers/firmware/dmi-id.c
37838 @@ -16,7 +16,7 @@
37839 struct dmi_device_attribute{
37840 struct device_attribute dev_attr;
37841 int field;
37842 -};
37843 +} __do_const;
37844 #define to_dmi_dev_attr(_dev_attr) \
37845 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37846
37847 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37848 index fa0affb..aa448eb 100644
37849 --- a/drivers/firmware/dmi_scan.c
37850 +++ b/drivers/firmware/dmi_scan.c
37851 @@ -791,7 +791,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37852 if (buf == NULL)
37853 return -1;
37854
37855 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37856 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37857
37858 iounmap(buf);
37859 return 0;
37860 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37861 index 5145fa3..0d3babd 100644
37862 --- a/drivers/firmware/efi/efi.c
37863 +++ b/drivers/firmware/efi/efi.c
37864 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37865 };
37866
37867 static struct efivars generic_efivars;
37868 -static struct efivar_operations generic_ops;
37869 +static efivar_operations_no_const generic_ops __read_only;
37870
37871 static int generic_ops_register(void)
37872 {
37873 - generic_ops.get_variable = efi.get_variable;
37874 - generic_ops.set_variable = efi.set_variable;
37875 - generic_ops.get_next_variable = efi.get_next_variable;
37876 - generic_ops.query_variable_store = efi_query_variable_store;
37877 + pax_open_kernel();
37878 + *(void **)&generic_ops.get_variable = efi.get_variable;
37879 + *(void **)&generic_ops.set_variable = efi.set_variable;
37880 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37881 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37882 + pax_close_kernel();
37883
37884 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37885 }
37886 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37887 index 8a7432a..28fb839 100644
37888 --- a/drivers/firmware/efi/efivars.c
37889 +++ b/drivers/firmware/efi/efivars.c
37890 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37891 static int
37892 create_efivars_bin_attributes(void)
37893 {
37894 - struct bin_attribute *attr;
37895 + bin_attribute_no_const *attr;
37896 int error;
37897
37898 /* new_var */
37899 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37900 index 2a90ba6..07f3733 100644
37901 --- a/drivers/firmware/google/memconsole.c
37902 +++ b/drivers/firmware/google/memconsole.c
37903 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37904 if (!found_memconsole())
37905 return -ENODEV;
37906
37907 - memconsole_bin_attr.size = memconsole_length;
37908 + pax_open_kernel();
37909 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37910 + pax_close_kernel();
37911
37912 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37913
37914 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37915 index 814addb..0937d7f 100644
37916 --- a/drivers/gpio/gpio-ich.c
37917 +++ b/drivers/gpio/gpio-ich.c
37918 @@ -71,7 +71,7 @@ struct ichx_desc {
37919 /* Some chipsets have quirks, let these use their own request/get */
37920 int (*request)(struct gpio_chip *chip, unsigned offset);
37921 int (*get)(struct gpio_chip *chip, unsigned offset);
37922 -};
37923 +} __do_const;
37924
37925 static struct {
37926 spinlock_t lock;
37927 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37928 index 9902732..64b62dd 100644
37929 --- a/drivers/gpio/gpio-vr41xx.c
37930 +++ b/drivers/gpio/gpio-vr41xx.c
37931 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37932 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37933 maskl, pendl, maskh, pendh);
37934
37935 - atomic_inc(&irq_err_count);
37936 + atomic_inc_unchecked(&irq_err_count);
37937
37938 return -EINVAL;
37939 }
37940 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37941 index c722c3b..2ec6040 100644
37942 --- a/drivers/gpu/drm/drm_crtc_helper.c
37943 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37944 @@ -328,7 +328,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37945 struct drm_crtc *tmp;
37946 int crtc_mask = 1;
37947
37948 - WARN(!crtc, "checking null crtc?\n");
37949 + BUG_ON(!crtc);
37950
37951 dev = crtc->dev;
37952
37953 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37954 index fe58d08..07bc38e 100644
37955 --- a/drivers/gpu/drm/drm_drv.c
37956 +++ b/drivers/gpu/drm/drm_drv.c
37957 @@ -186,7 +186,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
37958 atomic_set(&dev->vma_count, 0);
37959
37960 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37961 - atomic_set(&dev->counts[i], 0);
37962 + atomic_set_unchecked(&dev->counts[i], 0);
37963
37964 dev->sigdata.lock = NULL;
37965
37966 @@ -302,7 +302,7 @@ module_exit(drm_core_exit);
37967 /**
37968 * Copy and IOCTL return string to user space
37969 */
37970 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37971 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37972 {
37973 int len;
37974
37975 @@ -372,7 +372,7 @@ long drm_ioctl(struct file *filp,
37976 struct drm_file *file_priv = filp->private_data;
37977 struct drm_device *dev;
37978 const struct drm_ioctl_desc *ioctl = NULL;
37979 - drm_ioctl_t *func;
37980 + drm_ioctl_no_const_t func;
37981 unsigned int nr = DRM_IOCTL_NR(cmd);
37982 int retcode = -EINVAL;
37983 char stack_kdata[128];
37984 @@ -385,7 +385,7 @@ long drm_ioctl(struct file *filp,
37985 return -ENODEV;
37986
37987 atomic_inc(&dev->ioctl_count);
37988 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37989 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37990 ++file_priv->ioctl_count;
37991
37992 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37993 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37994 index 3f84277..c627c54 100644
37995 --- a/drivers/gpu/drm/drm_fops.c
37996 +++ b/drivers/gpu/drm/drm_fops.c
37997 @@ -97,7 +97,7 @@ int drm_open(struct inode *inode, struct file *filp)
37998 if (drm_device_is_unplugged(dev))
37999 return -ENODEV;
38000
38001 - if (!dev->open_count++)
38002 + if (local_inc_return(&dev->open_count) == 1)
38003 need_setup = 1;
38004 mutex_lock(&dev->struct_mutex);
38005 old_imapping = inode->i_mapping;
38006 @@ -113,7 +113,7 @@ int drm_open(struct inode *inode, struct file *filp)
38007 retcode = drm_open_helper(inode, filp, dev);
38008 if (retcode)
38009 goto err_undo;
38010 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38011 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38012 if (need_setup) {
38013 retcode = drm_setup(dev);
38014 if (retcode)
38015 @@ -128,7 +128,7 @@ err_undo:
38016 iput(container_of(dev->dev_mapping, struct inode, i_data));
38017 dev->dev_mapping = old_mapping;
38018 mutex_unlock(&dev->struct_mutex);
38019 - dev->open_count--;
38020 + local_dec(&dev->open_count);
38021 return retcode;
38022 }
38023 EXPORT_SYMBOL(drm_open);
38024 @@ -405,7 +405,7 @@ int drm_release(struct inode *inode, struct file *filp)
38025
38026 mutex_lock(&drm_global_mutex);
38027
38028 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38029 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38030
38031 if (dev->driver->preclose)
38032 dev->driver->preclose(dev, file_priv);
38033 @@ -414,10 +414,10 @@ int drm_release(struct inode *inode, struct file *filp)
38034 * Begin inline drm_release
38035 */
38036
38037 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38038 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38039 task_pid_nr(current),
38040 (long)old_encode_dev(file_priv->minor->device),
38041 - dev->open_count);
38042 + local_read(&dev->open_count));
38043
38044 /* Release any auth tokens that might point to this file_priv,
38045 (do that under the drm_global_mutex) */
38046 @@ -516,8 +516,8 @@ int drm_release(struct inode *inode, struct file *filp)
38047 * End inline drm_release
38048 */
38049
38050 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38051 - if (!--dev->open_count) {
38052 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38053 + if (local_dec_and_test(&dev->open_count)) {
38054 if (atomic_read(&dev->ioctl_count)) {
38055 DRM_ERROR("Device busy: %d\n",
38056 atomic_read(&dev->ioctl_count));
38057 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38058 index f731116..629842c 100644
38059 --- a/drivers/gpu/drm/drm_global.c
38060 +++ b/drivers/gpu/drm/drm_global.c
38061 @@ -36,7 +36,7 @@
38062 struct drm_global_item {
38063 struct mutex mutex;
38064 void *object;
38065 - int refcount;
38066 + atomic_t refcount;
38067 };
38068
38069 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38070 @@ -49,7 +49,7 @@ void drm_global_init(void)
38071 struct drm_global_item *item = &glob[i];
38072 mutex_init(&item->mutex);
38073 item->object = NULL;
38074 - item->refcount = 0;
38075 + atomic_set(&item->refcount, 0);
38076 }
38077 }
38078
38079 @@ -59,7 +59,7 @@ void drm_global_release(void)
38080 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38081 struct drm_global_item *item = &glob[i];
38082 BUG_ON(item->object != NULL);
38083 - BUG_ON(item->refcount != 0);
38084 + BUG_ON(atomic_read(&item->refcount) != 0);
38085 }
38086 }
38087
38088 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38089 void *object;
38090
38091 mutex_lock(&item->mutex);
38092 - if (item->refcount == 0) {
38093 + if (atomic_read(&item->refcount) == 0) {
38094 item->object = kzalloc(ref->size, GFP_KERNEL);
38095 if (unlikely(item->object == NULL)) {
38096 ret = -ENOMEM;
38097 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38098 goto out_err;
38099
38100 }
38101 - ++item->refcount;
38102 + atomic_inc(&item->refcount);
38103 ref->object = item->object;
38104 object = item->object;
38105 mutex_unlock(&item->mutex);
38106 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38107 struct drm_global_item *item = &glob[ref->global_type];
38108
38109 mutex_lock(&item->mutex);
38110 - BUG_ON(item->refcount == 0);
38111 + BUG_ON(atomic_read(&item->refcount) == 0);
38112 BUG_ON(ref->object != item->object);
38113 - if (--item->refcount == 0) {
38114 + if (atomic_dec_and_test(&item->refcount)) {
38115 ref->release(ref);
38116 item->object = NULL;
38117 }
38118 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38119 index 5329832..b503f49 100644
38120 --- a/drivers/gpu/drm/drm_info.c
38121 +++ b/drivers/gpu/drm/drm_info.c
38122 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38123 struct drm_local_map *map;
38124 struct drm_map_list *r_list;
38125
38126 - /* Hardcoded from _DRM_FRAME_BUFFER,
38127 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38128 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38129 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38130 + static const char * const types[] = {
38131 + [_DRM_FRAME_BUFFER] = "FB",
38132 + [_DRM_REGISTERS] = "REG",
38133 + [_DRM_SHM] = "SHM",
38134 + [_DRM_AGP] = "AGP",
38135 + [_DRM_SCATTER_GATHER] = "SG",
38136 + [_DRM_CONSISTENT] = "PCI",
38137 + [_DRM_GEM] = "GEM" };
38138 const char *type;
38139 int i;
38140
38141 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38142 map = r_list->map;
38143 if (!map)
38144 continue;
38145 - if (map->type < 0 || map->type > 5)
38146 + if (map->type >= ARRAY_SIZE(types))
38147 type = "??";
38148 else
38149 type = types[map->type];
38150 @@ -257,7 +261,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38151 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38152 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38153 vma->vm_flags & VM_IO ? 'i' : '-',
38154 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38155 + 0);
38156 +#else
38157 vma->vm_pgoff);
38158 +#endif
38159
38160 #if defined(__i386__)
38161 pgprot = pgprot_val(vma->vm_page_prot);
38162 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38163 index 2f4c434..dd12cd2 100644
38164 --- a/drivers/gpu/drm/drm_ioc32.c
38165 +++ b/drivers/gpu/drm/drm_ioc32.c
38166 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38167 request = compat_alloc_user_space(nbytes);
38168 if (!access_ok(VERIFY_WRITE, request, nbytes))
38169 return -EFAULT;
38170 - list = (struct drm_buf_desc *) (request + 1);
38171 + list = (struct drm_buf_desc __user *) (request + 1);
38172
38173 if (__put_user(count, &request->count)
38174 || __put_user(list, &request->list))
38175 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38176 request = compat_alloc_user_space(nbytes);
38177 if (!access_ok(VERIFY_WRITE, request, nbytes))
38178 return -EFAULT;
38179 - list = (struct drm_buf_pub *) (request + 1);
38180 + list = (struct drm_buf_pub __user *) (request + 1);
38181
38182 if (__put_user(count, &request->count)
38183 || __put_user(list, &request->list))
38184 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38185 return 0;
38186 }
38187
38188 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38189 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38190 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38191 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38192 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38193 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38194 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38195 {
38196 unsigned int nr = DRM_IOCTL_NR(cmd);
38197 - drm_ioctl_compat_t *fn;
38198 int ret;
38199
38200 /* Assume that ioctls without an explicit compat routine will just
38201 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38202 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38203 return drm_ioctl(filp, cmd, arg);
38204
38205 - fn = drm_compat_ioctls[nr];
38206 -
38207 - if (fn != NULL)
38208 - ret = (*fn) (filp, cmd, arg);
38209 + if (drm_compat_ioctls[nr] != NULL)
38210 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38211 else
38212 ret = drm_ioctl(filp, cmd, arg);
38213
38214 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38215 index d752c96..fe08455 100644
38216 --- a/drivers/gpu/drm/drm_lock.c
38217 +++ b/drivers/gpu/drm/drm_lock.c
38218 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38219 if (drm_lock_take(&master->lock, lock->context)) {
38220 master->lock.file_priv = file_priv;
38221 master->lock.lock_time = jiffies;
38222 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38223 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38224 break; /* Got lock */
38225 }
38226
38227 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38228 return -EINVAL;
38229 }
38230
38231 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38232 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38233
38234 if (drm_lock_free(&master->lock, lock->context)) {
38235 /* FIXME: Should really bail out here. */
38236 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38237 index 39d8645..59e06fa 100644
38238 --- a/drivers/gpu/drm/drm_stub.c
38239 +++ b/drivers/gpu/drm/drm_stub.c
38240 @@ -484,7 +484,7 @@ void drm_unplug_dev(struct drm_device *dev)
38241
38242 drm_device_set_unplugged(dev);
38243
38244 - if (dev->open_count == 0) {
38245 + if (local_read(&dev->open_count) == 0) {
38246 drm_put_dev(dev);
38247 }
38248 mutex_unlock(&drm_global_mutex);
38249 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38250 index 2290b3b..22056a1 100644
38251 --- a/drivers/gpu/drm/drm_sysfs.c
38252 +++ b/drivers/gpu/drm/drm_sysfs.c
38253 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38254 int drm_sysfs_device_add(struct drm_minor *minor)
38255 {
38256 int err;
38257 - char *minor_str;
38258 + const char *minor_str;
38259
38260 minor->kdev.parent = minor->dev->dev;
38261
38262 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38263 index ab1892eb..d7009ca 100644
38264 --- a/drivers/gpu/drm/i810/i810_dma.c
38265 +++ b/drivers/gpu/drm/i810/i810_dma.c
38266 @@ -944,8 +944,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38267 dma->buflist[vertex->idx],
38268 vertex->discard, vertex->used);
38269
38270 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38271 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38272 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38273 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38274 sarea_priv->last_enqueue = dev_priv->counter - 1;
38275 sarea_priv->last_dispatch = (int)hw_status[5];
38276
38277 @@ -1105,8 +1105,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38278 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38279 mc->last_render);
38280
38281 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38282 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38283 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38284 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38285 sarea_priv->last_enqueue = dev_priv->counter - 1;
38286 sarea_priv->last_dispatch = (int)hw_status[5];
38287
38288 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38289 index d4d16ed..8fb0b51 100644
38290 --- a/drivers/gpu/drm/i810/i810_drv.h
38291 +++ b/drivers/gpu/drm/i810/i810_drv.h
38292 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38293 int page_flipping;
38294
38295 wait_queue_head_t irq_queue;
38296 - atomic_t irq_received;
38297 - atomic_t irq_emitted;
38298 + atomic_unchecked_t irq_received;
38299 + atomic_unchecked_t irq_emitted;
38300
38301 int front_offset;
38302 } drm_i810_private_t;
38303 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38304 index a6f4cb5..6b2beb2 100644
38305 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38306 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38307 @@ -624,7 +624,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38308 I915_READ(GTIMR));
38309 }
38310 seq_printf(m, "Interrupts received: %d\n",
38311 - atomic_read(&dev_priv->irq_received));
38312 + atomic_read_unchecked(&dev_priv->irq_received));
38313 for_each_ring(ring, dev_priv, i) {
38314 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38315 seq_printf(m,
38316 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38317 index d5c784d..06e5c36 100644
38318 --- a/drivers/gpu/drm/i915/i915_dma.c
38319 +++ b/drivers/gpu/drm/i915/i915_dma.c
38320 @@ -1263,7 +1263,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38321 bool can_switch;
38322
38323 spin_lock(&dev->count_lock);
38324 - can_switch = (dev->open_count == 0);
38325 + can_switch = (local_read(&dev->open_count) == 0);
38326 spin_unlock(&dev->count_lock);
38327 return can_switch;
38328 }
38329 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38330 index ab0f2c0..53c1bda 100644
38331 --- a/drivers/gpu/drm/i915/i915_drv.h
38332 +++ b/drivers/gpu/drm/i915/i915_drv.h
38333 @@ -1181,7 +1181,7 @@ typedef struct drm_i915_private {
38334 drm_dma_handle_t *status_page_dmah;
38335 struct resource mch_res;
38336
38337 - atomic_t irq_received;
38338 + atomic_unchecked_t irq_received;
38339
38340 /* protects the irq masks */
38341 spinlock_t irq_lock;
38342 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38343 index bf34577..3fd2ffa 100644
38344 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38345 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38346 @@ -768,9 +768,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38347
38348 static int
38349 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38350 - int count)
38351 + unsigned int count)
38352 {
38353 - int i;
38354 + unsigned int i;
38355 int relocs_total = 0;
38356 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38357
38358 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38359 index 3c59584..500f2e9 100644
38360 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38361 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38362 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38363 (unsigned long)request);
38364 }
38365
38366 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38367 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38368 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38369 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38370 [DRM_I915_GETPARAM] = compat_i915_getparam,
38371 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38372 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38373 {
38374 unsigned int nr = DRM_IOCTL_NR(cmd);
38375 - drm_ioctl_compat_t *fn = NULL;
38376 int ret;
38377
38378 if (nr < DRM_COMMAND_BASE)
38379 return drm_compat_ioctl(filp, cmd, arg);
38380
38381 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38382 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38383 -
38384 - if (fn != NULL)
38385 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38386 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38387 ret = (*fn) (filp, cmd, arg);
38388 - else
38389 + } else
38390 ret = drm_ioctl(filp, cmd, arg);
38391
38392 return ret;
38393 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38394 index 4b91228..590c643 100644
38395 --- a/drivers/gpu/drm/i915/i915_irq.c
38396 +++ b/drivers/gpu/drm/i915/i915_irq.c
38397 @@ -1085,7 +1085,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38398 int pipe;
38399 u32 pipe_stats[I915_MAX_PIPES];
38400
38401 - atomic_inc(&dev_priv->irq_received);
38402 + atomic_inc_unchecked(&dev_priv->irq_received);
38403
38404 while (true) {
38405 iir = I915_READ(VLV_IIR);
38406 @@ -1390,7 +1390,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38407 irqreturn_t ret = IRQ_NONE;
38408 bool err_int_reenable = false;
38409
38410 - atomic_inc(&dev_priv->irq_received);
38411 + atomic_inc_unchecked(&dev_priv->irq_received);
38412
38413 /* We get interrupts on unclaimed registers, so check for this before we
38414 * do any I915_{READ,WRITE}. */
38415 @@ -2146,7 +2146,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38416 {
38417 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38418
38419 - atomic_set(&dev_priv->irq_received, 0);
38420 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38421
38422 I915_WRITE(HWSTAM, 0xeffe);
38423
38424 @@ -2164,7 +2164,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38425 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38426 int pipe;
38427
38428 - atomic_set(&dev_priv->irq_received, 0);
38429 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38430
38431 /* VLV magic */
38432 I915_WRITE(VLV_IMR, 0);
38433 @@ -2452,7 +2452,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38434 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38435 int pipe;
38436
38437 - atomic_set(&dev_priv->irq_received, 0);
38438 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38439
38440 for_each_pipe(pipe)
38441 I915_WRITE(PIPESTAT(pipe), 0);
38442 @@ -2530,7 +2530,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38443 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38444 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38445
38446 - atomic_inc(&dev_priv->irq_received);
38447 + atomic_inc_unchecked(&dev_priv->irq_received);
38448
38449 iir = I915_READ16(IIR);
38450 if (iir == 0)
38451 @@ -2604,7 +2604,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38452 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38453 int pipe;
38454
38455 - atomic_set(&dev_priv->irq_received, 0);
38456 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38457
38458 if (I915_HAS_HOTPLUG(dev)) {
38459 I915_WRITE(PORT_HOTPLUG_EN, 0);
38460 @@ -2703,7 +2703,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38461 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38462 int pipe, ret = IRQ_NONE;
38463
38464 - atomic_inc(&dev_priv->irq_received);
38465 + atomic_inc_unchecked(&dev_priv->irq_received);
38466
38467 iir = I915_READ(IIR);
38468 do {
38469 @@ -2827,7 +2827,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38470 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38471 int pipe;
38472
38473 - atomic_set(&dev_priv->irq_received, 0);
38474 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38475
38476 I915_WRITE(PORT_HOTPLUG_EN, 0);
38477 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38478 @@ -2941,7 +2941,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38479 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38480 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38481
38482 - atomic_inc(&dev_priv->irq_received);
38483 + atomic_inc_unchecked(&dev_priv->irq_received);
38484
38485 iir = I915_READ(IIR);
38486
38487 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38488 index d78d33f..01d7c58 100644
38489 --- a/drivers/gpu/drm/i915/intel_display.c
38490 +++ b/drivers/gpu/drm/i915/intel_display.c
38491 @@ -9972,13 +9972,13 @@ struct intel_quirk {
38492 int subsystem_vendor;
38493 int subsystem_device;
38494 void (*hook)(struct drm_device *dev);
38495 -};
38496 +} __do_const;
38497
38498 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38499 struct intel_dmi_quirk {
38500 void (*hook)(struct drm_device *dev);
38501 const struct dmi_system_id (*dmi_id_list)[];
38502 -};
38503 +} __do_const;
38504
38505 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38506 {
38507 @@ -9986,18 +9986,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38508 return 1;
38509 }
38510
38511 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38512 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38513 {
38514 - .dmi_id_list = &(const struct dmi_system_id[]) {
38515 - {
38516 - .callback = intel_dmi_reverse_brightness,
38517 - .ident = "NCR Corporation",
38518 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38519 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38520 - },
38521 - },
38522 - { } /* terminating entry */
38523 + .callback = intel_dmi_reverse_brightness,
38524 + .ident = "NCR Corporation",
38525 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38526 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38527 },
38528 + },
38529 + { } /* terminating entry */
38530 +};
38531 +
38532 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38533 + {
38534 + .dmi_id_list = &intel_dmi_quirks_table,
38535 .hook = quirk_invert_brightness,
38536 },
38537 };
38538 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38539 index ca4bc54..ee598a2 100644
38540 --- a/drivers/gpu/drm/mga/mga_drv.h
38541 +++ b/drivers/gpu/drm/mga/mga_drv.h
38542 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38543 u32 clear_cmd;
38544 u32 maccess;
38545
38546 - atomic_t vbl_received; /**< Number of vblanks received. */
38547 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38548 wait_queue_head_t fence_queue;
38549 - atomic_t last_fence_retired;
38550 + atomic_unchecked_t last_fence_retired;
38551 u32 next_fence_to_post;
38552
38553 unsigned int fb_cpp;
38554 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38555 index 709e90d..89a1c0d 100644
38556 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38557 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38558 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38559 return 0;
38560 }
38561
38562 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38563 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38564 [DRM_MGA_INIT] = compat_mga_init,
38565 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38566 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38567 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38568 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38569 {
38570 unsigned int nr = DRM_IOCTL_NR(cmd);
38571 - drm_ioctl_compat_t *fn = NULL;
38572 int ret;
38573
38574 if (nr < DRM_COMMAND_BASE)
38575 return drm_compat_ioctl(filp, cmd, arg);
38576
38577 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38578 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38579 -
38580 - if (fn != NULL)
38581 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38582 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38583 ret = (*fn) (filp, cmd, arg);
38584 - else
38585 + } else
38586 ret = drm_ioctl(filp, cmd, arg);
38587
38588 return ret;
38589 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38590 index 598c281..60d590e 100644
38591 --- a/drivers/gpu/drm/mga/mga_irq.c
38592 +++ b/drivers/gpu/drm/mga/mga_irq.c
38593 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38594 if (crtc != 0)
38595 return 0;
38596
38597 - return atomic_read(&dev_priv->vbl_received);
38598 + return atomic_read_unchecked(&dev_priv->vbl_received);
38599 }
38600
38601
38602 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38603 /* VBLANK interrupt */
38604 if (status & MGA_VLINEPEN) {
38605 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38606 - atomic_inc(&dev_priv->vbl_received);
38607 + atomic_inc_unchecked(&dev_priv->vbl_received);
38608 drm_handle_vblank(dev, 0);
38609 handled = 1;
38610 }
38611 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38612 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38613 MGA_WRITE(MGA_PRIMEND, prim_end);
38614
38615 - atomic_inc(&dev_priv->last_fence_retired);
38616 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38617 DRM_WAKEUP(&dev_priv->fence_queue);
38618 handled = 1;
38619 }
38620 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38621 * using fences.
38622 */
38623 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38624 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38625 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38626 - *sequence) <= (1 << 23)));
38627
38628 *sequence = cur_fence;
38629 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38630 index 3e72876..d1c15ad 100644
38631 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38632 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38633 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38634 struct bit_table {
38635 const char id;
38636 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38637 -};
38638 +} __no_const;
38639
38640 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38641
38642 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38643 index 994fd6e..6e12565 100644
38644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38645 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38646 @@ -94,7 +94,6 @@ struct nouveau_drm {
38647 struct drm_global_reference mem_global_ref;
38648 struct ttm_bo_global_ref bo_global_ref;
38649 struct ttm_bo_device bdev;
38650 - atomic_t validate_sequence;
38651 int (*move)(struct nouveau_channel *,
38652 struct ttm_buffer_object *,
38653 struct ttm_mem_reg *, struct ttm_mem_reg *);
38654 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38655 index c1a7e5a..38b8539 100644
38656 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38657 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38658 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38659 unsigned long arg)
38660 {
38661 unsigned int nr = DRM_IOCTL_NR(cmd);
38662 - drm_ioctl_compat_t *fn = NULL;
38663 + drm_ioctl_compat_t fn = NULL;
38664 int ret;
38665
38666 if (nr < DRM_COMMAND_BASE)
38667 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38668 index 81638d7..2e45854 100644
38669 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38670 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38671 @@ -65,7 +65,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38672 bool can_switch;
38673
38674 spin_lock(&dev->count_lock);
38675 - can_switch = (dev->open_count == 0);
38676 + can_switch = (local_read(&dev->open_count) == 0);
38677 spin_unlock(&dev->count_lock);
38678 return can_switch;
38679 }
38680 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
38681 index eb89653..613cf71 100644
38682 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
38683 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
38684 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
38685 int ret;
38686
38687 mutex_lock(&qdev->async_io_mutex);
38688 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
38689 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
38690 if (qdev->last_sent_io_cmd > irq_num) {
38691 if (intr)
38692 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
38693 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38694 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38695 else
38696 ret = wait_event_timeout(qdev->io_cmd_event,
38697 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38698 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38699 /* 0 is timeout, just bail the "hw" has gone away */
38700 if (ret <= 0)
38701 goto out;
38702 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
38703 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
38704 }
38705 outb(val, addr);
38706 qdev->last_sent_io_cmd = irq_num + 1;
38707 if (intr)
38708 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
38709 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38710 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38711 else
38712 ret = wait_event_timeout(qdev->io_cmd_event,
38713 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38714 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38715 out:
38716 if (ret > 0)
38717 ret = 0;
38718 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
38719 index c3c2bbd..bc3c0fb 100644
38720 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
38721 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
38722 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
38723 struct drm_info_node *node = (struct drm_info_node *) m->private;
38724 struct qxl_device *qdev = node->minor->dev->dev_private;
38725
38726 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
38727 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
38728 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
38729 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
38730 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
38731 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
38732 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
38733 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
38734 seq_printf(m, "%d\n", qdev->irq_received_error);
38735 return 0;
38736 }
38737 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
38738 index f7c9add..fb971d2 100644
38739 --- a/drivers/gpu/drm/qxl/qxl_drv.h
38740 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
38741 @@ -290,10 +290,10 @@ struct qxl_device {
38742 unsigned int last_sent_io_cmd;
38743
38744 /* interrupt handling */
38745 - atomic_t irq_received;
38746 - atomic_t irq_received_display;
38747 - atomic_t irq_received_cursor;
38748 - atomic_t irq_received_io_cmd;
38749 + atomic_unchecked_t irq_received;
38750 + atomic_unchecked_t irq_received_display;
38751 + atomic_unchecked_t irq_received_cursor;
38752 + atomic_unchecked_t irq_received_io_cmd;
38753 unsigned irq_received_error;
38754 wait_queue_head_t display_event;
38755 wait_queue_head_t cursor_event;
38756 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
38757 index 21393dc..329f3a9 100644
38758 --- a/drivers/gpu/drm/qxl/qxl_irq.c
38759 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
38760 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
38761
38762 pending = xchg(&qdev->ram_header->int_pending, 0);
38763
38764 - atomic_inc(&qdev->irq_received);
38765 + atomic_inc_unchecked(&qdev->irq_received);
38766
38767 if (pending & QXL_INTERRUPT_DISPLAY) {
38768 - atomic_inc(&qdev->irq_received_display);
38769 + atomic_inc_unchecked(&qdev->irq_received_display);
38770 wake_up_all(&qdev->display_event);
38771 qxl_queue_garbage_collect(qdev, false);
38772 }
38773 if (pending & QXL_INTERRUPT_CURSOR) {
38774 - atomic_inc(&qdev->irq_received_cursor);
38775 + atomic_inc_unchecked(&qdev->irq_received_cursor);
38776 wake_up_all(&qdev->cursor_event);
38777 }
38778 if (pending & QXL_INTERRUPT_IO_CMD) {
38779 - atomic_inc(&qdev->irq_received_io_cmd);
38780 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
38781 wake_up_all(&qdev->io_cmd_event);
38782 }
38783 if (pending & QXL_INTERRUPT_ERROR) {
38784 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
38785 init_waitqueue_head(&qdev->io_cmd_event);
38786 INIT_WORK(&qdev->client_monitors_config_work,
38787 qxl_client_monitors_config_work_func);
38788 - atomic_set(&qdev->irq_received, 0);
38789 - atomic_set(&qdev->irq_received_display, 0);
38790 - atomic_set(&qdev->irq_received_cursor, 0);
38791 - atomic_set(&qdev->irq_received_io_cmd, 0);
38792 + atomic_set_unchecked(&qdev->irq_received, 0);
38793 + atomic_set_unchecked(&qdev->irq_received_display, 0);
38794 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
38795 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
38796 qdev->irq_received_error = 0;
38797 ret = drm_irq_install(qdev->ddev);
38798 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
38799 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38800 index 037786d..2a95e33 100644
38801 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38802 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38803 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38804 }
38805 }
38806
38807 -static struct vm_operations_struct qxl_ttm_vm_ops;
38808 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38809 static const struct vm_operations_struct *ttm_vm_ops;
38810
38811 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38812 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38813 return r;
38814 if (unlikely(ttm_vm_ops == NULL)) {
38815 ttm_vm_ops = vma->vm_ops;
38816 + pax_open_kernel();
38817 qxl_ttm_vm_ops = *ttm_vm_ops;
38818 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38819 + pax_close_kernel();
38820 }
38821 vma->vm_ops = &qxl_ttm_vm_ops;
38822 return 0;
38823 @@ -558,25 +560,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38824 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38825 {
38826 #if defined(CONFIG_DEBUG_FS)
38827 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38828 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38829 - unsigned i;
38830 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38831 + {
38832 + .name = "qxl_mem_mm",
38833 + .show = &qxl_mm_dump_table,
38834 + },
38835 + {
38836 + .name = "qxl_surf_mm",
38837 + .show = &qxl_mm_dump_table,
38838 + }
38839 + };
38840
38841 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38842 - if (i == 0)
38843 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38844 - else
38845 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38846 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38847 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38848 - qxl_mem_types_list[i].driver_features = 0;
38849 - if (i == 0)
38850 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38851 - else
38852 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38853 + pax_open_kernel();
38854 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38855 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38856 + pax_close_kernel();
38857
38858 - }
38859 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38860 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38861 #else
38862 return 0;
38863 #endif
38864 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38865 index c451257..0ad2134 100644
38866 --- a/drivers/gpu/drm/r128/r128_cce.c
38867 +++ b/drivers/gpu/drm/r128/r128_cce.c
38868 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38869
38870 /* GH: Simple idle check.
38871 */
38872 - atomic_set(&dev_priv->idle_count, 0);
38873 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38874
38875 /* We don't support anything other than bus-mastering ring mode,
38876 * but the ring can be in either AGP or PCI space for the ring
38877 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38878 index 56eb5e3..c4ec43d 100644
38879 --- a/drivers/gpu/drm/r128/r128_drv.h
38880 +++ b/drivers/gpu/drm/r128/r128_drv.h
38881 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38882 int is_pci;
38883 unsigned long cce_buffers_offset;
38884
38885 - atomic_t idle_count;
38886 + atomic_unchecked_t idle_count;
38887
38888 int page_flipping;
38889 int current_page;
38890 u32 crtc_offset;
38891 u32 crtc_offset_cntl;
38892
38893 - atomic_t vbl_received;
38894 + atomic_unchecked_t vbl_received;
38895
38896 u32 color_fmt;
38897 unsigned int front_offset;
38898 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38899 index a954c54..9cc595c 100644
38900 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38901 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38902 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38903 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38904 }
38905
38906 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38907 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38908 [DRM_R128_INIT] = compat_r128_init,
38909 [DRM_R128_DEPTH] = compat_r128_depth,
38910 [DRM_R128_STIPPLE] = compat_r128_stipple,
38911 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38912 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38913 {
38914 unsigned int nr = DRM_IOCTL_NR(cmd);
38915 - drm_ioctl_compat_t *fn = NULL;
38916 int ret;
38917
38918 if (nr < DRM_COMMAND_BASE)
38919 return drm_compat_ioctl(filp, cmd, arg);
38920
38921 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38922 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38923 -
38924 - if (fn != NULL)
38925 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38926 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38927 ret = (*fn) (filp, cmd, arg);
38928 - else
38929 + } else
38930 ret = drm_ioctl(filp, cmd, arg);
38931
38932 return ret;
38933 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38934 index 2ea4f09..d391371 100644
38935 --- a/drivers/gpu/drm/r128/r128_irq.c
38936 +++ b/drivers/gpu/drm/r128/r128_irq.c
38937 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38938 if (crtc != 0)
38939 return 0;
38940
38941 - return atomic_read(&dev_priv->vbl_received);
38942 + return atomic_read_unchecked(&dev_priv->vbl_received);
38943 }
38944
38945 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38946 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38947 /* VBLANK interrupt */
38948 if (status & R128_CRTC_VBLANK_INT) {
38949 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38950 - atomic_inc(&dev_priv->vbl_received);
38951 + atomic_inc_unchecked(&dev_priv->vbl_received);
38952 drm_handle_vblank(dev, 0);
38953 return IRQ_HANDLED;
38954 }
38955 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38956 index 01dd9ae..6352f04 100644
38957 --- a/drivers/gpu/drm/r128/r128_state.c
38958 +++ b/drivers/gpu/drm/r128/r128_state.c
38959 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38960
38961 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38962 {
38963 - if (atomic_read(&dev_priv->idle_count) == 0)
38964 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38965 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38966 else
38967 - atomic_set(&dev_priv->idle_count, 0);
38968 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38969 }
38970
38971 #endif
38972 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38973 index af85299..ed9ac8d 100644
38974 --- a/drivers/gpu/drm/radeon/mkregtable.c
38975 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38976 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38977 regex_t mask_rex;
38978 regmatch_t match[4];
38979 char buf[1024];
38980 - size_t end;
38981 + long end;
38982 int len;
38983 int done = 0;
38984 int r;
38985 unsigned o;
38986 struct offset *offset;
38987 char last_reg_s[10];
38988 - int last_reg;
38989 + unsigned long last_reg;
38990
38991 if (regcomp
38992 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38993 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38994 index 841d0e0..9eaa268 100644
38995 --- a/drivers/gpu/drm/radeon/radeon_device.c
38996 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38997 @@ -1117,7 +1117,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38998 bool can_switch;
38999
39000 spin_lock(&dev->count_lock);
39001 - can_switch = (dev->open_count == 0);
39002 + can_switch = (local_read(&dev->open_count) == 0);
39003 spin_unlock(&dev->count_lock);
39004 return can_switch;
39005 }
39006 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39007 index b369d42..8dd04eb 100644
39008 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39009 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39010 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39011
39012 /* SW interrupt */
39013 wait_queue_head_t swi_queue;
39014 - atomic_t swi_emitted;
39015 + atomic_unchecked_t swi_emitted;
39016 int vblank_crtc;
39017 uint32_t irq_enable_reg;
39018 uint32_t r500_disp_irq_reg;
39019 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39020 index c180df8..5fd8186 100644
39021 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39022 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39023 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39024 request = compat_alloc_user_space(sizeof(*request));
39025 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39026 || __put_user(req32.param, &request->param)
39027 - || __put_user((void __user *)(unsigned long)req32.value,
39028 + || __put_user((unsigned long)req32.value,
39029 &request->value))
39030 return -EFAULT;
39031
39032 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39033 #define compat_radeon_cp_setparam NULL
39034 #endif /* X86_64 || IA64 */
39035
39036 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39037 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39038 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39039 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39040 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39041 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39042 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39043 {
39044 unsigned int nr = DRM_IOCTL_NR(cmd);
39045 - drm_ioctl_compat_t *fn = NULL;
39046 int ret;
39047
39048 if (nr < DRM_COMMAND_BASE)
39049 return drm_compat_ioctl(filp, cmd, arg);
39050
39051 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39052 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39053 -
39054 - if (fn != NULL)
39055 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39056 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39057 ret = (*fn) (filp, cmd, arg);
39058 - else
39059 + } else
39060 ret = drm_ioctl(filp, cmd, arg);
39061
39062 return ret;
39063 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39064 index 8d68e97..9dcfed8 100644
39065 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39066 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39067 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39068 unsigned int ret;
39069 RING_LOCALS;
39070
39071 - atomic_inc(&dev_priv->swi_emitted);
39072 - ret = atomic_read(&dev_priv->swi_emitted);
39073 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39074 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39075
39076 BEGIN_RING(4);
39077 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39078 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39079 drm_radeon_private_t *dev_priv =
39080 (drm_radeon_private_t *) dev->dev_private;
39081
39082 - atomic_set(&dev_priv->swi_emitted, 0);
39083 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39084 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39085
39086 dev->max_vblank_count = 0x001fffff;
39087 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39088 index 4d20910..6726b6d 100644
39089 --- a/drivers/gpu/drm/radeon/radeon_state.c
39090 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39091 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39092 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39093 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39094
39095 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39096 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39097 sarea_priv->nbox * sizeof(depth_boxes[0])))
39098 return -EFAULT;
39099
39100 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39101 {
39102 drm_radeon_private_t *dev_priv = dev->dev_private;
39103 drm_radeon_getparam_t *param = data;
39104 - int value;
39105 + int value = 0;
39106
39107 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39108
39109 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39110 index 71245d6..94c556d 100644
39111 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39112 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39113 @@ -784,7 +784,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39114 man->size = size >> PAGE_SHIFT;
39115 }
39116
39117 -static struct vm_operations_struct radeon_ttm_vm_ops;
39118 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39119 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39120
39121 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39122 @@ -825,8 +825,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39123 }
39124 if (unlikely(ttm_vm_ops == NULL)) {
39125 ttm_vm_ops = vma->vm_ops;
39126 + pax_open_kernel();
39127 radeon_ttm_vm_ops = *ttm_vm_ops;
39128 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39129 + pax_close_kernel();
39130 }
39131 vma->vm_ops = &radeon_ttm_vm_ops;
39132 return 0;
39133 @@ -855,38 +857,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39134 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39135 {
39136 #if defined(CONFIG_DEBUG_FS)
39137 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39138 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39139 - unsigned i;
39140 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39141 + {
39142 + .name = "radeon_vram_mm",
39143 + .show = &radeon_mm_dump_table,
39144 + },
39145 + {
39146 + .name = "radeon_gtt_mm",
39147 + .show = &radeon_mm_dump_table,
39148 + },
39149 + {
39150 + .name = "ttm_page_pool",
39151 + .show = &ttm_page_alloc_debugfs,
39152 + },
39153 + {
39154 + .name = "ttm_dma_page_pool",
39155 + .show = &ttm_dma_page_alloc_debugfs,
39156 + },
39157 + };
39158 + unsigned i = RADEON_DEBUGFS_MEM_TYPES + 1;
39159
39160 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39161 - if (i == 0)
39162 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39163 - else
39164 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39165 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39166 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39167 - radeon_mem_types_list[i].driver_features = 0;
39168 - if (i == 0)
39169 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39170 - else
39171 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39172 -
39173 - }
39174 - /* Add ttm page pool to debugfs */
39175 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39176 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39177 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39178 - radeon_mem_types_list[i].driver_features = 0;
39179 - radeon_mem_types_list[i++].data = NULL;
39180 + pax_open_kernel();
39181 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39182 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39183 + pax_close_kernel();
39184 #ifdef CONFIG_SWIOTLB
39185 - if (swiotlb_nr_tbl()) {
39186 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39187 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39188 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39189 - radeon_mem_types_list[i].driver_features = 0;
39190 - radeon_mem_types_list[i++].data = NULL;
39191 - }
39192 + if (swiotlb_nr_tbl())
39193 + i++;
39194 #endif
39195 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39196
39197 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39198 index 1447d79..40b2a5b 100644
39199 --- a/drivers/gpu/drm/radeon/rs690.c
39200 +++ b/drivers/gpu/drm/radeon/rs690.c
39201 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39202 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39203 rdev->pm.sideport_bandwidth.full)
39204 max_bandwidth = rdev->pm.sideport_bandwidth;
39205 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39206 + read_delay_latency.full = dfixed_const(800 * 1000);
39207 read_delay_latency.full = dfixed_div(read_delay_latency,
39208 rdev->pm.igp_sideport_mclk);
39209 + a.full = dfixed_const(370);
39210 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39211 } else {
39212 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39213 rdev->pm.k8_bandwidth.full)
39214 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39215 index dbc2def..0a9f710 100644
39216 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39217 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39218 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39219 zone->glob = glob;
39220 glob->zone_kernel = zone;
39221 ret = kobject_init_and_add(
39222 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39223 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39224 if (unlikely(ret != 0)) {
39225 kobject_put(&zone->kobj);
39226 return ret;
39227 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39228 zone->glob = glob;
39229 glob->zone_dma32 = zone;
39230 ret = kobject_init_and_add(
39231 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39232 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39233 if (unlikely(ret != 0)) {
39234 kobject_put(&zone->kobj);
39235 return ret;
39236 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39237 index 863bef9..cba15cf 100644
39238 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39239 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39240 @@ -391,9 +391,9 @@ out:
39241 static unsigned long
39242 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
39243 {
39244 - static atomic_t start_pool = ATOMIC_INIT(0);
39245 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39246 unsigned i;
39247 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39248 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39249 struct ttm_page_pool *pool;
39250 int shrink_pages = sc->nr_to_scan;
39251 unsigned long freed = 0;
39252 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39253 index 97e9d61..bf23c461 100644
39254 --- a/drivers/gpu/drm/udl/udl_fb.c
39255 +++ b/drivers/gpu/drm/udl/udl_fb.c
39256 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39257 fb_deferred_io_cleanup(info);
39258 kfree(info->fbdefio);
39259 info->fbdefio = NULL;
39260 - info->fbops->fb_mmap = udl_fb_mmap;
39261 }
39262
39263 pr_warn("released /dev/fb%d user=%d count=%d\n",
39264 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39265 index a811ef2..ff99b05 100644
39266 --- a/drivers/gpu/drm/via/via_drv.h
39267 +++ b/drivers/gpu/drm/via/via_drv.h
39268 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39269 typedef uint32_t maskarray_t[5];
39270
39271 typedef struct drm_via_irq {
39272 - atomic_t irq_received;
39273 + atomic_unchecked_t irq_received;
39274 uint32_t pending_mask;
39275 uint32_t enable_mask;
39276 wait_queue_head_t irq_queue;
39277 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39278 struct timeval last_vblank;
39279 int last_vblank_valid;
39280 unsigned usec_per_vblank;
39281 - atomic_t vbl_received;
39282 + atomic_unchecked_t vbl_received;
39283 drm_via_state_t hc_state;
39284 char pci_buf[VIA_PCI_BUF_SIZE];
39285 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39286 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39287 index ac98964..5dbf512 100644
39288 --- a/drivers/gpu/drm/via/via_irq.c
39289 +++ b/drivers/gpu/drm/via/via_irq.c
39290 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39291 if (crtc != 0)
39292 return 0;
39293
39294 - return atomic_read(&dev_priv->vbl_received);
39295 + return atomic_read_unchecked(&dev_priv->vbl_received);
39296 }
39297
39298 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39299 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39300
39301 status = VIA_READ(VIA_REG_INTERRUPT);
39302 if (status & VIA_IRQ_VBLANK_PENDING) {
39303 - atomic_inc(&dev_priv->vbl_received);
39304 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39305 + atomic_inc_unchecked(&dev_priv->vbl_received);
39306 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39307 do_gettimeofday(&cur_vblank);
39308 if (dev_priv->last_vblank_valid) {
39309 dev_priv->usec_per_vblank =
39310 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39311 dev_priv->last_vblank = cur_vblank;
39312 dev_priv->last_vblank_valid = 1;
39313 }
39314 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39315 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39316 DRM_DEBUG("US per vblank is: %u\n",
39317 dev_priv->usec_per_vblank);
39318 }
39319 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39320
39321 for (i = 0; i < dev_priv->num_irqs; ++i) {
39322 if (status & cur_irq->pending_mask) {
39323 - atomic_inc(&cur_irq->irq_received);
39324 + atomic_inc_unchecked(&cur_irq->irq_received);
39325 DRM_WAKEUP(&cur_irq->irq_queue);
39326 handled = 1;
39327 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39328 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39329 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39330 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39331 masks[irq][4]));
39332 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39333 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39334 } else {
39335 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39336 (((cur_irq_sequence =
39337 - atomic_read(&cur_irq->irq_received)) -
39338 + atomic_read_unchecked(&cur_irq->irq_received)) -
39339 *sequence) <= (1 << 23)));
39340 }
39341 *sequence = cur_irq_sequence;
39342 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39343 }
39344
39345 for (i = 0; i < dev_priv->num_irqs; ++i) {
39346 - atomic_set(&cur_irq->irq_received, 0);
39347 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39348 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39349 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39350 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39351 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39352 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39353 case VIA_IRQ_RELATIVE:
39354 irqwait->request.sequence +=
39355 - atomic_read(&cur_irq->irq_received);
39356 + atomic_read_unchecked(&cur_irq->irq_received);
39357 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39358 case VIA_IRQ_ABSOLUTE:
39359 break;
39360 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39361 index 150ec64..f5165f2 100644
39362 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39363 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39364 @@ -290,7 +290,7 @@ struct vmw_private {
39365 * Fencing and IRQs.
39366 */
39367
39368 - atomic_t marker_seq;
39369 + atomic_unchecked_t marker_seq;
39370 wait_queue_head_t fence_queue;
39371 wait_queue_head_t fifo_queue;
39372 int fence_queue_waiters; /* Protected by hw_mutex */
39373 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39374 index 3eb1486..0a47ee9 100644
39375 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39376 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39377 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39378 (unsigned int) min,
39379 (unsigned int) fifo->capabilities);
39380
39381 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39382 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39383 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39384 vmw_marker_queue_init(&fifo->marker_queue);
39385 return vmw_fifo_send_fence(dev_priv, &dummy);
39386 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39387 if (reserveable)
39388 iowrite32(bytes, fifo_mem +
39389 SVGA_FIFO_RESERVED);
39390 - return fifo_mem + (next_cmd >> 2);
39391 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39392 } else {
39393 need_bounce = true;
39394 }
39395 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39396
39397 fm = vmw_fifo_reserve(dev_priv, bytes);
39398 if (unlikely(fm == NULL)) {
39399 - *seqno = atomic_read(&dev_priv->marker_seq);
39400 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39401 ret = -ENOMEM;
39402 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39403 false, 3*HZ);
39404 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39405 }
39406
39407 do {
39408 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39409 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39410 } while (*seqno == 0);
39411
39412 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39413 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39414 index c509d40..3b640c3 100644
39415 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39416 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39417 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39418 int ret;
39419
39420 num_clips = arg->num_clips;
39421 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39422 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39423
39424 if (unlikely(num_clips == 0))
39425 return 0;
39426 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39427 int ret;
39428
39429 num_clips = arg->num_clips;
39430 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39431 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39432
39433 if (unlikely(num_clips == 0))
39434 return 0;
39435 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39436 index 4640adb..e1384ed 100644
39437 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39438 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39439 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39440 * emitted. Then the fence is stale and signaled.
39441 */
39442
39443 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39444 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39445 > VMW_FENCE_WRAP);
39446
39447 return ret;
39448 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39449
39450 if (fifo_idle)
39451 down_read(&fifo_state->rwsem);
39452 - signal_seq = atomic_read(&dev_priv->marker_seq);
39453 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39454 ret = 0;
39455
39456 for (;;) {
39457 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39458 index 8a8725c2..afed796 100644
39459 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39460 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39461 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39462 while (!vmw_lag_lt(queue, us)) {
39463 spin_lock(&queue->lock);
39464 if (list_empty(&queue->head))
39465 - seqno = atomic_read(&dev_priv->marker_seq);
39466 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39467 else {
39468 marker = list_first_entry(&queue->head,
39469 struct vmw_marker, head);
39470 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39471 index b1a05ad..1c9d899 100644
39472 --- a/drivers/gpu/host1x/drm/dc.c
39473 +++ b/drivers/gpu/host1x/drm/dc.c
39474 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39475 }
39476
39477 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39478 - dc->debugfs_files[i].data = dc;
39479 + *(void **)&dc->debugfs_files[i].data = dc;
39480
39481 err = drm_debugfs_create_files(dc->debugfs_files,
39482 ARRAY_SIZE(debugfs_files),
39483 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
39484 index ec0ae2d..dc0780b 100644
39485 --- a/drivers/gpu/vga/vga_switcheroo.c
39486 +++ b/drivers/gpu/vga/vga_switcheroo.c
39487 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
39488
39489 /* this version is for the case where the power switch is separate
39490 to the device being powered down. */
39491 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
39492 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
39493 {
39494 /* copy over all the bus versions */
39495 if (dev->bus && dev->bus->pm) {
39496 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
39497 return ret;
39498 }
39499
39500 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
39501 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
39502 {
39503 /* copy over all the bus versions */
39504 if (dev->bus && dev->bus->pm) {
39505 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39506 index e80da62..bbcba01 100644
39507 --- a/drivers/hid/hid-core.c
39508 +++ b/drivers/hid/hid-core.c
39509 @@ -2417,7 +2417,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39510
39511 int hid_add_device(struct hid_device *hdev)
39512 {
39513 - static atomic_t id = ATOMIC_INIT(0);
39514 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39515 int ret;
39516
39517 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39518 @@ -2451,7 +2451,7 @@ int hid_add_device(struct hid_device *hdev)
39519 /* XXX hack, any other cleaner solution after the driver core
39520 * is converted to allow more than 20 bytes as the device name? */
39521 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39522 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39523 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39524
39525 hid_debug_register(hdev, dev_name(&hdev->dev));
39526 ret = device_add(&hdev->dev);
39527 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39528 index c13fb5b..55a3802 100644
39529 --- a/drivers/hid/hid-wiimote-debug.c
39530 +++ b/drivers/hid/hid-wiimote-debug.c
39531 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39532 else if (size == 0)
39533 return -EIO;
39534
39535 - if (copy_to_user(u, buf, size))
39536 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39537 return -EFAULT;
39538
39539 *off += size;
39540 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39541 index 93b00d7..0a71596 100644
39542 --- a/drivers/hid/uhid.c
39543 +++ b/drivers/hid/uhid.c
39544 @@ -47,7 +47,7 @@ struct uhid_device {
39545 struct mutex report_lock;
39546 wait_queue_head_t report_wait;
39547 atomic_t report_done;
39548 - atomic_t report_id;
39549 + atomic_unchecked_t report_id;
39550 struct uhid_event report_buf;
39551 };
39552
39553 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39554
39555 spin_lock_irqsave(&uhid->qlock, flags);
39556 ev->type = UHID_FEATURE;
39557 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39558 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39559 ev->u.feature.rnum = rnum;
39560 ev->u.feature.rtype = report_type;
39561
39562 @@ -446,7 +446,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39563 spin_lock_irqsave(&uhid->qlock, flags);
39564
39565 /* id for old report; drop it silently */
39566 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39567 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39568 goto unlock;
39569 if (atomic_read(&uhid->report_done))
39570 goto unlock;
39571 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39572 index 6de6c98..18319e9 100644
39573 --- a/drivers/hv/channel.c
39574 +++ b/drivers/hv/channel.c
39575 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39576 int ret = 0;
39577 int t;
39578
39579 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39580 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39581 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39582 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39583
39584 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39585 if (ret)
39586 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39587 index 88f4096..e50452e 100644
39588 --- a/drivers/hv/hv.c
39589 +++ b/drivers/hv/hv.c
39590 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39591 u64 output_address = (output) ? virt_to_phys(output) : 0;
39592 u32 output_address_hi = output_address >> 32;
39593 u32 output_address_lo = output_address & 0xFFFFFFFF;
39594 - void *hypercall_page = hv_context.hypercall_page;
39595 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39596
39597 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39598 "=a"(hv_status_lo) : "d" (control_hi),
39599 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39600 index 7e17a54..a50a33d 100644
39601 --- a/drivers/hv/hv_balloon.c
39602 +++ b/drivers/hv/hv_balloon.c
39603 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39604
39605 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39606 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39607 -static atomic_t trans_id = ATOMIC_INIT(0);
39608 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39609
39610 static int dm_ring_size = (5 * PAGE_SIZE);
39611
39612 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
39613 pr_info("Memory hot add failed\n");
39614
39615 dm->state = DM_INITIALIZED;
39616 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39617 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39618 vmbus_sendpacket(dm->dev->channel, &resp,
39619 sizeof(struct dm_hot_add_response),
39620 (unsigned long)NULL,
39621 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39622 memset(&status, 0, sizeof(struct dm_status));
39623 status.hdr.type = DM_STATUS_REPORT;
39624 status.hdr.size = sizeof(struct dm_status);
39625 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39626 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39627
39628 /*
39629 * The host expects the guest to report free memory.
39630 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39631 * send the status. This can happen if we were interrupted
39632 * after we picked our transaction ID.
39633 */
39634 - if (status.hdr.trans_id != atomic_read(&trans_id))
39635 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39636 return;
39637
39638 vmbus_sendpacket(dm->dev->channel, &status,
39639 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
39640 */
39641
39642 do {
39643 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39644 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39645 ret = vmbus_sendpacket(dm_device.dev->channel,
39646 bl_resp,
39647 bl_resp->hdr.size,
39648 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39649
39650 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39651 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39652 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39653 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39654 resp.hdr.size = sizeof(struct dm_unballoon_response);
39655
39656 vmbus_sendpacket(dm_device.dev->channel, &resp,
39657 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39658 memset(&version_req, 0, sizeof(struct dm_version_request));
39659 version_req.hdr.type = DM_VERSION_REQUEST;
39660 version_req.hdr.size = sizeof(struct dm_version_request);
39661 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39662 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39663 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39664 version_req.is_last_attempt = 1;
39665
39666 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39667 memset(&version_req, 0, sizeof(struct dm_version_request));
39668 version_req.hdr.type = DM_VERSION_REQUEST;
39669 version_req.hdr.size = sizeof(struct dm_version_request);
39670 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39671 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39672 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39673 version_req.is_last_attempt = 0;
39674
39675 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39676 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39677 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39678 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39679 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39680 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39681
39682 cap_msg.caps.cap_bits.balloon = 1;
39683 cap_msg.caps.cap_bits.hot_add = 1;
39684 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39685 index d84918f..7f38f9f 100644
39686 --- a/drivers/hv/hyperv_vmbus.h
39687 +++ b/drivers/hv/hyperv_vmbus.h
39688 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39689 struct vmbus_connection {
39690 enum vmbus_connect_state conn_state;
39691
39692 - atomic_t next_gpadl_handle;
39693 + atomic_unchecked_t next_gpadl_handle;
39694
39695 /*
39696 * Represents channel interrupts. Each bit position represents a
39697 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39698 index f9fe46f..356b119 100644
39699 --- a/drivers/hv/vmbus_drv.c
39700 +++ b/drivers/hv/vmbus_drv.c
39701 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39702 {
39703 int ret = 0;
39704
39705 - static atomic_t device_num = ATOMIC_INIT(0);
39706 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39707
39708 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39709 - atomic_inc_return(&device_num));
39710 + atomic_inc_return_unchecked(&device_num));
39711
39712 child_device_obj->device.bus = &hv_bus;
39713 child_device_obj->device.parent = &hv_acpi_dev->dev;
39714 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39715 index a9e3d01..9dd246e 100644
39716 --- a/drivers/hwmon/acpi_power_meter.c
39717 +++ b/drivers/hwmon/acpi_power_meter.c
39718 @@ -117,7 +117,7 @@ struct sensor_template {
39719 struct device_attribute *devattr,
39720 const char *buf, size_t count);
39721 int index;
39722 -};
39723 +} __do_const;
39724
39725 /* Averaging interval */
39726 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39727 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39728 struct sensor_template *attrs)
39729 {
39730 struct device *dev = &resource->acpi_dev->dev;
39731 - struct sensor_device_attribute *sensors =
39732 + sensor_device_attribute_no_const *sensors =
39733 &resource->sensors[resource->num_sensors];
39734 int res = 0;
39735
39736 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39737 index 3288f13..71cfb4e 100644
39738 --- a/drivers/hwmon/applesmc.c
39739 +++ b/drivers/hwmon/applesmc.c
39740 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39741 {
39742 struct applesmc_node_group *grp;
39743 struct applesmc_dev_attr *node;
39744 - struct attribute *attr;
39745 + attribute_no_const *attr;
39746 int ret, i;
39747
39748 for (grp = groups; grp->format; grp++) {
39749 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39750 index b25c643..a13460d 100644
39751 --- a/drivers/hwmon/asus_atk0110.c
39752 +++ b/drivers/hwmon/asus_atk0110.c
39753 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39754 struct atk_sensor_data {
39755 struct list_head list;
39756 struct atk_data *data;
39757 - struct device_attribute label_attr;
39758 - struct device_attribute input_attr;
39759 - struct device_attribute limit1_attr;
39760 - struct device_attribute limit2_attr;
39761 + device_attribute_no_const label_attr;
39762 + device_attribute_no_const input_attr;
39763 + device_attribute_no_const limit1_attr;
39764 + device_attribute_no_const limit2_attr;
39765 char label_attr_name[ATTR_NAME_SIZE];
39766 char input_attr_name[ATTR_NAME_SIZE];
39767 char limit1_attr_name[ATTR_NAME_SIZE];
39768 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39769 static struct device_attribute atk_name_attr =
39770 __ATTR(name, 0444, atk_name_show, NULL);
39771
39772 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39773 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39774 sysfs_show_func show)
39775 {
39776 sysfs_attr_init(&attr->attr);
39777 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39778 index 78be661..4dd032f 100644
39779 --- a/drivers/hwmon/coretemp.c
39780 +++ b/drivers/hwmon/coretemp.c
39781 @@ -797,7 +797,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39782 return NOTIFY_OK;
39783 }
39784
39785 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39786 +static struct notifier_block coretemp_cpu_notifier = {
39787 .notifier_call = coretemp_cpu_callback,
39788 };
39789
39790 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39791 index 632f1dc..57e6a58 100644
39792 --- a/drivers/hwmon/ibmaem.c
39793 +++ b/drivers/hwmon/ibmaem.c
39794 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39795 struct aem_rw_sensor_template *rw)
39796 {
39797 struct device *dev = &data->pdev->dev;
39798 - struct sensor_device_attribute *sensors = data->sensors;
39799 + sensor_device_attribute_no_const *sensors = data->sensors;
39800 int err;
39801
39802 /* Set up read-only sensors */
39803 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39804 index 708081b..fe2d4ab 100644
39805 --- a/drivers/hwmon/iio_hwmon.c
39806 +++ b/drivers/hwmon/iio_hwmon.c
39807 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39808 {
39809 struct device *dev = &pdev->dev;
39810 struct iio_hwmon_state *st;
39811 - struct sensor_device_attribute *a;
39812 + sensor_device_attribute_no_const *a;
39813 int ret, i;
39814 int in_i = 1, temp_i = 1, curr_i = 1;
39815 enum iio_chan_type type;
39816 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
39817 index 6eb03ce..bea7e3e 100644
39818 --- a/drivers/hwmon/nct6775.c
39819 +++ b/drivers/hwmon/nct6775.c
39820 @@ -936,10 +936,10 @@ static struct attribute_group *
39821 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
39822 int repeat)
39823 {
39824 - struct attribute_group *group;
39825 + attribute_group_no_const *group;
39826 struct sensor_device_attr_u *su;
39827 - struct sensor_device_attribute *a;
39828 - struct sensor_device_attribute_2 *a2;
39829 + sensor_device_attribute_no_const *a;
39830 + sensor_device_attribute_2_no_const *a2;
39831 struct attribute **attrs;
39832 struct sensor_device_template **t;
39833 int err, i, j, count;
39834 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39835 index 9319fcf..189ff45 100644
39836 --- a/drivers/hwmon/pmbus/pmbus_core.c
39837 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39838 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39839 return 0;
39840 }
39841
39842 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39843 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39844 const char *name,
39845 umode_t mode,
39846 ssize_t (*show)(struct device *dev,
39847 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39848 dev_attr->store = store;
39849 }
39850
39851 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39852 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39853 const char *name,
39854 umode_t mode,
39855 ssize_t (*show)(struct device *dev,
39856 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39857 u16 reg, u8 mask)
39858 {
39859 struct pmbus_boolean *boolean;
39860 - struct sensor_device_attribute *a;
39861 + sensor_device_attribute_no_const *a;
39862
39863 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39864 if (!boolean)
39865 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39866 bool update, bool readonly)
39867 {
39868 struct pmbus_sensor *sensor;
39869 - struct device_attribute *a;
39870 + device_attribute_no_const *a;
39871
39872 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39873 if (!sensor)
39874 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39875 const char *lstring, int index)
39876 {
39877 struct pmbus_label *label;
39878 - struct device_attribute *a;
39879 + device_attribute_no_const *a;
39880
39881 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39882 if (!label)
39883 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39884 index 97cd45a..ac54d8b 100644
39885 --- a/drivers/hwmon/sht15.c
39886 +++ b/drivers/hwmon/sht15.c
39887 @@ -169,7 +169,7 @@ struct sht15_data {
39888 int supply_uv;
39889 bool supply_uv_valid;
39890 struct work_struct update_supply_work;
39891 - atomic_t interrupt_handled;
39892 + atomic_unchecked_t interrupt_handled;
39893 };
39894
39895 /**
39896 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39897 ret = gpio_direction_input(data->pdata->gpio_data);
39898 if (ret)
39899 return ret;
39900 - atomic_set(&data->interrupt_handled, 0);
39901 + atomic_set_unchecked(&data->interrupt_handled, 0);
39902
39903 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39904 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39905 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39906 /* Only relevant if the interrupt hasn't occurred. */
39907 - if (!atomic_read(&data->interrupt_handled))
39908 + if (!atomic_read_unchecked(&data->interrupt_handled))
39909 schedule_work(&data->read_work);
39910 }
39911 ret = wait_event_timeout(data->wait_queue,
39912 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39913
39914 /* First disable the interrupt */
39915 disable_irq_nosync(irq);
39916 - atomic_inc(&data->interrupt_handled);
39917 + atomic_inc_unchecked(&data->interrupt_handled);
39918 /* Then schedule a reading work struct */
39919 if (data->state != SHT15_READING_NOTHING)
39920 schedule_work(&data->read_work);
39921 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39922 * If not, then start the interrupt again - care here as could
39923 * have gone low in meantime so verify it hasn't!
39924 */
39925 - atomic_set(&data->interrupt_handled, 0);
39926 + atomic_set_unchecked(&data->interrupt_handled, 0);
39927 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39928 /* If still not occurred or another handler was scheduled */
39929 if (gpio_get_value(data->pdata->gpio_data)
39930 - || atomic_read(&data->interrupt_handled))
39931 + || atomic_read_unchecked(&data->interrupt_handled))
39932 return;
39933 }
39934
39935 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39936 index 38944e9..ae9e5ed 100644
39937 --- a/drivers/hwmon/via-cputemp.c
39938 +++ b/drivers/hwmon/via-cputemp.c
39939 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39940 return NOTIFY_OK;
39941 }
39942
39943 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39944 +static struct notifier_block via_cputemp_cpu_notifier = {
39945 .notifier_call = via_cputemp_cpu_callback,
39946 };
39947
39948 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39949 index 07f01ac..d79ad3d 100644
39950 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
39951 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
39952 @@ -43,7 +43,7 @@
39953 extern struct i2c_adapter amd756_smbus;
39954
39955 static struct i2c_adapter *s4882_adapter;
39956 -static struct i2c_algorithm *s4882_algo;
39957 +static i2c_algorithm_no_const *s4882_algo;
39958
39959 /* Wrapper access functions for multiplexed SMBus */
39960 static DEFINE_MUTEX(amd756_lock);
39961 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
39962 index dae3ddf..26e21d1 100644
39963 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
39964 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
39965 @@ -99,7 +99,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
39966 /* usb layer */
39967
39968 /* Send command to device, and get response. */
39969 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
39970 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
39971 {
39972 int ret = 0;
39973 int actual;
39974 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
39975 index 2ca268d..c6acbdf 100644
39976 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
39977 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
39978 @@ -41,7 +41,7 @@
39979 extern struct i2c_adapter *nforce2_smbus;
39980
39981 static struct i2c_adapter *s4985_adapter;
39982 -static struct i2c_algorithm *s4985_algo;
39983 +static i2c_algorithm_no_const *s4985_algo;
39984
39985 /* Wrapper access functions for multiplexed SMBus */
39986 static DEFINE_MUTEX(nforce2_lock);
39987 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
39988 index c3ccdea..5b3dc1a 100644
39989 --- a/drivers/i2c/i2c-dev.c
39990 +++ b/drivers/i2c/i2c-dev.c
39991 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
39992 break;
39993 }
39994
39995 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
39996 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
39997 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
39998 if (IS_ERR(rdwr_pa[i].buf)) {
39999 res = PTR_ERR(rdwr_pa[i].buf);
40000 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40001 index 0b510ba..4fbb5085 100644
40002 --- a/drivers/ide/ide-cd.c
40003 +++ b/drivers/ide/ide-cd.c
40004 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40005 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40006 if ((unsigned long)buf & alignment
40007 || blk_rq_bytes(rq) & q->dma_pad_mask
40008 - || object_is_on_stack(buf))
40009 + || object_starts_on_stack(buf))
40010 drive->dma = 0;
40011 }
40012 }
40013 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40014 index f95c697..0a1b05c 100644
40015 --- a/drivers/iio/industrialio-core.c
40016 +++ b/drivers/iio/industrialio-core.c
40017 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40018 }
40019
40020 static
40021 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40022 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40023 const char *postfix,
40024 struct iio_chan_spec const *chan,
40025 ssize_t (*readfunc)(struct device *dev,
40026 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40027 index 784b97c..c9ceadf 100644
40028 --- a/drivers/infiniband/core/cm.c
40029 +++ b/drivers/infiniband/core/cm.c
40030 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40031
40032 struct cm_counter_group {
40033 struct kobject obj;
40034 - atomic_long_t counter[CM_ATTR_COUNT];
40035 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40036 };
40037
40038 struct cm_counter_attribute {
40039 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40040 struct ib_mad_send_buf *msg = NULL;
40041 int ret;
40042
40043 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40044 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40045 counter[CM_REQ_COUNTER]);
40046
40047 /* Quick state check to discard duplicate REQs. */
40048 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40049 if (!cm_id_priv)
40050 return;
40051
40052 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40053 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40054 counter[CM_REP_COUNTER]);
40055 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40056 if (ret)
40057 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40058 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40059 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40060 spin_unlock_irq(&cm_id_priv->lock);
40061 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40062 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40063 counter[CM_RTU_COUNTER]);
40064 goto out;
40065 }
40066 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40067 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40068 dreq_msg->local_comm_id);
40069 if (!cm_id_priv) {
40070 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40071 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40072 counter[CM_DREQ_COUNTER]);
40073 cm_issue_drep(work->port, work->mad_recv_wc);
40074 return -EINVAL;
40075 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40076 case IB_CM_MRA_REP_RCVD:
40077 break;
40078 case IB_CM_TIMEWAIT:
40079 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40080 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40081 counter[CM_DREQ_COUNTER]);
40082 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40083 goto unlock;
40084 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40085 cm_free_msg(msg);
40086 goto deref;
40087 case IB_CM_DREQ_RCVD:
40088 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40089 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40090 counter[CM_DREQ_COUNTER]);
40091 goto unlock;
40092 default:
40093 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40094 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40095 cm_id_priv->msg, timeout)) {
40096 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40097 - atomic_long_inc(&work->port->
40098 + atomic_long_inc_unchecked(&work->port->
40099 counter_group[CM_RECV_DUPLICATES].
40100 counter[CM_MRA_COUNTER]);
40101 goto out;
40102 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40103 break;
40104 case IB_CM_MRA_REQ_RCVD:
40105 case IB_CM_MRA_REP_RCVD:
40106 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40107 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40108 counter[CM_MRA_COUNTER]);
40109 /* fall through */
40110 default:
40111 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40112 case IB_CM_LAP_IDLE:
40113 break;
40114 case IB_CM_MRA_LAP_SENT:
40115 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40116 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40117 counter[CM_LAP_COUNTER]);
40118 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40119 goto unlock;
40120 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40121 cm_free_msg(msg);
40122 goto deref;
40123 case IB_CM_LAP_RCVD:
40124 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40125 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40126 counter[CM_LAP_COUNTER]);
40127 goto unlock;
40128 default:
40129 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40130 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40131 if (cur_cm_id_priv) {
40132 spin_unlock_irq(&cm.lock);
40133 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40134 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40135 counter[CM_SIDR_REQ_COUNTER]);
40136 goto out; /* Duplicate message. */
40137 }
40138 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40139 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40140 msg->retries = 1;
40141
40142 - atomic_long_add(1 + msg->retries,
40143 + atomic_long_add_unchecked(1 + msg->retries,
40144 &port->counter_group[CM_XMIT].counter[attr_index]);
40145 if (msg->retries)
40146 - atomic_long_add(msg->retries,
40147 + atomic_long_add_unchecked(msg->retries,
40148 &port->counter_group[CM_XMIT_RETRIES].
40149 counter[attr_index]);
40150
40151 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40152 }
40153
40154 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40155 - atomic_long_inc(&port->counter_group[CM_RECV].
40156 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40157 counter[attr_id - CM_ATTR_ID_OFFSET]);
40158
40159 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40160 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40161 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40162
40163 return sprintf(buf, "%ld\n",
40164 - atomic_long_read(&group->counter[cm_attr->index]));
40165 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40166 }
40167
40168 static const struct sysfs_ops cm_counter_ops = {
40169 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40170 index 9f5ad7c..588cd84 100644
40171 --- a/drivers/infiniband/core/fmr_pool.c
40172 +++ b/drivers/infiniband/core/fmr_pool.c
40173 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40174
40175 struct task_struct *thread;
40176
40177 - atomic_t req_ser;
40178 - atomic_t flush_ser;
40179 + atomic_unchecked_t req_ser;
40180 + atomic_unchecked_t flush_ser;
40181
40182 wait_queue_head_t force_wait;
40183 };
40184 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40185 struct ib_fmr_pool *pool = pool_ptr;
40186
40187 do {
40188 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40189 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40190 ib_fmr_batch_release(pool);
40191
40192 - atomic_inc(&pool->flush_ser);
40193 + atomic_inc_unchecked(&pool->flush_ser);
40194 wake_up_interruptible(&pool->force_wait);
40195
40196 if (pool->flush_function)
40197 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40198 }
40199
40200 set_current_state(TASK_INTERRUPTIBLE);
40201 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40202 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40203 !kthread_should_stop())
40204 schedule();
40205 __set_current_state(TASK_RUNNING);
40206 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40207 pool->dirty_watermark = params->dirty_watermark;
40208 pool->dirty_len = 0;
40209 spin_lock_init(&pool->pool_lock);
40210 - atomic_set(&pool->req_ser, 0);
40211 - atomic_set(&pool->flush_ser, 0);
40212 + atomic_set_unchecked(&pool->req_ser, 0);
40213 + atomic_set_unchecked(&pool->flush_ser, 0);
40214 init_waitqueue_head(&pool->force_wait);
40215
40216 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40217 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40218 }
40219 spin_unlock_irq(&pool->pool_lock);
40220
40221 - serial = atomic_inc_return(&pool->req_ser);
40222 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40223 wake_up_process(pool->thread);
40224
40225 if (wait_event_interruptible(pool->force_wait,
40226 - atomic_read(&pool->flush_ser) - serial >= 0))
40227 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40228 return -EINTR;
40229
40230 return 0;
40231 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40232 } else {
40233 list_add_tail(&fmr->list, &pool->dirty_list);
40234 if (++pool->dirty_len >= pool->dirty_watermark) {
40235 - atomic_inc(&pool->req_ser);
40236 + atomic_inc_unchecked(&pool->req_ser);
40237 wake_up_process(pool->thread);
40238 }
40239 }
40240 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40241 index 4cb8eb2..146bf60 100644
40242 --- a/drivers/infiniband/hw/cxgb4/mem.c
40243 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40244 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40245 int err;
40246 struct fw_ri_tpte tpt;
40247 u32 stag_idx;
40248 - static atomic_t key;
40249 + static atomic_unchecked_t key;
40250
40251 if (c4iw_fatal_error(rdev))
40252 return -EIO;
40253 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40254 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40255 rdev->stats.stag.max = rdev->stats.stag.cur;
40256 mutex_unlock(&rdev->stats.lock);
40257 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40258 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40259 }
40260 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40261 __func__, stag_state, type, pdid, stag_idx);
40262 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40263 index 79b3dbc..96e5fcc 100644
40264 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40265 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40266 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40267 struct ib_atomic_eth *ateth;
40268 struct ipath_ack_entry *e;
40269 u64 vaddr;
40270 - atomic64_t *maddr;
40271 + atomic64_unchecked_t *maddr;
40272 u64 sdata;
40273 u32 rkey;
40274 u8 next;
40275 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40276 IB_ACCESS_REMOTE_ATOMIC)))
40277 goto nack_acc_unlck;
40278 /* Perform atomic OP and save result. */
40279 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40280 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40281 sdata = be64_to_cpu(ateth->swap_data);
40282 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40283 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40284 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40285 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40286 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40287 be64_to_cpu(ateth->compare_data),
40288 sdata);
40289 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40290 index 1f95bba..9530f87 100644
40291 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40292 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40293 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40294 unsigned long flags;
40295 struct ib_wc wc;
40296 u64 sdata;
40297 - atomic64_t *maddr;
40298 + atomic64_unchecked_t *maddr;
40299 enum ib_wc_status send_status;
40300
40301 /*
40302 @@ -382,11 +382,11 @@ again:
40303 IB_ACCESS_REMOTE_ATOMIC)))
40304 goto acc_err;
40305 /* Perform atomic OP and save result. */
40306 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40307 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40308 sdata = wqe->wr.wr.atomic.compare_add;
40309 *(u64 *) sqp->s_sge.sge.vaddr =
40310 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40311 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40312 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40313 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40314 sdata, wqe->wr.wr.atomic.swap);
40315 goto send_comp;
40316 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40317 index f2a3f48..673ec79 100644
40318 --- a/drivers/infiniband/hw/mlx4/mad.c
40319 +++ b/drivers/infiniband/hw/mlx4/mad.c
40320 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40321
40322 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40323 {
40324 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40325 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40326 cpu_to_be64(0xff00000000000000LL);
40327 }
40328
40329 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40330 index 25b2cdf..099ff97 100644
40331 --- a/drivers/infiniband/hw/mlx4/mcg.c
40332 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40333 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40334 {
40335 char name[20];
40336
40337 - atomic_set(&ctx->tid, 0);
40338 + atomic_set_unchecked(&ctx->tid, 0);
40339 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40340 ctx->mcg_wq = create_singlethread_workqueue(name);
40341 if (!ctx->mcg_wq)
40342 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40343 index 036b663..c9a8c73 100644
40344 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40345 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40346 @@ -404,7 +404,7 @@ struct mlx4_ib_demux_ctx {
40347 struct list_head mcg_mgid0_list;
40348 struct workqueue_struct *mcg_wq;
40349 struct mlx4_ib_demux_pv_ctx **tun;
40350 - atomic_t tid;
40351 + atomic_unchecked_t tid;
40352 int flushing; /* flushing the work queue */
40353 };
40354
40355 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40356 index 9d3e5c1..6f166df 100644
40357 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40358 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40359 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40360 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40361 }
40362
40363 -int mthca_QUERY_FW(struct mthca_dev *dev)
40364 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40365 {
40366 struct mthca_mailbox *mailbox;
40367 u32 *outbox;
40368 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40369 CMD_TIME_CLASS_B);
40370 }
40371
40372 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40373 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40374 int num_mtt)
40375 {
40376 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
40377 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
40378 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
40379 }
40380
40381 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40382 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40383 int eq_num)
40384 {
40385 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
40386 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
40387 CMD_TIME_CLASS_B);
40388 }
40389
40390 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40391 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40392 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
40393 void *in_mad, void *response_mad)
40394 {
40395 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
40396 index 87897b9..7e79542 100644
40397 --- a/drivers/infiniband/hw/mthca/mthca_main.c
40398 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
40399 @@ -692,7 +692,7 @@ err_close:
40400 return err;
40401 }
40402
40403 -static int mthca_setup_hca(struct mthca_dev *dev)
40404 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
40405 {
40406 int err;
40407
40408 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40409 index ed9a989..6aa5dc2 100644
40410 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40411 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40412 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
40413 * through the bitmaps)
40414 */
40415
40416 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
40417 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
40418 {
40419 int o;
40420 int m;
40421 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40422 return key;
40423 }
40424
40425 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40426 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40427 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40428 {
40429 struct mthca_mailbox *mailbox;
40430 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
40431 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
40432 }
40433
40434 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
40435 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
40436 u64 *buffer_list, int buffer_size_shift,
40437 int list_len, u64 iova, u64 total_size,
40438 u32 access, struct mthca_mr *mr)
40439 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
40440 index 5b71d43..35a9e14 100644
40441 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
40442 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
40443 @@ -763,7 +763,7 @@ unlock:
40444 return 0;
40445 }
40446
40447 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
40448 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
40449 {
40450 struct mthca_dev *dev = to_mdev(ibcq->device);
40451 struct mthca_cq *cq = to_mcq(ibcq);
40452 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40453 index 4291410..d2ab1fb 100644
40454 --- a/drivers/infiniband/hw/nes/nes.c
40455 +++ b/drivers/infiniband/hw/nes/nes.c
40456 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40457 LIST_HEAD(nes_adapter_list);
40458 static LIST_HEAD(nes_dev_list);
40459
40460 -atomic_t qps_destroyed;
40461 +atomic_unchecked_t qps_destroyed;
40462
40463 static unsigned int ee_flsh_adapter;
40464 static unsigned int sysfs_nonidx_addr;
40465 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40466 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40467 struct nes_adapter *nesadapter = nesdev->nesadapter;
40468
40469 - atomic_inc(&qps_destroyed);
40470 + atomic_inc_unchecked(&qps_destroyed);
40471
40472 /* Free the control structures */
40473
40474 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40475 index 33cc589..3bd6538 100644
40476 --- a/drivers/infiniband/hw/nes/nes.h
40477 +++ b/drivers/infiniband/hw/nes/nes.h
40478 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40479 extern unsigned int wqm_quanta;
40480 extern struct list_head nes_adapter_list;
40481
40482 -extern atomic_t cm_connects;
40483 -extern atomic_t cm_accepts;
40484 -extern atomic_t cm_disconnects;
40485 -extern atomic_t cm_closes;
40486 -extern atomic_t cm_connecteds;
40487 -extern atomic_t cm_connect_reqs;
40488 -extern atomic_t cm_rejects;
40489 -extern atomic_t mod_qp_timouts;
40490 -extern atomic_t qps_created;
40491 -extern atomic_t qps_destroyed;
40492 -extern atomic_t sw_qps_destroyed;
40493 +extern atomic_unchecked_t cm_connects;
40494 +extern atomic_unchecked_t cm_accepts;
40495 +extern atomic_unchecked_t cm_disconnects;
40496 +extern atomic_unchecked_t cm_closes;
40497 +extern atomic_unchecked_t cm_connecteds;
40498 +extern atomic_unchecked_t cm_connect_reqs;
40499 +extern atomic_unchecked_t cm_rejects;
40500 +extern atomic_unchecked_t mod_qp_timouts;
40501 +extern atomic_unchecked_t qps_created;
40502 +extern atomic_unchecked_t qps_destroyed;
40503 +extern atomic_unchecked_t sw_qps_destroyed;
40504 extern u32 mh_detected;
40505 extern u32 mh_pauses_sent;
40506 extern u32 cm_packets_sent;
40507 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40508 extern u32 cm_packets_received;
40509 extern u32 cm_packets_dropped;
40510 extern u32 cm_packets_retrans;
40511 -extern atomic_t cm_listens_created;
40512 -extern atomic_t cm_listens_destroyed;
40513 +extern atomic_unchecked_t cm_listens_created;
40514 +extern atomic_unchecked_t cm_listens_destroyed;
40515 extern u32 cm_backlog_drops;
40516 -extern atomic_t cm_loopbacks;
40517 -extern atomic_t cm_nodes_created;
40518 -extern atomic_t cm_nodes_destroyed;
40519 -extern atomic_t cm_accel_dropped_pkts;
40520 -extern atomic_t cm_resets_recvd;
40521 -extern atomic_t pau_qps_created;
40522 -extern atomic_t pau_qps_destroyed;
40523 +extern atomic_unchecked_t cm_loopbacks;
40524 +extern atomic_unchecked_t cm_nodes_created;
40525 +extern atomic_unchecked_t cm_nodes_destroyed;
40526 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40527 +extern atomic_unchecked_t cm_resets_recvd;
40528 +extern atomic_unchecked_t pau_qps_created;
40529 +extern atomic_unchecked_t pau_qps_destroyed;
40530
40531 extern u32 int_mod_timer_init;
40532 extern u32 int_mod_cq_depth_256;
40533 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40534 index 6b29249..57081dd 100644
40535 --- a/drivers/infiniband/hw/nes/nes_cm.c
40536 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40537 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40538 u32 cm_packets_retrans;
40539 u32 cm_packets_created;
40540 u32 cm_packets_received;
40541 -atomic_t cm_listens_created;
40542 -atomic_t cm_listens_destroyed;
40543 +atomic_unchecked_t cm_listens_created;
40544 +atomic_unchecked_t cm_listens_destroyed;
40545 u32 cm_backlog_drops;
40546 -atomic_t cm_loopbacks;
40547 -atomic_t cm_nodes_created;
40548 -atomic_t cm_nodes_destroyed;
40549 -atomic_t cm_accel_dropped_pkts;
40550 -atomic_t cm_resets_recvd;
40551 +atomic_unchecked_t cm_loopbacks;
40552 +atomic_unchecked_t cm_nodes_created;
40553 +atomic_unchecked_t cm_nodes_destroyed;
40554 +atomic_unchecked_t cm_accel_dropped_pkts;
40555 +atomic_unchecked_t cm_resets_recvd;
40556
40557 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40558 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40559 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40560
40561 static struct nes_cm_core *g_cm_core;
40562
40563 -atomic_t cm_connects;
40564 -atomic_t cm_accepts;
40565 -atomic_t cm_disconnects;
40566 -atomic_t cm_closes;
40567 -atomic_t cm_connecteds;
40568 -atomic_t cm_connect_reqs;
40569 -atomic_t cm_rejects;
40570 +atomic_unchecked_t cm_connects;
40571 +atomic_unchecked_t cm_accepts;
40572 +atomic_unchecked_t cm_disconnects;
40573 +atomic_unchecked_t cm_closes;
40574 +atomic_unchecked_t cm_connecteds;
40575 +atomic_unchecked_t cm_connect_reqs;
40576 +atomic_unchecked_t cm_rejects;
40577
40578 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40579 {
40580 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40581 kfree(listener);
40582 listener = NULL;
40583 ret = 0;
40584 - atomic_inc(&cm_listens_destroyed);
40585 + atomic_inc_unchecked(&cm_listens_destroyed);
40586 } else {
40587 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40588 }
40589 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40590 cm_node->rem_mac);
40591
40592 add_hte_node(cm_core, cm_node);
40593 - atomic_inc(&cm_nodes_created);
40594 + atomic_inc_unchecked(&cm_nodes_created);
40595
40596 return cm_node;
40597 }
40598 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40599 }
40600
40601 atomic_dec(&cm_core->node_cnt);
40602 - atomic_inc(&cm_nodes_destroyed);
40603 + atomic_inc_unchecked(&cm_nodes_destroyed);
40604 nesqp = cm_node->nesqp;
40605 if (nesqp) {
40606 nesqp->cm_node = NULL;
40607 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40608
40609 static void drop_packet(struct sk_buff *skb)
40610 {
40611 - atomic_inc(&cm_accel_dropped_pkts);
40612 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40613 dev_kfree_skb_any(skb);
40614 }
40615
40616 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40617 {
40618
40619 int reset = 0; /* whether to send reset in case of err.. */
40620 - atomic_inc(&cm_resets_recvd);
40621 + atomic_inc_unchecked(&cm_resets_recvd);
40622 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40623 " refcnt=%d\n", cm_node, cm_node->state,
40624 atomic_read(&cm_node->ref_count));
40625 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40626 rem_ref_cm_node(cm_node->cm_core, cm_node);
40627 return NULL;
40628 }
40629 - atomic_inc(&cm_loopbacks);
40630 + atomic_inc_unchecked(&cm_loopbacks);
40631 loopbackremotenode->loopbackpartner = cm_node;
40632 loopbackremotenode->tcp_cntxt.rcv_wscale =
40633 NES_CM_DEFAULT_RCV_WND_SCALE;
40634 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40635 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40636 else {
40637 rem_ref_cm_node(cm_core, cm_node);
40638 - atomic_inc(&cm_accel_dropped_pkts);
40639 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40640 dev_kfree_skb_any(skb);
40641 }
40642 break;
40643 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40644
40645 if ((cm_id) && (cm_id->event_handler)) {
40646 if (issue_disconn) {
40647 - atomic_inc(&cm_disconnects);
40648 + atomic_inc_unchecked(&cm_disconnects);
40649 cm_event.event = IW_CM_EVENT_DISCONNECT;
40650 cm_event.status = disconn_status;
40651 cm_event.local_addr = cm_id->local_addr;
40652 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40653 }
40654
40655 if (issue_close) {
40656 - atomic_inc(&cm_closes);
40657 + atomic_inc_unchecked(&cm_closes);
40658 nes_disconnect(nesqp, 1);
40659
40660 cm_id->provider_data = nesqp;
40661 @@ -3035,7 +3035,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40662
40663 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40664 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40665 - atomic_inc(&cm_accepts);
40666 + atomic_inc_unchecked(&cm_accepts);
40667
40668 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40669 netdev_refcnt_read(nesvnic->netdev));
40670 @@ -3224,7 +3224,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40671 struct nes_cm_core *cm_core;
40672 u8 *start_buff;
40673
40674 - atomic_inc(&cm_rejects);
40675 + atomic_inc_unchecked(&cm_rejects);
40676 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40677 loopback = cm_node->loopbackpartner;
40678 cm_core = cm_node->cm_core;
40679 @@ -3286,7 +3286,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40680 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
40681 ntohs(laddr->sin_port));
40682
40683 - atomic_inc(&cm_connects);
40684 + atomic_inc_unchecked(&cm_connects);
40685 nesqp->active_conn = 1;
40686
40687 /* cache the cm_id in the qp */
40688 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40689 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40690 return err;
40691 }
40692 - atomic_inc(&cm_listens_created);
40693 + atomic_inc_unchecked(&cm_listens_created);
40694 }
40695
40696 cm_id->add_ref(cm_id);
40697 @@ -3505,7 +3505,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40698
40699 if (nesqp->destroyed)
40700 return;
40701 - atomic_inc(&cm_connecteds);
40702 + atomic_inc_unchecked(&cm_connecteds);
40703 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40704 " local port 0x%04X. jiffies = %lu.\n",
40705 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
40706 @@ -3686,7 +3686,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40707
40708 cm_id->add_ref(cm_id);
40709 ret = cm_id->event_handler(cm_id, &cm_event);
40710 - atomic_inc(&cm_closes);
40711 + atomic_inc_unchecked(&cm_closes);
40712 cm_event.event = IW_CM_EVENT_CLOSE;
40713 cm_event.status = 0;
40714 cm_event.provider_data = cm_id->provider_data;
40715 @@ -3726,7 +3726,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40716 return;
40717 cm_id = cm_node->cm_id;
40718
40719 - atomic_inc(&cm_connect_reqs);
40720 + atomic_inc_unchecked(&cm_connect_reqs);
40721 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40722 cm_node, cm_id, jiffies);
40723
40724 @@ -3770,7 +3770,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40725 return;
40726 cm_id = cm_node->cm_id;
40727
40728 - atomic_inc(&cm_connect_reqs);
40729 + atomic_inc_unchecked(&cm_connect_reqs);
40730 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40731 cm_node, cm_id, jiffies);
40732
40733 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40734 index 4166452..fc952c3 100644
40735 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40736 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40737 @@ -40,8 +40,8 @@
40738 #include "nes.h"
40739 #include "nes_mgt.h"
40740
40741 -atomic_t pau_qps_created;
40742 -atomic_t pau_qps_destroyed;
40743 +atomic_unchecked_t pau_qps_created;
40744 +atomic_unchecked_t pau_qps_destroyed;
40745
40746 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40747 {
40748 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40749 {
40750 struct sk_buff *skb;
40751 unsigned long flags;
40752 - atomic_inc(&pau_qps_destroyed);
40753 + atomic_inc_unchecked(&pau_qps_destroyed);
40754
40755 /* Free packets that have not yet been forwarded */
40756 /* Lock is acquired by skb_dequeue when removing the skb */
40757 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40758 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40759 skb_queue_head_init(&nesqp->pau_list);
40760 spin_lock_init(&nesqp->pau_lock);
40761 - atomic_inc(&pau_qps_created);
40762 + atomic_inc_unchecked(&pau_qps_created);
40763 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40764 }
40765
40766 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40767 index 49eb511..a774366 100644
40768 --- a/drivers/infiniband/hw/nes/nes_nic.c
40769 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40770 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40771 target_stat_values[++index] = mh_detected;
40772 target_stat_values[++index] = mh_pauses_sent;
40773 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40774 - target_stat_values[++index] = atomic_read(&cm_connects);
40775 - target_stat_values[++index] = atomic_read(&cm_accepts);
40776 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40777 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40778 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40779 - target_stat_values[++index] = atomic_read(&cm_rejects);
40780 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40781 - target_stat_values[++index] = atomic_read(&qps_created);
40782 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40783 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40784 - target_stat_values[++index] = atomic_read(&cm_closes);
40785 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40786 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40787 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40788 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40789 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40790 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40791 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40792 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40793 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40794 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40795 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40796 target_stat_values[++index] = cm_packets_sent;
40797 target_stat_values[++index] = cm_packets_bounced;
40798 target_stat_values[++index] = cm_packets_created;
40799 target_stat_values[++index] = cm_packets_received;
40800 target_stat_values[++index] = cm_packets_dropped;
40801 target_stat_values[++index] = cm_packets_retrans;
40802 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40803 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40804 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40805 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40806 target_stat_values[++index] = cm_backlog_drops;
40807 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40808 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40809 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40810 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40811 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40812 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40813 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40814 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40815 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40816 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40817 target_stat_values[++index] = nesadapter->free_4kpbl;
40818 target_stat_values[++index] = nesadapter->free_256pbl;
40819 target_stat_values[++index] = int_mod_timer_init;
40820 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40821 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40822 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40823 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40824 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40825 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40826 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40827 }
40828
40829 /**
40830 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40831 index 5b53ca5..443da3c 100644
40832 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40833 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40834 @@ -46,9 +46,9 @@
40835
40836 #include <rdma/ib_umem.h>
40837
40838 -atomic_t mod_qp_timouts;
40839 -atomic_t qps_created;
40840 -atomic_t sw_qps_destroyed;
40841 +atomic_unchecked_t mod_qp_timouts;
40842 +atomic_unchecked_t qps_created;
40843 +atomic_unchecked_t sw_qps_destroyed;
40844
40845 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40846
40847 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40848 if (init_attr->create_flags)
40849 return ERR_PTR(-EINVAL);
40850
40851 - atomic_inc(&qps_created);
40852 + atomic_inc_unchecked(&qps_created);
40853 switch (init_attr->qp_type) {
40854 case IB_QPT_RC:
40855 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40856 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40857 struct iw_cm_event cm_event;
40858 int ret = 0;
40859
40860 - atomic_inc(&sw_qps_destroyed);
40861 + atomic_inc_unchecked(&sw_qps_destroyed);
40862 nesqp->destroyed = 1;
40863
40864 /* Blow away the connection if it exists. */
40865 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40866 index 1946101..09766d2 100644
40867 --- a/drivers/infiniband/hw/qib/qib.h
40868 +++ b/drivers/infiniband/hw/qib/qib.h
40869 @@ -52,6 +52,7 @@
40870 #include <linux/kref.h>
40871 #include <linux/sched.h>
40872 #include <linux/kthread.h>
40873 +#include <linux/slab.h>
40874
40875 #include "qib_common.h"
40876 #include "qib_verbs.h"
40877 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40878 index 922a7fe..bb035db 100644
40879 --- a/drivers/input/gameport/gameport.c
40880 +++ b/drivers/input/gameport/gameport.c
40881 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40882 */
40883 static void gameport_init_port(struct gameport *gameport)
40884 {
40885 - static atomic_t gameport_no = ATOMIC_INIT(0);
40886 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40887
40888 __module_get(THIS_MODULE);
40889
40890 mutex_init(&gameport->drv_mutex);
40891 device_initialize(&gameport->dev);
40892 dev_set_name(&gameport->dev, "gameport%lu",
40893 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40894 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40895 gameport->dev.bus = &gameport_bus;
40896 gameport->dev.release = gameport_release_port;
40897 if (gameport->parent)
40898 diff --git a/drivers/input/input.c b/drivers/input/input.c
40899 index e75d015..57d1c28 100644
40900 --- a/drivers/input/input.c
40901 +++ b/drivers/input/input.c
40902 @@ -1734,7 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
40903 */
40904 struct input_dev *input_allocate_device(void)
40905 {
40906 - static atomic_t input_no = ATOMIC_INIT(0);
40907 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40908 struct input_dev *dev;
40909
40910 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
40911 @@ -1749,7 +1749,7 @@ struct input_dev *input_allocate_device(void)
40912 INIT_LIST_HEAD(&dev->node);
40913
40914 dev_set_name(&dev->dev, "input%ld",
40915 - (unsigned long) atomic_inc_return(&input_no) - 1);
40916 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40917
40918 __module_get(THIS_MODULE);
40919 }
40920 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40921 index 04c69af..5f92d00 100644
40922 --- a/drivers/input/joystick/sidewinder.c
40923 +++ b/drivers/input/joystick/sidewinder.c
40924 @@ -30,6 +30,7 @@
40925 #include <linux/kernel.h>
40926 #include <linux/module.h>
40927 #include <linux/slab.h>
40928 +#include <linux/sched.h>
40929 #include <linux/init.h>
40930 #include <linux/input.h>
40931 #include <linux/gameport.h>
40932 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40933 index 75e3b10..fb390fd 100644
40934 --- a/drivers/input/joystick/xpad.c
40935 +++ b/drivers/input/joystick/xpad.c
40936 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40937
40938 static int xpad_led_probe(struct usb_xpad *xpad)
40939 {
40940 - static atomic_t led_seq = ATOMIC_INIT(0);
40941 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40942 long led_no;
40943 struct xpad_led *led;
40944 struct led_classdev *led_cdev;
40945 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40946 if (!led)
40947 return -ENOMEM;
40948
40949 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40950 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40951
40952 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40953 led->xpad = xpad;
40954 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40955 index e204f26..8459f15 100644
40956 --- a/drivers/input/misc/ims-pcu.c
40957 +++ b/drivers/input/misc/ims-pcu.c
40958 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40959
40960 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40961 {
40962 - static atomic_t device_no = ATOMIC_INIT(0);
40963 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40964
40965 const struct ims_pcu_device_info *info;
40966 u8 device_id;
40967 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40968 }
40969
40970 /* Device appears to be operable, complete initialization */
40971 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40972 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40973
40974 error = ims_pcu_setup_backlight(pcu);
40975 if (error)
40976 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40977 index 2f0b39d..7370f13 100644
40978 --- a/drivers/input/mouse/psmouse.h
40979 +++ b/drivers/input/mouse/psmouse.h
40980 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40981 ssize_t (*set)(struct psmouse *psmouse, void *data,
40982 const char *buf, size_t count);
40983 bool protect;
40984 -};
40985 +} __do_const;
40986 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40987
40988 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40989 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40990 index 4c842c3..590b0bf 100644
40991 --- a/drivers/input/mousedev.c
40992 +++ b/drivers/input/mousedev.c
40993 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40994
40995 spin_unlock_irq(&client->packet_lock);
40996
40997 - if (copy_to_user(buffer, data, count))
40998 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40999 return -EFAULT;
41000
41001 return count;
41002 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41003 index 2b56855..5a55837 100644
41004 --- a/drivers/input/serio/serio.c
41005 +++ b/drivers/input/serio/serio.c
41006 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41007 */
41008 static void serio_init_port(struct serio *serio)
41009 {
41010 - static atomic_t serio_no = ATOMIC_INIT(0);
41011 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41012
41013 __module_get(THIS_MODULE);
41014
41015 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41016 mutex_init(&serio->drv_mutex);
41017 device_initialize(&serio->dev);
41018 dev_set_name(&serio->dev, "serio%ld",
41019 - (long)atomic_inc_return(&serio_no) - 1);
41020 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41021 serio->dev.bus = &serio_bus;
41022 serio->dev.release = serio_release_port;
41023 serio->dev.groups = serio_device_attr_groups;
41024 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41025 index 59df2e7..8f1cafb 100644
41026 --- a/drivers/input/serio/serio_raw.c
41027 +++ b/drivers/input/serio/serio_raw.c
41028 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41029
41030 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41031 {
41032 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41033 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41034 struct serio_raw *serio_raw;
41035 int err;
41036
41037 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41038 }
41039
41040 snprintf(serio_raw->name, sizeof(serio_raw->name),
41041 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41042 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41043 kref_init(&serio_raw->kref);
41044 INIT_LIST_HEAD(&serio_raw->client_list);
41045 init_waitqueue_head(&serio_raw->wait);
41046 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41047 index fbe9ca7..dbee61d 100644
41048 --- a/drivers/iommu/iommu.c
41049 +++ b/drivers/iommu/iommu.c
41050 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41051 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41052 {
41053 bus_register_notifier(bus, &iommu_bus_nb);
41054 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41055 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41056 }
41057
41058 /**
41059 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41060 index 39f81ae..2660096 100644
41061 --- a/drivers/iommu/irq_remapping.c
41062 +++ b/drivers/iommu/irq_remapping.c
41063 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41064 void panic_if_irq_remap(const char *msg)
41065 {
41066 if (irq_remapping_enabled)
41067 - panic(msg);
41068 + panic("%s", msg);
41069 }
41070
41071 static void ir_ack_apic_edge(struct irq_data *data)
41072 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41073
41074 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41075 {
41076 - chip->irq_print_chip = ir_print_prefix;
41077 - chip->irq_ack = ir_ack_apic_edge;
41078 - chip->irq_eoi = ir_ack_apic_level;
41079 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41080 + pax_open_kernel();
41081 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41082 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41083 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41084 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41085 + pax_close_kernel();
41086 }
41087
41088 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41089 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41090 index d0e9480..d2b6340 100644
41091 --- a/drivers/irqchip/irq-gic.c
41092 +++ b/drivers/irqchip/irq-gic.c
41093 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41094 * Supported arch specific GIC irq extension.
41095 * Default make them NULL.
41096 */
41097 -struct irq_chip gic_arch_extn = {
41098 +irq_chip_no_const gic_arch_extn = {
41099 .irq_eoi = NULL,
41100 .irq_mask = NULL,
41101 .irq_unmask = NULL,
41102 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41103 chained_irq_exit(chip, desc);
41104 }
41105
41106 -static struct irq_chip gic_chip = {
41107 +static irq_chip_no_const gic_chip __read_only = {
41108 .name = "GIC",
41109 .irq_mask = gic_mask_irq,
41110 .irq_unmask = gic_unmask_irq,
41111 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41112 index ac6f72b..81150f2 100644
41113 --- a/drivers/isdn/capi/capi.c
41114 +++ b/drivers/isdn/capi/capi.c
41115 @@ -81,8 +81,8 @@ struct capiminor {
41116
41117 struct capi20_appl *ap;
41118 u32 ncci;
41119 - atomic_t datahandle;
41120 - atomic_t msgid;
41121 + atomic_unchecked_t datahandle;
41122 + atomic_unchecked_t msgid;
41123
41124 struct tty_port port;
41125 int ttyinstop;
41126 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41127 capimsg_setu16(s, 2, mp->ap->applid);
41128 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41129 capimsg_setu8 (s, 5, CAPI_RESP);
41130 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41131 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41132 capimsg_setu32(s, 8, mp->ncci);
41133 capimsg_setu16(s, 12, datahandle);
41134 }
41135 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41136 mp->outbytes -= len;
41137 spin_unlock_bh(&mp->outlock);
41138
41139 - datahandle = atomic_inc_return(&mp->datahandle);
41140 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41141 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41142 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41143 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41144 capimsg_setu16(skb->data, 2, mp->ap->applid);
41145 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41146 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41147 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41148 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41149 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41150 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41151 capimsg_setu16(skb->data, 16, len); /* Data length */
41152 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41153 index 600c79b..3752bab 100644
41154 --- a/drivers/isdn/gigaset/interface.c
41155 +++ b/drivers/isdn/gigaset/interface.c
41156 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41157 }
41158 tty->driver_data = cs;
41159
41160 - ++cs->port.count;
41161 + atomic_inc(&cs->port.count);
41162
41163 - if (cs->port.count == 1) {
41164 + if (atomic_read(&cs->port.count) == 1) {
41165 tty_port_tty_set(&cs->port, tty);
41166 cs->port.low_latency = 1;
41167 }
41168 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41169
41170 if (!cs->connected)
41171 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41172 - else if (!cs->port.count)
41173 + else if (!atomic_read(&cs->port.count))
41174 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41175 - else if (!--cs->port.count)
41176 + else if (!atomic_dec_return(&cs->port.count))
41177 tty_port_tty_set(&cs->port, NULL);
41178
41179 mutex_unlock(&cs->mutex);
41180 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41181 index d0a41cb..f0cdb8c 100644
41182 --- a/drivers/isdn/gigaset/usb-gigaset.c
41183 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41184 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41185 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41186 memcpy(cs->hw.usb->bchars, buf, 6);
41187 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41188 - 0, 0, &buf, 6, 2000);
41189 + 0, 0, buf, 6, 2000);
41190 }
41191
41192 static void gigaset_freebcshw(struct bc_state *bcs)
41193 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41194 index 4d9b195..455075c 100644
41195 --- a/drivers/isdn/hardware/avm/b1.c
41196 +++ b/drivers/isdn/hardware/avm/b1.c
41197 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41198 }
41199 if (left) {
41200 if (t4file->user) {
41201 - if (copy_from_user(buf, dp, left))
41202 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41203 return -EFAULT;
41204 } else {
41205 memcpy(buf, dp, left);
41206 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41207 }
41208 if (left) {
41209 if (config->user) {
41210 - if (copy_from_user(buf, dp, left))
41211 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41212 return -EFAULT;
41213 } else {
41214 memcpy(buf, dp, left);
41215 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41216 index 9bb12ba..d4262f7 100644
41217 --- a/drivers/isdn/i4l/isdn_common.c
41218 +++ b/drivers/isdn/i4l/isdn_common.c
41219 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41220 } else
41221 return -EINVAL;
41222 case IIOCDBGVAR:
41223 + if (!capable(CAP_SYS_RAWIO))
41224 + return -EPERM;
41225 if (arg) {
41226 if (copy_to_user(argp, &dev, sizeof(ulong)))
41227 return -EFAULT;
41228 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41229 index 3c5f249..5fac4d0 100644
41230 --- a/drivers/isdn/i4l/isdn_tty.c
41231 +++ b/drivers/isdn/i4l/isdn_tty.c
41232 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41233
41234 #ifdef ISDN_DEBUG_MODEM_OPEN
41235 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41236 - port->count);
41237 + atomic_read(&port->count));
41238 #endif
41239 - port->count++;
41240 + atomic_inc(&port->count);
41241 port->tty = tty;
41242 /*
41243 * Start up serial port
41244 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41245 #endif
41246 return;
41247 }
41248 - if ((tty->count == 1) && (port->count != 1)) {
41249 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41250 /*
41251 * Uh, oh. tty->count is 1, which means that the tty
41252 * structure will be freed. Info->count should always
41253 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41254 * serial port won't be shutdown.
41255 */
41256 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41257 - "info->count is %d\n", port->count);
41258 - port->count = 1;
41259 + "info->count is %d\n", atomic_read(&port->count));
41260 + atomic_set(&port->count, 1);
41261 }
41262 - if (--port->count < 0) {
41263 + if (atomic_dec_return(&port->count) < 0) {
41264 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41265 - info->line, port->count);
41266 - port->count = 0;
41267 + info->line, atomic_read(&port->count));
41268 + atomic_set(&port->count, 0);
41269 }
41270 - if (port->count) {
41271 + if (atomic_read(&port->count)) {
41272 #ifdef ISDN_DEBUG_MODEM_OPEN
41273 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41274 #endif
41275 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41276 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41277 return;
41278 isdn_tty_shutdown(info);
41279 - port->count = 0;
41280 + atomic_set(&port->count, 0);
41281 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41282 port->tty = NULL;
41283 wake_up_interruptible(&port->open_wait);
41284 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41285 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41286 modem_info *info = &dev->mdm.info[i];
41287
41288 - if (info->port.count == 0)
41289 + if (atomic_read(&info->port.count) == 0)
41290 continue;
41291 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41292 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41293 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41294 index e74df7c..03a03ba 100644
41295 --- a/drivers/isdn/icn/icn.c
41296 +++ b/drivers/isdn/icn/icn.c
41297 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41298 if (count > len)
41299 count = len;
41300 if (user) {
41301 - if (copy_from_user(msg, buf, count))
41302 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41303 return -EFAULT;
41304 } else
41305 memcpy(msg, buf, count);
41306 diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
41307 index baf2686..02125e6 100644
41308 --- a/drivers/isdn/isdnloop/isdnloop.c
41309 +++ b/drivers/isdn/isdnloop/isdnloop.c
41310 @@ -1083,8 +1083,10 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41311 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41312 return -ENOMEM;
41313 }
41314 - for (i = 0; i < 3; i++)
41315 - strcpy(card->s0num[i], sdef.num[i]);
41316 + for (i = 0; i < 3; i++) {
41317 + strlcpy(card->s0num[i], sdef.num[i],
41318 + sizeof(card->s0num[0]));
41319 + }
41320 break;
41321 case ISDN_PTYPE_1TR6:
41322 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
41323 @@ -1097,7 +1099,7 @@ isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp)
41324 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
41325 return -ENOMEM;
41326 }
41327 - strcpy(card->s0num[0], sdef.num[0]);
41328 + strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0]));
41329 card->s0num[1][0] = '\0';
41330 card->s0num[2][0] = '\0';
41331 break;
41332 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
41333 index a4f05c5..1433bc5 100644
41334 --- a/drivers/isdn/mISDN/dsp_cmx.c
41335 +++ b/drivers/isdn/mISDN/dsp_cmx.c
41336 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
41337 static u16 dsp_count; /* last sample count */
41338 static int dsp_count_valid; /* if we have last sample count */
41339
41340 -void
41341 +void __intentional_overflow(-1)
41342 dsp_cmx_send(void *arg)
41343 {
41344 struct dsp_conf *conf;
41345 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41346 index d93e245..e7ece6b 100644
41347 --- a/drivers/leds/leds-clevo-mail.c
41348 +++ b/drivers/leds/leds-clevo-mail.c
41349 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41350 * detected as working, but in reality it is not) as low as
41351 * possible.
41352 */
41353 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
41354 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
41355 {
41356 .callback = clevo_mail_led_dmi_callback,
41357 .ident = "Clevo D410J",
41358 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41359 index 5b8f938..b73d657 100644
41360 --- a/drivers/leds/leds-ss4200.c
41361 +++ b/drivers/leds/leds-ss4200.c
41362 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41363 * detected as working, but in reality it is not) as low as
41364 * possible.
41365 */
41366 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
41367 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
41368 {
41369 .callback = ss4200_led_dmi_callback,
41370 .ident = "Intel SS4200-E",
41371 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41372 index 0bf1e4e..b4bf44e 100644
41373 --- a/drivers/lguest/core.c
41374 +++ b/drivers/lguest/core.c
41375 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41376 * The end address needs +1 because __get_vm_area allocates an
41377 * extra guard page, so we need space for that.
41378 */
41379 +
41380 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41381 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41382 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41383 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41384 +#else
41385 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41386 VM_ALLOC, switcher_addr, switcher_addr
41387 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41388 +#endif
41389 +
41390 if (!switcher_vma) {
41391 err = -ENOMEM;
41392 printk("lguest: could not map switcher pages high\n");
41393 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41394 * Now the Switcher is mapped at the right address, we can't fail!
41395 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41396 */
41397 - memcpy(switcher_vma->addr, start_switcher_text,
41398 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41399 end_switcher_text - start_switcher_text);
41400
41401 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41402 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41403 index bfb39bb..08a603b 100644
41404 --- a/drivers/lguest/page_tables.c
41405 +++ b/drivers/lguest/page_tables.c
41406 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41407 /*:*/
41408
41409 #ifdef CONFIG_X86_PAE
41410 -static void release_pmd(pmd_t *spmd)
41411 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41412 {
41413 /* If the entry's not present, there's nothing to release. */
41414 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41415 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41416 index 5169239..47cb4db 100644
41417 --- a/drivers/lguest/x86/core.c
41418 +++ b/drivers/lguest/x86/core.c
41419 @@ -59,7 +59,7 @@ static struct {
41420 /* Offset from where switcher.S was compiled to where we've copied it */
41421 static unsigned long switcher_offset(void)
41422 {
41423 - return switcher_addr - (unsigned long)start_switcher_text;
41424 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41425 }
41426
41427 /* This cpu's struct lguest_pages (after the Switcher text page) */
41428 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41429 * These copies are pretty cheap, so we do them unconditionally: */
41430 /* Save the current Host top-level page directory.
41431 */
41432 +
41433 +#ifdef CONFIG_PAX_PER_CPU_PGD
41434 + pages->state.host_cr3 = read_cr3();
41435 +#else
41436 pages->state.host_cr3 = __pa(current->mm->pgd);
41437 +#endif
41438 +
41439 /*
41440 * Set up the Guest's page tables to see this CPU's pages (and no
41441 * other CPU's pages).
41442 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41443 * compiled-in switcher code and the high-mapped copy we just made.
41444 */
41445 for (i = 0; i < IDT_ENTRIES; i++)
41446 - default_idt_entries[i] += switcher_offset();
41447 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41448
41449 /*
41450 * Set up the Switcher's per-cpu areas.
41451 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41452 * it will be undisturbed when we switch. To change %cs and jump we
41453 * need this structure to feed to Intel's "lcall" instruction.
41454 */
41455 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41456 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41457 lguest_entry.segment = LGUEST_CS;
41458
41459 /*
41460 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41461 index 40634b0..4f5855e 100644
41462 --- a/drivers/lguest/x86/switcher_32.S
41463 +++ b/drivers/lguest/x86/switcher_32.S
41464 @@ -87,6 +87,7 @@
41465 #include <asm/page.h>
41466 #include <asm/segment.h>
41467 #include <asm/lguest.h>
41468 +#include <asm/processor-flags.h>
41469
41470 // We mark the start of the code to copy
41471 // It's placed in .text tho it's never run here
41472 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41473 // Changes type when we load it: damn Intel!
41474 // For after we switch over our page tables
41475 // That entry will be read-only: we'd crash.
41476 +
41477 +#ifdef CONFIG_PAX_KERNEXEC
41478 + mov %cr0, %edx
41479 + xor $X86_CR0_WP, %edx
41480 + mov %edx, %cr0
41481 +#endif
41482 +
41483 movl $(GDT_ENTRY_TSS*8), %edx
41484 ltr %dx
41485
41486 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41487 // Let's clear it again for our return.
41488 // The GDT descriptor of the Host
41489 // Points to the table after two "size" bytes
41490 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41491 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41492 // Clear "used" from type field (byte 5, bit 2)
41493 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41494 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41495 +
41496 +#ifdef CONFIG_PAX_KERNEXEC
41497 + mov %cr0, %eax
41498 + xor $X86_CR0_WP, %eax
41499 + mov %eax, %cr0
41500 +#endif
41501
41502 // Once our page table's switched, the Guest is live!
41503 // The Host fades as we run this final step.
41504 @@ -295,13 +309,12 @@ deliver_to_host:
41505 // I consulted gcc, and it gave
41506 // These instructions, which I gladly credit:
41507 leal (%edx,%ebx,8), %eax
41508 - movzwl (%eax),%edx
41509 - movl 4(%eax), %eax
41510 - xorw %ax, %ax
41511 - orl %eax, %edx
41512 + movl 4(%eax), %edx
41513 + movw (%eax), %dx
41514 // Now the address of the handler's in %edx
41515 // We call it now: its "iret" drops us home.
41516 - jmp *%edx
41517 + ljmp $__KERNEL_CS, $1f
41518 +1: jmp *%edx
41519
41520 // Every interrupt can come to us here
41521 // But we must truly tell each apart.
41522 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41523 index 0003992..854bbce 100644
41524 --- a/drivers/md/bcache/closure.h
41525 +++ b/drivers/md/bcache/closure.h
41526 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41527 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41528 struct workqueue_struct *wq)
41529 {
41530 - BUG_ON(object_is_on_stack(cl));
41531 + BUG_ON(object_starts_on_stack(cl));
41532 closure_set_ip(cl);
41533 cl->fn = fn;
41534 cl->wq = wq;
41535 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41536 index 547c4c5..5be1de4 100644
41537 --- a/drivers/md/bcache/super.c
41538 +++ b/drivers/md/bcache/super.c
41539 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41540 err:
41541 closure_sync(&op.cl);
41542 /* XXX: test this, it's broken */
41543 - bch_cache_set_error(c, err);
41544 + bch_cache_set_error(c, "%s", err);
41545 }
41546
41547 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41548 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41549 index a7fd821..9dcf6c3 100644
41550 --- a/drivers/md/bitmap.c
41551 +++ b/drivers/md/bitmap.c
41552 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41553 chunk_kb ? "KB" : "B");
41554 if (bitmap->storage.file) {
41555 seq_printf(seq, ", file: ");
41556 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41557 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41558 }
41559
41560 seq_printf(seq, "\n");
41561 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41562 index afe0814..8cf3794 100644
41563 --- a/drivers/md/dm-ioctl.c
41564 +++ b/drivers/md/dm-ioctl.c
41565 @@ -1745,7 +1745,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41566 cmd == DM_LIST_VERSIONS_CMD)
41567 return 0;
41568
41569 - if ((cmd == DM_DEV_CREATE_CMD)) {
41570 + if (cmd == DM_DEV_CREATE_CMD) {
41571 if (!*param->name) {
41572 DMWARN("name not supplied when creating device");
41573 return -EINVAL;
41574 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41575 index 9584443..9fc9ac9 100644
41576 --- a/drivers/md/dm-raid1.c
41577 +++ b/drivers/md/dm-raid1.c
41578 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41579
41580 struct mirror {
41581 struct mirror_set *ms;
41582 - atomic_t error_count;
41583 + atomic_unchecked_t error_count;
41584 unsigned long error_type;
41585 struct dm_dev *dev;
41586 sector_t offset;
41587 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41588 struct mirror *m;
41589
41590 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41591 - if (!atomic_read(&m->error_count))
41592 + if (!atomic_read_unchecked(&m->error_count))
41593 return m;
41594
41595 return NULL;
41596 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41597 * simple way to tell if a device has encountered
41598 * errors.
41599 */
41600 - atomic_inc(&m->error_count);
41601 + atomic_inc_unchecked(&m->error_count);
41602
41603 if (test_and_set_bit(error_type, &m->error_type))
41604 return;
41605 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41606 struct mirror *m = get_default_mirror(ms);
41607
41608 do {
41609 - if (likely(!atomic_read(&m->error_count)))
41610 + if (likely(!atomic_read_unchecked(&m->error_count)))
41611 return m;
41612
41613 if (m-- == ms->mirror)
41614 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41615 {
41616 struct mirror *default_mirror = get_default_mirror(m->ms);
41617
41618 - return !atomic_read(&default_mirror->error_count);
41619 + return !atomic_read_unchecked(&default_mirror->error_count);
41620 }
41621
41622 static int mirror_available(struct mirror_set *ms, struct bio *bio)
41623 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
41624 */
41625 if (likely(region_in_sync(ms, region, 1)))
41626 m = choose_mirror(ms, bio->bi_sector);
41627 - else if (m && atomic_read(&m->error_count))
41628 + else if (m && atomic_read_unchecked(&m->error_count))
41629 m = NULL;
41630
41631 if (likely(m))
41632 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
41633 }
41634
41635 ms->mirror[mirror].ms = ms;
41636 - atomic_set(&(ms->mirror[mirror].error_count), 0);
41637 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
41638 ms->mirror[mirror].error_type = 0;
41639 ms->mirror[mirror].offset = offset;
41640
41641 @@ -1339,7 +1339,7 @@ static void mirror_resume(struct dm_target *ti)
41642 */
41643 static char device_status_char(struct mirror *m)
41644 {
41645 - if (!atomic_read(&(m->error_count)))
41646 + if (!atomic_read_unchecked(&(m->error_count)))
41647 return 'A';
41648
41649 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
41650 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
41651 index 3d404c1..b62af0e 100644
41652 --- a/drivers/md/dm-stats.c
41653 +++ b/drivers/md/dm-stats.c
41654 @@ -382,7 +382,7 @@ do_sync_free:
41655 synchronize_rcu_expedited();
41656 dm_stat_free(&s->rcu_head);
41657 } else {
41658 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
41659 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
41660 call_rcu(&s->rcu_head, dm_stat_free);
41661 }
41662 return 0;
41663 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
41664 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
41665 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
41666 ));
41667 - ACCESS_ONCE(last->last_sector) = end_sector;
41668 - ACCESS_ONCE(last->last_rw) = bi_rw;
41669 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
41670 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
41671 }
41672
41673 rcu_read_lock();
41674 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
41675 index 73c1712..7347292 100644
41676 --- a/drivers/md/dm-stripe.c
41677 +++ b/drivers/md/dm-stripe.c
41678 @@ -21,7 +21,7 @@ struct stripe {
41679 struct dm_dev *dev;
41680 sector_t physical_start;
41681
41682 - atomic_t error_count;
41683 + atomic_unchecked_t error_count;
41684 };
41685
41686 struct stripe_c {
41687 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
41688 kfree(sc);
41689 return r;
41690 }
41691 - atomic_set(&(sc->stripe[i].error_count), 0);
41692 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
41693 }
41694
41695 ti->private = sc;
41696 @@ -327,7 +327,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
41697 DMEMIT("%d ", sc->stripes);
41698 for (i = 0; i < sc->stripes; i++) {
41699 DMEMIT("%s ", sc->stripe[i].dev->name);
41700 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
41701 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
41702 'D' : 'A';
41703 }
41704 buffer[i] = '\0';
41705 @@ -372,8 +372,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
41706 */
41707 for (i = 0; i < sc->stripes; i++)
41708 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
41709 - atomic_inc(&(sc->stripe[i].error_count));
41710 - if (atomic_read(&(sc->stripe[i].error_count)) <
41711 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
41712 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
41713 DM_IO_ERROR_THRESHOLD)
41714 schedule_work(&sc->trigger_event);
41715 }
41716 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
41717 index 8f87835..531854d 100644
41718 --- a/drivers/md/dm-table.c
41719 +++ b/drivers/md/dm-table.c
41720 @@ -286,7 +286,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
41721 static int open_dev(struct dm_dev_internal *d, dev_t dev,
41722 struct mapped_device *md)
41723 {
41724 - static char *_claim_ptr = "I belong to device-mapper";
41725 + static char _claim_ptr[] = "I belong to device-mapper";
41726 struct block_device *bdev;
41727
41728 int r;
41729 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
41730 if (!dev_size)
41731 return 0;
41732
41733 - if ((start >= dev_size) || (start + len > dev_size)) {
41734 + if ((start >= dev_size) || (len > dev_size - start)) {
41735 DMWARN("%s: %s too small for target: "
41736 "start=%llu, len=%llu, dev_size=%llu",
41737 dm_device_name(ti->table->md), bdevname(bdev, b),
41738 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
41739 index 60bce43..9b997d0 100644
41740 --- a/drivers/md/dm-thin-metadata.c
41741 +++ b/drivers/md/dm-thin-metadata.c
41742 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
41743 {
41744 pmd->info.tm = pmd->tm;
41745 pmd->info.levels = 2;
41746 - pmd->info.value_type.context = pmd->data_sm;
41747 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
41748 pmd->info.value_type.size = sizeof(__le64);
41749 pmd->info.value_type.inc = data_block_inc;
41750 pmd->info.value_type.dec = data_block_dec;
41751 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
41752
41753 pmd->bl_info.tm = pmd->tm;
41754 pmd->bl_info.levels = 1;
41755 - pmd->bl_info.value_type.context = pmd->data_sm;
41756 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
41757 pmd->bl_info.value_type.size = sizeof(__le64);
41758 pmd->bl_info.value_type.inc = data_block_inc;
41759 pmd->bl_info.value_type.dec = data_block_dec;
41760 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
41761 index b3e26c7..1efca94 100644
41762 --- a/drivers/md/dm.c
41763 +++ b/drivers/md/dm.c
41764 @@ -179,9 +179,9 @@ struct mapped_device {
41765 /*
41766 * Event handling.
41767 */
41768 - atomic_t event_nr;
41769 + atomic_unchecked_t event_nr;
41770 wait_queue_head_t eventq;
41771 - atomic_t uevent_seq;
41772 + atomic_unchecked_t uevent_seq;
41773 struct list_head uevent_list;
41774 spinlock_t uevent_lock; /* Protect access to uevent_list */
41775
41776 @@ -1985,8 +1985,8 @@ static struct mapped_device *alloc_dev(int minor)
41777 spin_lock_init(&md->deferred_lock);
41778 atomic_set(&md->holders, 1);
41779 atomic_set(&md->open_count, 0);
41780 - atomic_set(&md->event_nr, 0);
41781 - atomic_set(&md->uevent_seq, 0);
41782 + atomic_set_unchecked(&md->event_nr, 0);
41783 + atomic_set_unchecked(&md->uevent_seq, 0);
41784 INIT_LIST_HEAD(&md->uevent_list);
41785 spin_lock_init(&md->uevent_lock);
41786
41787 @@ -2139,7 +2139,7 @@ static void event_callback(void *context)
41788
41789 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
41790
41791 - atomic_inc(&md->event_nr);
41792 + atomic_inc_unchecked(&md->event_nr);
41793 wake_up(&md->eventq);
41794 }
41795
41796 @@ -2832,18 +2832,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
41797
41798 uint32_t dm_next_uevent_seq(struct mapped_device *md)
41799 {
41800 - return atomic_add_return(1, &md->uevent_seq);
41801 + return atomic_add_return_unchecked(1, &md->uevent_seq);
41802 }
41803
41804 uint32_t dm_get_event_nr(struct mapped_device *md)
41805 {
41806 - return atomic_read(&md->event_nr);
41807 + return atomic_read_unchecked(&md->event_nr);
41808 }
41809
41810 int dm_wait_event(struct mapped_device *md, int event_nr)
41811 {
41812 return wait_event_interruptible(md->eventq,
41813 - (event_nr != atomic_read(&md->event_nr)));
41814 + (event_nr != atomic_read_unchecked(&md->event_nr)));
41815 }
41816
41817 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
41818 diff --git a/drivers/md/md.c b/drivers/md/md.c
41819 index 561a65f..f4e8c71 100644
41820 --- a/drivers/md/md.c
41821 +++ b/drivers/md/md.c
41822 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
41823 * start build, activate spare
41824 */
41825 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
41826 -static atomic_t md_event_count;
41827 +static atomic_unchecked_t md_event_count;
41828 void md_new_event(struct mddev *mddev)
41829 {
41830 - atomic_inc(&md_event_count);
41831 + atomic_inc_unchecked(&md_event_count);
41832 wake_up(&md_event_waiters);
41833 }
41834 EXPORT_SYMBOL_GPL(md_new_event);
41835 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
41836 */
41837 static void md_new_event_inintr(struct mddev *mddev)
41838 {
41839 - atomic_inc(&md_event_count);
41840 + atomic_inc_unchecked(&md_event_count);
41841 wake_up(&md_event_waiters);
41842 }
41843
41844 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
41845 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
41846 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
41847 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
41848 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
41849 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
41850
41851 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
41852 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
41853 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
41854 else
41855 sb->resync_offset = cpu_to_le64(0);
41856
41857 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
41858 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
41859
41860 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
41861 sb->size = cpu_to_le64(mddev->dev_sectors);
41862 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
41863 static ssize_t
41864 errors_show(struct md_rdev *rdev, char *page)
41865 {
41866 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
41867 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
41868 }
41869
41870 static ssize_t
41871 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
41872 char *e;
41873 unsigned long n = simple_strtoul(buf, &e, 10);
41874 if (*buf && (*e == 0 || *e == '\n')) {
41875 - atomic_set(&rdev->corrected_errors, n);
41876 + atomic_set_unchecked(&rdev->corrected_errors, n);
41877 return len;
41878 }
41879 return -EINVAL;
41880 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
41881 rdev->sb_loaded = 0;
41882 rdev->bb_page = NULL;
41883 atomic_set(&rdev->nr_pending, 0);
41884 - atomic_set(&rdev->read_errors, 0);
41885 - atomic_set(&rdev->corrected_errors, 0);
41886 + atomic_set_unchecked(&rdev->read_errors, 0);
41887 + atomic_set_unchecked(&rdev->corrected_errors, 0);
41888
41889 INIT_LIST_HEAD(&rdev->same_set);
41890 init_waitqueue_head(&rdev->blocked_wait);
41891 @@ -7042,7 +7042,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
41892
41893 spin_unlock(&pers_lock);
41894 seq_printf(seq, "\n");
41895 - seq->poll_event = atomic_read(&md_event_count);
41896 + seq->poll_event = atomic_read_unchecked(&md_event_count);
41897 return 0;
41898 }
41899 if (v == (void*)2) {
41900 @@ -7145,7 +7145,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
41901 return error;
41902
41903 seq = file->private_data;
41904 - seq->poll_event = atomic_read(&md_event_count);
41905 + seq->poll_event = atomic_read_unchecked(&md_event_count);
41906 return error;
41907 }
41908
41909 @@ -7159,7 +7159,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
41910 /* always allow read */
41911 mask = POLLIN | POLLRDNORM;
41912
41913 - if (seq->poll_event != atomic_read(&md_event_count))
41914 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
41915 mask |= POLLERR | POLLPRI;
41916 return mask;
41917 }
41918 @@ -7203,7 +7203,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
41919 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
41920 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
41921 (int)part_stat_read(&disk->part0, sectors[1]) -
41922 - atomic_read(&disk->sync_io);
41923 + atomic_read_unchecked(&disk->sync_io);
41924 /* sync IO will cause sync_io to increase before the disk_stats
41925 * as sync_io is counted when a request starts, and
41926 * disk_stats is counted when it completes.
41927 diff --git a/drivers/md/md.h b/drivers/md/md.h
41928 index 608050c..6e77db5d 100644
41929 --- a/drivers/md/md.h
41930 +++ b/drivers/md/md.h
41931 @@ -94,13 +94,13 @@ struct md_rdev {
41932 * only maintained for arrays that
41933 * support hot removal
41934 */
41935 - atomic_t read_errors; /* number of consecutive read errors that
41936 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
41937 * we have tried to ignore.
41938 */
41939 struct timespec last_read_error; /* monotonic time since our
41940 * last read error
41941 */
41942 - atomic_t corrected_errors; /* number of corrected read errors,
41943 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
41944 * for reporting to userspace and storing
41945 * in superblock.
41946 */
41947 @@ -446,7 +446,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
41948
41949 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
41950 {
41951 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
41952 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
41953 }
41954
41955 struct md_personality
41956 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
41957 index 3e6d115..ffecdeb 100644
41958 --- a/drivers/md/persistent-data/dm-space-map.h
41959 +++ b/drivers/md/persistent-data/dm-space-map.h
41960 @@ -71,6 +71,7 @@ struct dm_space_map {
41961 dm_sm_threshold_fn fn,
41962 void *context);
41963 };
41964 +typedef struct dm_space_map __no_const dm_space_map_no_const;
41965
41966 /*----------------------------------------------------------------*/
41967
41968 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
41969 index aacf6bf..67d63f2 100644
41970 --- a/drivers/md/raid1.c
41971 +++ b/drivers/md/raid1.c
41972 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
41973 if (r1_sync_page_io(rdev, sect, s,
41974 bio->bi_io_vec[idx].bv_page,
41975 READ) != 0)
41976 - atomic_add(s, &rdev->corrected_errors);
41977 + atomic_add_unchecked(s, &rdev->corrected_errors);
41978 }
41979 sectors -= s;
41980 sect += s;
41981 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
41982 test_bit(In_sync, &rdev->flags)) {
41983 if (r1_sync_page_io(rdev, sect, s,
41984 conf->tmppage, READ)) {
41985 - atomic_add(s, &rdev->corrected_errors);
41986 + atomic_add_unchecked(s, &rdev->corrected_errors);
41987 printk(KERN_INFO
41988 "md/raid1:%s: read error corrected "
41989 "(%d sectors at %llu on %s)\n",
41990 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
41991 index 73dc8a3..bdd515a 100644
41992 --- a/drivers/md/raid10.c
41993 +++ b/drivers/md/raid10.c
41994 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
41995 /* The write handler will notice the lack of
41996 * R10BIO_Uptodate and record any errors etc
41997 */
41998 - atomic_add(r10_bio->sectors,
41999 + atomic_add_unchecked(r10_bio->sectors,
42000 &conf->mirrors[d].rdev->corrected_errors);
42001
42002 /* for reconstruct, we always reschedule after a read.
42003 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42004 {
42005 struct timespec cur_time_mon;
42006 unsigned long hours_since_last;
42007 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42008 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42009
42010 ktime_get_ts(&cur_time_mon);
42011
42012 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42013 * overflowing the shift of read_errors by hours_since_last.
42014 */
42015 if (hours_since_last >= 8 * sizeof(read_errors))
42016 - atomic_set(&rdev->read_errors, 0);
42017 + atomic_set_unchecked(&rdev->read_errors, 0);
42018 else
42019 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42020 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42021 }
42022
42023 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42024 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42025 return;
42026
42027 check_decay_read_errors(mddev, rdev);
42028 - atomic_inc(&rdev->read_errors);
42029 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42030 + atomic_inc_unchecked(&rdev->read_errors);
42031 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42032 char b[BDEVNAME_SIZE];
42033 bdevname(rdev->bdev, b);
42034
42035 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42036 "md/raid10:%s: %s: Raid device exceeded "
42037 "read_error threshold [cur %d:max %d]\n",
42038 mdname(mddev), b,
42039 - atomic_read(&rdev->read_errors), max_read_errors);
42040 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42041 printk(KERN_NOTICE
42042 "md/raid10:%s: %s: Failing raid device\n",
42043 mdname(mddev), b);
42044 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42045 sect +
42046 choose_data_offset(r10_bio, rdev)),
42047 bdevname(rdev->bdev, b));
42048 - atomic_add(s, &rdev->corrected_errors);
42049 + atomic_add_unchecked(s, &rdev->corrected_errors);
42050 }
42051
42052 rdev_dec_pending(rdev, mddev);
42053 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42054 index f8b9068..7a2b9fc 100644
42055 --- a/drivers/md/raid5.c
42056 +++ b/drivers/md/raid5.c
42057 @@ -1886,21 +1886,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42058 mdname(conf->mddev), STRIPE_SECTORS,
42059 (unsigned long long)s,
42060 bdevname(rdev->bdev, b));
42061 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42062 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42063 clear_bit(R5_ReadError, &sh->dev[i].flags);
42064 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42065 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42066 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42067
42068 - if (atomic_read(&rdev->read_errors))
42069 - atomic_set(&rdev->read_errors, 0);
42070 + if (atomic_read_unchecked(&rdev->read_errors))
42071 + atomic_set_unchecked(&rdev->read_errors, 0);
42072 } else {
42073 const char *bdn = bdevname(rdev->bdev, b);
42074 int retry = 0;
42075 int set_bad = 0;
42076
42077 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42078 - atomic_inc(&rdev->read_errors);
42079 + atomic_inc_unchecked(&rdev->read_errors);
42080 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42081 printk_ratelimited(
42082 KERN_WARNING
42083 @@ -1928,7 +1928,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42084 mdname(conf->mddev),
42085 (unsigned long long)s,
42086 bdn);
42087 - } else if (atomic_read(&rdev->read_errors)
42088 + } else if (atomic_read_unchecked(&rdev->read_errors)
42089 > conf->max_nr_stripes)
42090 printk(KERN_WARNING
42091 "md/raid:%s: Too many read errors, failing device %s.\n",
42092 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42093 index 401ef64..836e563 100644
42094 --- a/drivers/media/dvb-core/dvbdev.c
42095 +++ b/drivers/media/dvb-core/dvbdev.c
42096 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42097 const struct dvb_device *template, void *priv, int type)
42098 {
42099 struct dvb_device *dvbdev;
42100 - struct file_operations *dvbdevfops;
42101 + file_operations_no_const *dvbdevfops;
42102 struct device *clsdev;
42103 int minor;
42104 int id;
42105 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42106 index 9b6c3bb..baeb5c7 100644
42107 --- a/drivers/media/dvb-frontends/dib3000.h
42108 +++ b/drivers/media/dvb-frontends/dib3000.h
42109 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42110 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42111 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42112 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42113 -};
42114 +} __no_const;
42115
42116 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42117 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42118 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42119 index ecf21d9..b992428d 100644
42120 --- a/drivers/media/pci/cx88/cx88-video.c
42121 +++ b/drivers/media/pci/cx88/cx88-video.c
42122 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42123
42124 /* ------------------------------------------------------------------ */
42125
42126 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42127 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42128 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42129 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42130 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42131 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42132
42133 module_param_array(video_nr, int, NULL, 0444);
42134 module_param_array(vbi_nr, int, NULL, 0444);
42135 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42136 index c08ae3e..eb59af1 100644
42137 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42138 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42139 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42140 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42141
42142 /* ivtv instance counter */
42143 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42144 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42145
42146 /* Parameter declarations */
42147 static int cardtype[IVTV_MAX_CARDS];
42148 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42149 index dfd0a21..6bbb465 100644
42150 --- a/drivers/media/platform/omap/omap_vout.c
42151 +++ b/drivers/media/platform/omap/omap_vout.c
42152 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42153 OMAP_VIDEO2,
42154 };
42155
42156 -static struct videobuf_queue_ops video_vbq_ops;
42157 /* Variables configurable through module params*/
42158 static u32 video1_numbuffers = 3;
42159 static u32 video2_numbuffers = 3;
42160 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42161 {
42162 struct videobuf_queue *q;
42163 struct omap_vout_device *vout = NULL;
42164 + static struct videobuf_queue_ops video_vbq_ops = {
42165 + .buf_setup = omap_vout_buffer_setup,
42166 + .buf_prepare = omap_vout_buffer_prepare,
42167 + .buf_release = omap_vout_buffer_release,
42168 + .buf_queue = omap_vout_buffer_queue,
42169 + };
42170
42171 vout = video_drvdata(file);
42172 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42173 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42174 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42175
42176 q = &vout->vbq;
42177 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42178 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42179 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42180 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42181 spin_lock_init(&vout->vbq_lock);
42182
42183 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42184 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42185 index 04e6490..2df65bf 100644
42186 --- a/drivers/media/platform/s5p-tv/mixer.h
42187 +++ b/drivers/media/platform/s5p-tv/mixer.h
42188 @@ -156,7 +156,7 @@ struct mxr_layer {
42189 /** layer index (unique identifier) */
42190 int idx;
42191 /** callbacks for layer methods */
42192 - struct mxr_layer_ops ops;
42193 + struct mxr_layer_ops *ops;
42194 /** format array */
42195 const struct mxr_format **fmt_array;
42196 /** size of format array */
42197 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42198 index b93a21f..2535195 100644
42199 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42200 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42201 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42202 {
42203 struct mxr_layer *layer;
42204 int ret;
42205 - struct mxr_layer_ops ops = {
42206 + static struct mxr_layer_ops ops = {
42207 .release = mxr_graph_layer_release,
42208 .buffer_set = mxr_graph_buffer_set,
42209 .stream_set = mxr_graph_stream_set,
42210 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42211 index b713403..53cb5ad 100644
42212 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42213 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42214 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42215 layer->update_buf = next;
42216 }
42217
42218 - layer->ops.buffer_set(layer, layer->update_buf);
42219 + layer->ops->buffer_set(layer, layer->update_buf);
42220
42221 if (done && done != layer->shadow_buf)
42222 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42223 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42224 index 641b1f0..49cff30 100644
42225 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42226 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42227 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42228 layer->geo.src.height = layer->geo.src.full_height;
42229
42230 mxr_geometry_dump(mdev, &layer->geo);
42231 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42232 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42233 mxr_geometry_dump(mdev, &layer->geo);
42234 }
42235
42236 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42237 layer->geo.dst.full_width = mbus_fmt.width;
42238 layer->geo.dst.full_height = mbus_fmt.height;
42239 layer->geo.dst.field = mbus_fmt.field;
42240 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42241 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42242
42243 mxr_geometry_dump(mdev, &layer->geo);
42244 }
42245 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42246 /* set source size to highest accepted value */
42247 geo->src.full_width = max(geo->dst.full_width, pix->width);
42248 geo->src.full_height = max(geo->dst.full_height, pix->height);
42249 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42250 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42251 mxr_geometry_dump(mdev, &layer->geo);
42252 /* set cropping to total visible screen */
42253 geo->src.width = pix->width;
42254 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42255 geo->src.x_offset = 0;
42256 geo->src.y_offset = 0;
42257 /* assure consistency of geometry */
42258 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42259 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42260 mxr_geometry_dump(mdev, &layer->geo);
42261 /* set full size to lowest possible value */
42262 geo->src.full_width = 0;
42263 geo->src.full_height = 0;
42264 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42265 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42266 mxr_geometry_dump(mdev, &layer->geo);
42267
42268 /* returning results */
42269 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42270 target->width = s->r.width;
42271 target->height = s->r.height;
42272
42273 - layer->ops.fix_geometry(layer, stage, s->flags);
42274 + layer->ops->fix_geometry(layer, stage, s->flags);
42275
42276 /* retrieve update selection rectangle */
42277 res.left = target->x_offset;
42278 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42279 mxr_output_get(mdev);
42280
42281 mxr_layer_update_output(layer);
42282 - layer->ops.format_set(layer);
42283 + layer->ops->format_set(layer);
42284 /* enabling layer in hardware */
42285 spin_lock_irqsave(&layer->enq_slock, flags);
42286 layer->state = MXR_LAYER_STREAMING;
42287 spin_unlock_irqrestore(&layer->enq_slock, flags);
42288
42289 - layer->ops.stream_set(layer, MXR_ENABLE);
42290 + layer->ops->stream_set(layer, MXR_ENABLE);
42291 mxr_streamer_get(mdev);
42292
42293 return 0;
42294 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42295 spin_unlock_irqrestore(&layer->enq_slock, flags);
42296
42297 /* disabling layer in hardware */
42298 - layer->ops.stream_set(layer, MXR_DISABLE);
42299 + layer->ops->stream_set(layer, MXR_DISABLE);
42300 /* remove one streamer */
42301 mxr_streamer_put(mdev);
42302 /* allow changes in output configuration */
42303 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42304
42305 void mxr_layer_release(struct mxr_layer *layer)
42306 {
42307 - if (layer->ops.release)
42308 - layer->ops.release(layer);
42309 + if (layer->ops->release)
42310 + layer->ops->release(layer);
42311 }
42312
42313 void mxr_base_layer_release(struct mxr_layer *layer)
42314 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42315
42316 layer->mdev = mdev;
42317 layer->idx = idx;
42318 - layer->ops = *ops;
42319 + layer->ops = ops;
42320
42321 spin_lock_init(&layer->enq_slock);
42322 INIT_LIST_HEAD(&layer->enq_list);
42323 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42324 index 3d13a63..da31bf1 100644
42325 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42326 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42327 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42328 {
42329 struct mxr_layer *layer;
42330 int ret;
42331 - struct mxr_layer_ops ops = {
42332 + static struct mxr_layer_ops ops = {
42333 .release = mxr_vp_layer_release,
42334 .buffer_set = mxr_vp_buffer_set,
42335 .stream_set = mxr_vp_stream_set,
42336 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42337 index 545c04c..a14bded 100644
42338 --- a/drivers/media/radio/radio-cadet.c
42339 +++ b/drivers/media/radio/radio-cadet.c
42340 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42341 unsigned char readbuf[RDS_BUFFER];
42342 int i = 0;
42343
42344 + if (count > RDS_BUFFER)
42345 + return -EFAULT;
42346 mutex_lock(&dev->lock);
42347 if (dev->rdsstat == 0)
42348 cadet_start_rds(dev);
42349 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42350 while (i < count && dev->rdsin != dev->rdsout)
42351 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42352
42353 - if (i && copy_to_user(data, readbuf, i))
42354 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42355 i = -EFAULT;
42356 unlock:
42357 mutex_unlock(&dev->lock);
42358 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42359 index 5236035..c622c74 100644
42360 --- a/drivers/media/radio/radio-maxiradio.c
42361 +++ b/drivers/media/radio/radio-maxiradio.c
42362 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42363 /* TEA5757 pin mappings */
42364 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42365
42366 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42367 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42368
42369 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42370 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42371 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42372 index b914772..7ddbf9b 100644
42373 --- a/drivers/media/radio/radio-shark.c
42374 +++ b/drivers/media/radio/radio-shark.c
42375 @@ -79,7 +79,7 @@ struct shark_device {
42376 u32 last_val;
42377 };
42378
42379 -static atomic_t shark_instance = ATOMIC_INIT(0);
42380 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42381
42382 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42383 {
42384 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42385 index 9fb6697..f167415 100644
42386 --- a/drivers/media/radio/radio-shark2.c
42387 +++ b/drivers/media/radio/radio-shark2.c
42388 @@ -74,7 +74,7 @@ struct shark_device {
42389 u8 *transfer_buffer;
42390 };
42391
42392 -static atomic_t shark_instance = ATOMIC_INIT(0);
42393 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42394
42395 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42396 {
42397 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42398 index 9c9084c..a9e8dfb 100644
42399 --- a/drivers/media/radio/radio-si476x.c
42400 +++ b/drivers/media/radio/radio-si476x.c
42401 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42402 struct si476x_radio *radio;
42403 struct v4l2_ctrl *ctrl;
42404
42405 - static atomic_t instance = ATOMIC_INIT(0);
42406 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42407
42408 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42409 if (!radio)
42410 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42411 index 46da365..3ba4206 100644
42412 --- a/drivers/media/rc/rc-main.c
42413 +++ b/drivers/media/rc/rc-main.c
42414 @@ -1065,7 +1065,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42415 int rc_register_device(struct rc_dev *dev)
42416 {
42417 static bool raw_init = false; /* raw decoders loaded? */
42418 - static atomic_t devno = ATOMIC_INIT(0);
42419 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42420 struct rc_map *rc_map;
42421 const char *path;
42422 int rc;
42423 @@ -1096,7 +1096,7 @@ int rc_register_device(struct rc_dev *dev)
42424 */
42425 mutex_lock(&dev->lock);
42426
42427 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42428 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42429 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42430 dev_set_drvdata(&dev->dev, dev);
42431 rc = device_add(&dev->dev);
42432 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42433 index 3940bb0..fb3952a 100644
42434 --- a/drivers/media/usb/dvb-usb/cxusb.c
42435 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42436 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42437
42438 struct dib0700_adapter_state {
42439 int (*set_param_save) (struct dvb_frontend *);
42440 -};
42441 +} __no_const;
42442
42443 static int dib7070_set_param_override(struct dvb_frontend *fe)
42444 {
42445 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42446 index 6e237b6..dc25556 100644
42447 --- a/drivers/media/usb/dvb-usb/dw2102.c
42448 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42449 @@ -118,7 +118,7 @@ struct su3000_state {
42450
42451 struct s6x0_state {
42452 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42453 -};
42454 +} __no_const;
42455
42456 /* debug */
42457 static int dvb_usb_dw2102_debug;
42458 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42459 index 8f7a6a4..59502dd 100644
42460 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42461 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42462 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42463 __u32 reserved;
42464 };
42465
42466 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42467 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42468 enum v4l2_memory memory)
42469 {
42470 void __user *up_pln;
42471 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42472 return 0;
42473 }
42474
42475 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42476 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42477 enum v4l2_memory memory)
42478 {
42479 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42480 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42481 put_user(kp->start_block, &up->start_block) ||
42482 put_user(kp->blocks, &up->blocks) ||
42483 put_user(tmp, &up->edid) ||
42484 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42485 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42486 return -EFAULT;
42487 return 0;
42488 }
42489 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42490 index 02d1b63..5fd6b16 100644
42491 --- a/drivers/media/v4l2-core/v4l2-device.c
42492 +++ b/drivers/media/v4l2-core/v4l2-device.c
42493 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42494 EXPORT_SYMBOL_GPL(v4l2_device_put);
42495
42496 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42497 - atomic_t *instance)
42498 + atomic_unchecked_t *instance)
42499 {
42500 - int num = atomic_inc_return(instance) - 1;
42501 + int num = atomic_inc_return_unchecked(instance) - 1;
42502 int len = strlen(basename);
42503
42504 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42505 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42506 index 68e6b5e..d8b923e 100644
42507 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42508 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42509 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42510 struct file *file, void *fh, void *p);
42511 } u;
42512 void (*debug)(const void *arg, bool write_only);
42513 -};
42514 +} __do_const;
42515 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42516
42517 /* This control needs a priority check */
42518 #define INFO_FL_PRIO (1 << 0)
42519 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42520 struct video_device *vfd = video_devdata(file);
42521 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42522 bool write_only = false;
42523 - struct v4l2_ioctl_info default_info;
42524 + v4l2_ioctl_info_no_const default_info;
42525 const struct v4l2_ioctl_info *info;
42526 void *fh = file->private_data;
42527 struct v4l2_fh *vfh = NULL;
42528 @@ -2194,7 +2195,7 @@ done:
42529 }
42530
42531 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42532 - void * __user *user_ptr, void ***kernel_ptr)
42533 + void __user **user_ptr, void ***kernel_ptr)
42534 {
42535 int ret = 0;
42536
42537 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42538 ret = -EINVAL;
42539 break;
42540 }
42541 - *user_ptr = (void __user *)buf->m.planes;
42542 + *user_ptr = (void __force_user *)buf->m.planes;
42543 *kernel_ptr = (void *)&buf->m.planes;
42544 *array_size = sizeof(struct v4l2_plane) * buf->length;
42545 ret = 1;
42546 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42547 ret = -EINVAL;
42548 break;
42549 }
42550 - *user_ptr = (void __user *)ctrls->controls;
42551 + *user_ptr = (void __force_user *)ctrls->controls;
42552 *kernel_ptr = (void *)&ctrls->controls;
42553 *array_size = sizeof(struct v4l2_ext_control)
42554 * ctrls->count;
42555 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42556 index 767ff4d..c69d259 100644
42557 --- a/drivers/message/fusion/mptbase.c
42558 +++ b/drivers/message/fusion/mptbase.c
42559 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42560 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42561 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42562
42563 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42564 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42565 +#else
42566 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42567 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42568 +#endif
42569 +
42570 /*
42571 * Rounding UP to nearest 4-kB boundary here...
42572 */
42573 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42574 ioc->facts.GlobalCredits);
42575
42576 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42577 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42578 + NULL, NULL);
42579 +#else
42580 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42581 +#endif
42582 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42583 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42584 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42585 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42586 index dd239bd..689c4f7 100644
42587 --- a/drivers/message/fusion/mptsas.c
42588 +++ b/drivers/message/fusion/mptsas.c
42589 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42590 return 0;
42591 }
42592
42593 +static inline void
42594 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42595 +{
42596 + if (phy_info->port_details) {
42597 + phy_info->port_details->rphy = rphy;
42598 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42599 + ioc->name, rphy));
42600 + }
42601 +
42602 + if (rphy) {
42603 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42604 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42605 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42606 + ioc->name, rphy, rphy->dev.release));
42607 + }
42608 +}
42609 +
42610 /* no mutex */
42611 static void
42612 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42613 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42614 return NULL;
42615 }
42616
42617 -static inline void
42618 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42619 -{
42620 - if (phy_info->port_details) {
42621 - phy_info->port_details->rphy = rphy;
42622 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42623 - ioc->name, rphy));
42624 - }
42625 -
42626 - if (rphy) {
42627 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42628 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42629 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42630 - ioc->name, rphy, rphy->dev.release));
42631 - }
42632 -}
42633 -
42634 static inline struct sas_port *
42635 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42636 {
42637 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42638 index 727819c..ad74694 100644
42639 --- a/drivers/message/fusion/mptscsih.c
42640 +++ b/drivers/message/fusion/mptscsih.c
42641 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
42642
42643 h = shost_priv(SChost);
42644
42645 - if (h) {
42646 - if (h->info_kbuf == NULL)
42647 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42648 - return h->info_kbuf;
42649 - h->info_kbuf[0] = '\0';
42650 + if (!h)
42651 + return NULL;
42652
42653 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42654 - h->info_kbuf[size-1] = '\0';
42655 - }
42656 + if (h->info_kbuf == NULL)
42657 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42658 + return h->info_kbuf;
42659 + h->info_kbuf[0] = '\0';
42660 +
42661 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42662 + h->info_kbuf[size-1] = '\0';
42663
42664 return h->info_kbuf;
42665 }
42666 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
42667 index b7d87cd..3fb36da 100644
42668 --- a/drivers/message/i2o/i2o_proc.c
42669 +++ b/drivers/message/i2o/i2o_proc.c
42670 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
42671 "Array Controller Device"
42672 };
42673
42674 -static char *chtostr(char *tmp, u8 *chars, int n)
42675 -{
42676 - tmp[0] = 0;
42677 - return strncat(tmp, (char *)chars, n);
42678 -}
42679 -
42680 static int i2o_report_query_status(struct seq_file *seq, int block_status,
42681 char *group)
42682 {
42683 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
42684 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
42685 {
42686 struct i2o_controller *c = (struct i2o_controller *)seq->private;
42687 - static u32 work32[5];
42688 - static u8 *work8 = (u8 *) work32;
42689 - static u16 *work16 = (u16 *) work32;
42690 + u32 work32[5];
42691 + u8 *work8 = (u8 *) work32;
42692 + u16 *work16 = (u16 *) work32;
42693 int token;
42694 u32 hwcap;
42695
42696 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
42697 } *result;
42698
42699 i2o_exec_execute_ddm_table ddm_table;
42700 - char tmp[28 + 1];
42701
42702 result = kmalloc(sizeof(*result), GFP_KERNEL);
42703 if (!result)
42704 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
42705
42706 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
42707 seq_printf(seq, "%-#8x", ddm_table.module_id);
42708 - seq_printf(seq, "%-29s",
42709 - chtostr(tmp, ddm_table.module_name_version, 28));
42710 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
42711 seq_printf(seq, "%9d ", ddm_table.data_size);
42712 seq_printf(seq, "%8d", ddm_table.code_size);
42713
42714 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
42715
42716 i2o_driver_result_table *result;
42717 i2o_driver_store_table *dst;
42718 - char tmp[28 + 1];
42719
42720 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
42721 if (result == NULL)
42722 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
42723
42724 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
42725 seq_printf(seq, "%-#8x", dst->module_id);
42726 - seq_printf(seq, "%-29s",
42727 - chtostr(tmp, dst->module_name_version, 28));
42728 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
42729 + seq_printf(seq, "%-.28s", dst->module_name_version);
42730 + seq_printf(seq, "%-.8s", dst->date);
42731 seq_printf(seq, "%8d ", dst->module_size);
42732 seq_printf(seq, "%8d ", dst->mpb_size);
42733 seq_printf(seq, "0x%04x", dst->module_flags);
42734 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
42735 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
42736 {
42737 struct i2o_device *d = (struct i2o_device *)seq->private;
42738 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
42739 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
42740 // == (allow) 512d bytes (max)
42741 - static u16 *work16 = (u16 *) work32;
42742 + u16 *work16 = (u16 *) work32;
42743 int token;
42744 - char tmp[16 + 1];
42745
42746 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
42747
42748 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
42749 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
42750 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
42751 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
42752 - seq_printf(seq, "Vendor info : %s\n",
42753 - chtostr(tmp, (u8 *) (work32 + 2), 16));
42754 - seq_printf(seq, "Product info : %s\n",
42755 - chtostr(tmp, (u8 *) (work32 + 6), 16));
42756 - seq_printf(seq, "Description : %s\n",
42757 - chtostr(tmp, (u8 *) (work32 + 10), 16));
42758 - seq_printf(seq, "Product rev. : %s\n",
42759 - chtostr(tmp, (u8 *) (work32 + 14), 8));
42760 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
42761 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
42762 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
42763 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
42764
42765 seq_printf(seq, "Serial number : ");
42766 print_serial_number(seq, (u8 *) (work32 + 16),
42767 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
42768 u8 pad[256]; // allow up to 256 byte (max) serial number
42769 } result;
42770
42771 - char tmp[24 + 1];
42772 -
42773 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
42774
42775 if (token < 0) {
42776 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
42777 }
42778
42779 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
42780 - seq_printf(seq, "Module name : %s\n",
42781 - chtostr(tmp, result.module_name, 24));
42782 - seq_printf(seq, "Module revision : %s\n",
42783 - chtostr(tmp, result.module_rev, 8));
42784 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
42785 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
42786
42787 seq_printf(seq, "Serial number : ");
42788 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
42789 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42790 u8 instance_number[4];
42791 } result;
42792
42793 - char tmp[64 + 1];
42794 -
42795 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
42796
42797 if (token < 0) {
42798 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42799 return 0;
42800 }
42801
42802 - seq_printf(seq, "Device name : %s\n",
42803 - chtostr(tmp, result.device_name, 64));
42804 - seq_printf(seq, "Service name : %s\n",
42805 - chtostr(tmp, result.service_name, 64));
42806 - seq_printf(seq, "Physical name : %s\n",
42807 - chtostr(tmp, result.physical_location, 64));
42808 - seq_printf(seq, "Instance number : %s\n",
42809 - chtostr(tmp, result.instance_number, 4));
42810 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
42811 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
42812 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
42813 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
42814
42815 return 0;
42816 }
42817 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42818 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
42819 {
42820 struct i2o_device *d = (struct i2o_device *)seq->private;
42821 - static u32 work32[12];
42822 - static u16 *work16 = (u16 *) work32;
42823 - static u8 *work8 = (u8 *) work32;
42824 + u32 work32[12];
42825 + u16 *work16 = (u16 *) work32;
42826 + u8 *work8 = (u8 *) work32;
42827 int token;
42828
42829 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
42830 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
42831 index a8c08f3..155fe3d 100644
42832 --- a/drivers/message/i2o/iop.c
42833 +++ b/drivers/message/i2o/iop.c
42834 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
42835
42836 spin_lock_irqsave(&c->context_list_lock, flags);
42837
42838 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
42839 - atomic_inc(&c->context_list_counter);
42840 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
42841 + atomic_inc_unchecked(&c->context_list_counter);
42842
42843 - entry->context = atomic_read(&c->context_list_counter);
42844 + entry->context = atomic_read_unchecked(&c->context_list_counter);
42845
42846 list_add(&entry->list, &c->context_list);
42847
42848 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
42849
42850 #if BITS_PER_LONG == 64
42851 spin_lock_init(&c->context_list_lock);
42852 - atomic_set(&c->context_list_counter, 0);
42853 + atomic_set_unchecked(&c->context_list_counter, 0);
42854 INIT_LIST_HEAD(&c->context_list);
42855 #endif
42856
42857 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
42858 index fcbb2e9..2635e11 100644
42859 --- a/drivers/mfd/janz-cmodio.c
42860 +++ b/drivers/mfd/janz-cmodio.c
42861 @@ -13,6 +13,7 @@
42862
42863 #include <linux/kernel.h>
42864 #include <linux/module.h>
42865 +#include <linux/slab.h>
42866 #include <linux/init.h>
42867 #include <linux/pci.h>
42868 #include <linux/interrupt.h>
42869 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
42870 index de7fb80..7c1b931 100644
42871 --- a/drivers/mfd/max8925-i2c.c
42872 +++ b/drivers/mfd/max8925-i2c.c
42873 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
42874 const struct i2c_device_id *id)
42875 {
42876 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
42877 - static struct max8925_chip *chip;
42878 + struct max8925_chip *chip;
42879 struct device_node *node = client->dev.of_node;
42880
42881 if (node && !pdata) {
42882 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
42883 index d792772..cd73ba3 100644
42884 --- a/drivers/mfd/tps65910.c
42885 +++ b/drivers/mfd/tps65910.c
42886 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
42887 struct tps65910_platform_data *pdata)
42888 {
42889 int ret = 0;
42890 - static struct regmap_irq_chip *tps6591x_irqs_chip;
42891 + struct regmap_irq_chip *tps6591x_irqs_chip;
42892
42893 if (!irq) {
42894 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
42895 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
42896 index 9aa6d1e..1631bfc 100644
42897 --- a/drivers/mfd/twl4030-irq.c
42898 +++ b/drivers/mfd/twl4030-irq.c
42899 @@ -35,6 +35,7 @@
42900 #include <linux/of.h>
42901 #include <linux/irqdomain.h>
42902 #include <linux/i2c/twl.h>
42903 +#include <asm/pgtable.h>
42904
42905 #include "twl-core.h"
42906
42907 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
42908 * Install an irq handler for each of the SIH modules;
42909 * clone dummy irq_chip since PIH can't *do* anything
42910 */
42911 - twl4030_irq_chip = dummy_irq_chip;
42912 - twl4030_irq_chip.name = "twl4030";
42913 + pax_open_kernel();
42914 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
42915 + *(const char **)&twl4030_irq_chip.name = "twl4030";
42916
42917 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
42918 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
42919 + pax_close_kernel();
42920
42921 for (i = irq_base; i < irq_end; i++) {
42922 irq_set_chip_and_handler(i, &twl4030_irq_chip,
42923 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
42924 index 464419b..64bae8d 100644
42925 --- a/drivers/misc/c2port/core.c
42926 +++ b/drivers/misc/c2port/core.c
42927 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
42928 goto error_idr_alloc;
42929 c2dev->id = ret;
42930
42931 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
42932 + pax_open_kernel();
42933 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
42934 + pax_close_kernel();
42935
42936 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
42937 "c2port%d", c2dev->id);
42938 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
42939 index 36f5d52..32311c3 100644
42940 --- a/drivers/misc/kgdbts.c
42941 +++ b/drivers/misc/kgdbts.c
42942 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
42943 char before[BREAK_INSTR_SIZE];
42944 char after[BREAK_INSTR_SIZE];
42945
42946 - probe_kernel_read(before, (char *)kgdbts_break_test,
42947 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
42948 BREAK_INSTR_SIZE);
42949 init_simple_test();
42950 ts.tst = plant_and_detach_test;
42951 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
42952 /* Activate test with initial breakpoint */
42953 if (!is_early)
42954 kgdb_breakpoint();
42955 - probe_kernel_read(after, (char *)kgdbts_break_test,
42956 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
42957 BREAK_INSTR_SIZE);
42958 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
42959 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
42960 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
42961 index 036effe..b3a6336 100644
42962 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
42963 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
42964 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
42965 * the lid is closed. This leads to interrupts as soon as a little move
42966 * is done.
42967 */
42968 - atomic_inc(&lis3->count);
42969 + atomic_inc_unchecked(&lis3->count);
42970
42971 wake_up_interruptible(&lis3->misc_wait);
42972 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
42973 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
42974 if (lis3->pm_dev)
42975 pm_runtime_get_sync(lis3->pm_dev);
42976
42977 - atomic_set(&lis3->count, 0);
42978 + atomic_set_unchecked(&lis3->count, 0);
42979 return 0;
42980 }
42981
42982 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
42983 add_wait_queue(&lis3->misc_wait, &wait);
42984 while (true) {
42985 set_current_state(TASK_INTERRUPTIBLE);
42986 - data = atomic_xchg(&lis3->count, 0);
42987 + data = atomic_xchg_unchecked(&lis3->count, 0);
42988 if (data)
42989 break;
42990
42991 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
42992 struct lis3lv02d, miscdev);
42993
42994 poll_wait(file, &lis3->misc_wait, wait);
42995 - if (atomic_read(&lis3->count))
42996 + if (atomic_read_unchecked(&lis3->count))
42997 return POLLIN | POLLRDNORM;
42998 return 0;
42999 }
43000 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43001 index c439c82..1f20f57 100644
43002 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43003 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43004 @@ -297,7 +297,7 @@ struct lis3lv02d {
43005 struct input_polled_dev *idev; /* input device */
43006 struct platform_device *pdev; /* platform device */
43007 struct regulator_bulk_data regulators[2];
43008 - atomic_t count; /* interrupt count after last read */
43009 + atomic_unchecked_t count; /* interrupt count after last read */
43010 union axis_conversion ac; /* hw -> logical axis */
43011 int mapped_btns[3];
43012
43013 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43014 index 2f30bad..c4c13d0 100644
43015 --- a/drivers/misc/sgi-gru/gruhandles.c
43016 +++ b/drivers/misc/sgi-gru/gruhandles.c
43017 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43018 unsigned long nsec;
43019
43020 nsec = CLKS2NSEC(clks);
43021 - atomic_long_inc(&mcs_op_statistics[op].count);
43022 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43023 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43024 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43025 if (mcs_op_statistics[op].max < nsec)
43026 mcs_op_statistics[op].max = nsec;
43027 }
43028 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43029 index 4f76359..cdfcb2e 100644
43030 --- a/drivers/misc/sgi-gru/gruprocfs.c
43031 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43032 @@ -32,9 +32,9 @@
43033
43034 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43035
43036 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43037 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43038 {
43039 - unsigned long val = atomic_long_read(v);
43040 + unsigned long val = atomic_long_read_unchecked(v);
43041
43042 seq_printf(s, "%16lu %s\n", val, id);
43043 }
43044 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43045
43046 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43047 for (op = 0; op < mcsop_last; op++) {
43048 - count = atomic_long_read(&mcs_op_statistics[op].count);
43049 - total = atomic_long_read(&mcs_op_statistics[op].total);
43050 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43051 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43052 max = mcs_op_statistics[op].max;
43053 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43054 count ? total / count : 0, max);
43055 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43056 index 5c3ce24..4915ccb 100644
43057 --- a/drivers/misc/sgi-gru/grutables.h
43058 +++ b/drivers/misc/sgi-gru/grutables.h
43059 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43060 * GRU statistics.
43061 */
43062 struct gru_stats_s {
43063 - atomic_long_t vdata_alloc;
43064 - atomic_long_t vdata_free;
43065 - atomic_long_t gts_alloc;
43066 - atomic_long_t gts_free;
43067 - atomic_long_t gms_alloc;
43068 - atomic_long_t gms_free;
43069 - atomic_long_t gts_double_allocate;
43070 - atomic_long_t assign_context;
43071 - atomic_long_t assign_context_failed;
43072 - atomic_long_t free_context;
43073 - atomic_long_t load_user_context;
43074 - atomic_long_t load_kernel_context;
43075 - atomic_long_t lock_kernel_context;
43076 - atomic_long_t unlock_kernel_context;
43077 - atomic_long_t steal_user_context;
43078 - atomic_long_t steal_kernel_context;
43079 - atomic_long_t steal_context_failed;
43080 - atomic_long_t nopfn;
43081 - atomic_long_t asid_new;
43082 - atomic_long_t asid_next;
43083 - atomic_long_t asid_wrap;
43084 - atomic_long_t asid_reuse;
43085 - atomic_long_t intr;
43086 - atomic_long_t intr_cbr;
43087 - atomic_long_t intr_tfh;
43088 - atomic_long_t intr_spurious;
43089 - atomic_long_t intr_mm_lock_failed;
43090 - atomic_long_t call_os;
43091 - atomic_long_t call_os_wait_queue;
43092 - atomic_long_t user_flush_tlb;
43093 - atomic_long_t user_unload_context;
43094 - atomic_long_t user_exception;
43095 - atomic_long_t set_context_option;
43096 - atomic_long_t check_context_retarget_intr;
43097 - atomic_long_t check_context_unload;
43098 - atomic_long_t tlb_dropin;
43099 - atomic_long_t tlb_preload_page;
43100 - atomic_long_t tlb_dropin_fail_no_asid;
43101 - atomic_long_t tlb_dropin_fail_upm;
43102 - atomic_long_t tlb_dropin_fail_invalid;
43103 - atomic_long_t tlb_dropin_fail_range_active;
43104 - atomic_long_t tlb_dropin_fail_idle;
43105 - atomic_long_t tlb_dropin_fail_fmm;
43106 - atomic_long_t tlb_dropin_fail_no_exception;
43107 - atomic_long_t tfh_stale_on_fault;
43108 - atomic_long_t mmu_invalidate_range;
43109 - atomic_long_t mmu_invalidate_page;
43110 - atomic_long_t flush_tlb;
43111 - atomic_long_t flush_tlb_gru;
43112 - atomic_long_t flush_tlb_gru_tgh;
43113 - atomic_long_t flush_tlb_gru_zero_asid;
43114 + atomic_long_unchecked_t vdata_alloc;
43115 + atomic_long_unchecked_t vdata_free;
43116 + atomic_long_unchecked_t gts_alloc;
43117 + atomic_long_unchecked_t gts_free;
43118 + atomic_long_unchecked_t gms_alloc;
43119 + atomic_long_unchecked_t gms_free;
43120 + atomic_long_unchecked_t gts_double_allocate;
43121 + atomic_long_unchecked_t assign_context;
43122 + atomic_long_unchecked_t assign_context_failed;
43123 + atomic_long_unchecked_t free_context;
43124 + atomic_long_unchecked_t load_user_context;
43125 + atomic_long_unchecked_t load_kernel_context;
43126 + atomic_long_unchecked_t lock_kernel_context;
43127 + atomic_long_unchecked_t unlock_kernel_context;
43128 + atomic_long_unchecked_t steal_user_context;
43129 + atomic_long_unchecked_t steal_kernel_context;
43130 + atomic_long_unchecked_t steal_context_failed;
43131 + atomic_long_unchecked_t nopfn;
43132 + atomic_long_unchecked_t asid_new;
43133 + atomic_long_unchecked_t asid_next;
43134 + atomic_long_unchecked_t asid_wrap;
43135 + atomic_long_unchecked_t asid_reuse;
43136 + atomic_long_unchecked_t intr;
43137 + atomic_long_unchecked_t intr_cbr;
43138 + atomic_long_unchecked_t intr_tfh;
43139 + atomic_long_unchecked_t intr_spurious;
43140 + atomic_long_unchecked_t intr_mm_lock_failed;
43141 + atomic_long_unchecked_t call_os;
43142 + atomic_long_unchecked_t call_os_wait_queue;
43143 + atomic_long_unchecked_t user_flush_tlb;
43144 + atomic_long_unchecked_t user_unload_context;
43145 + atomic_long_unchecked_t user_exception;
43146 + atomic_long_unchecked_t set_context_option;
43147 + atomic_long_unchecked_t check_context_retarget_intr;
43148 + atomic_long_unchecked_t check_context_unload;
43149 + atomic_long_unchecked_t tlb_dropin;
43150 + atomic_long_unchecked_t tlb_preload_page;
43151 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43152 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43153 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43154 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43155 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43156 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43157 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43158 + atomic_long_unchecked_t tfh_stale_on_fault;
43159 + atomic_long_unchecked_t mmu_invalidate_range;
43160 + atomic_long_unchecked_t mmu_invalidate_page;
43161 + atomic_long_unchecked_t flush_tlb;
43162 + atomic_long_unchecked_t flush_tlb_gru;
43163 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43164 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43165
43166 - atomic_long_t copy_gpa;
43167 - atomic_long_t read_gpa;
43168 + atomic_long_unchecked_t copy_gpa;
43169 + atomic_long_unchecked_t read_gpa;
43170
43171 - atomic_long_t mesq_receive;
43172 - atomic_long_t mesq_receive_none;
43173 - atomic_long_t mesq_send;
43174 - atomic_long_t mesq_send_failed;
43175 - atomic_long_t mesq_noop;
43176 - atomic_long_t mesq_send_unexpected_error;
43177 - atomic_long_t mesq_send_lb_overflow;
43178 - atomic_long_t mesq_send_qlimit_reached;
43179 - atomic_long_t mesq_send_amo_nacked;
43180 - atomic_long_t mesq_send_put_nacked;
43181 - atomic_long_t mesq_page_overflow;
43182 - atomic_long_t mesq_qf_locked;
43183 - atomic_long_t mesq_qf_noop_not_full;
43184 - atomic_long_t mesq_qf_switch_head_failed;
43185 - atomic_long_t mesq_qf_unexpected_error;
43186 - atomic_long_t mesq_noop_unexpected_error;
43187 - atomic_long_t mesq_noop_lb_overflow;
43188 - atomic_long_t mesq_noop_qlimit_reached;
43189 - atomic_long_t mesq_noop_amo_nacked;
43190 - atomic_long_t mesq_noop_put_nacked;
43191 - atomic_long_t mesq_noop_page_overflow;
43192 + atomic_long_unchecked_t mesq_receive;
43193 + atomic_long_unchecked_t mesq_receive_none;
43194 + atomic_long_unchecked_t mesq_send;
43195 + atomic_long_unchecked_t mesq_send_failed;
43196 + atomic_long_unchecked_t mesq_noop;
43197 + atomic_long_unchecked_t mesq_send_unexpected_error;
43198 + atomic_long_unchecked_t mesq_send_lb_overflow;
43199 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43200 + atomic_long_unchecked_t mesq_send_amo_nacked;
43201 + atomic_long_unchecked_t mesq_send_put_nacked;
43202 + atomic_long_unchecked_t mesq_page_overflow;
43203 + atomic_long_unchecked_t mesq_qf_locked;
43204 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43205 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43206 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43207 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43208 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43209 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43210 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43211 + atomic_long_unchecked_t mesq_noop_put_nacked;
43212 + atomic_long_unchecked_t mesq_noop_page_overflow;
43213
43214 };
43215
43216 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43217 tghop_invalidate, mcsop_last};
43218
43219 struct mcs_op_statistic {
43220 - atomic_long_t count;
43221 - atomic_long_t total;
43222 + atomic_long_unchecked_t count;
43223 + atomic_long_unchecked_t total;
43224 unsigned long max;
43225 };
43226
43227 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43228
43229 #define STAT(id) do { \
43230 if (gru_options & OPT_STATS) \
43231 - atomic_long_inc(&gru_stats.id); \
43232 + atomic_long_inc_unchecked(&gru_stats.id); \
43233 } while (0)
43234
43235 #ifdef CONFIG_SGI_GRU_DEBUG
43236 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43237 index c862cd4..0d176fe 100644
43238 --- a/drivers/misc/sgi-xp/xp.h
43239 +++ b/drivers/misc/sgi-xp/xp.h
43240 @@ -288,7 +288,7 @@ struct xpc_interface {
43241 xpc_notify_func, void *);
43242 void (*received) (short, int, void *);
43243 enum xp_retval (*partid_to_nasids) (short, void *);
43244 -};
43245 +} __no_const;
43246
43247 extern struct xpc_interface xpc_interface;
43248
43249 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43250 index b94d5f7..7f494c5 100644
43251 --- a/drivers/misc/sgi-xp/xpc.h
43252 +++ b/drivers/misc/sgi-xp/xpc.h
43253 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43254 void (*received_payload) (struct xpc_channel *, void *);
43255 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43256 };
43257 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43258
43259 /* struct xpc_partition act_state values (for XPC HB) */
43260
43261 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43262 /* found in xpc_main.c */
43263 extern struct device *xpc_part;
43264 extern struct device *xpc_chan;
43265 -extern struct xpc_arch_operations xpc_arch_ops;
43266 +extern xpc_arch_operations_no_const xpc_arch_ops;
43267 extern int xpc_disengage_timelimit;
43268 extern int xpc_disengage_timedout;
43269 extern int xpc_activate_IRQ_rcvd;
43270 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43271 index 82dc574..8539ab2 100644
43272 --- a/drivers/misc/sgi-xp/xpc_main.c
43273 +++ b/drivers/misc/sgi-xp/xpc_main.c
43274 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43275 .notifier_call = xpc_system_die,
43276 };
43277
43278 -struct xpc_arch_operations xpc_arch_ops;
43279 +xpc_arch_operations_no_const xpc_arch_ops;
43280
43281 /*
43282 * Timer function to enforce the timelimit on the partition disengage.
43283 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43284
43285 if (((die_args->trapnr == X86_TRAP_MF) ||
43286 (die_args->trapnr == X86_TRAP_XF)) &&
43287 - !user_mode_vm(die_args->regs))
43288 + !user_mode(die_args->regs))
43289 xpc_die_deactivate();
43290
43291 break;
43292 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43293 index ef18348..1b53cf0 100644
43294 --- a/drivers/mmc/core/mmc_ops.c
43295 +++ b/drivers/mmc/core/mmc_ops.c
43296 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43297 void *data_buf;
43298 int is_on_stack;
43299
43300 - is_on_stack = object_is_on_stack(buf);
43301 + is_on_stack = object_starts_on_stack(buf);
43302 if (is_on_stack) {
43303 /*
43304 * dma onto stack is unsafe/nonportable, but callers to this
43305 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43306 index 81b2994..dce857e 100644
43307 --- a/drivers/mmc/host/dw_mmc.h
43308 +++ b/drivers/mmc/host/dw_mmc.h
43309 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43310 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43311 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43312 int (*parse_dt)(struct dw_mci *host);
43313 -};
43314 +} __do_const;
43315 #endif /* _DW_MMC_H_ */
43316 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43317 index c3785ed..1984c44 100644
43318 --- a/drivers/mmc/host/mmci.c
43319 +++ b/drivers/mmc/host/mmci.c
43320 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43321 }
43322
43323 if (variant->busy_detect) {
43324 - mmci_ops.card_busy = mmci_card_busy;
43325 + pax_open_kernel();
43326 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43327 + pax_close_kernel();
43328 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43329 }
43330
43331 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43332 index 6debda9..2ba7427 100644
43333 --- a/drivers/mmc/host/sdhci-s3c.c
43334 +++ b/drivers/mmc/host/sdhci-s3c.c
43335 @@ -668,9 +668,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43336 * we can use overriding functions instead of default.
43337 */
43338 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43339 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43340 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43341 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43342 + pax_open_kernel();
43343 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43344 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43345 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43346 + pax_close_kernel();
43347 }
43348
43349 /* It supports additional host capabilities if needed */
43350 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43351 index 096993f..f02c23b 100644
43352 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43353 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43354 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43355 size_t totlen = 0, thislen;
43356 int ret = 0;
43357 size_t buflen = 0;
43358 - static char *buffer;
43359 + char *buffer;
43360
43361 if (!ECCBUF_SIZE) {
43362 /* We should fall back to a general writev implementation.
43363 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43364 index 2ed2bb3..2d0b82e 100644
43365 --- a/drivers/mtd/nand/denali.c
43366 +++ b/drivers/mtd/nand/denali.c
43367 @@ -24,6 +24,7 @@
43368 #include <linux/slab.h>
43369 #include <linux/mtd/mtd.h>
43370 #include <linux/module.h>
43371 +#include <linux/slab.h>
43372
43373 #include "denali.h"
43374
43375 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43376 index 51b9d6a..52af9a7 100644
43377 --- a/drivers/mtd/nftlmount.c
43378 +++ b/drivers/mtd/nftlmount.c
43379 @@ -24,6 +24,7 @@
43380 #include <asm/errno.h>
43381 #include <linux/delay.h>
43382 #include <linux/slab.h>
43383 +#include <linux/sched.h>
43384 #include <linux/mtd/mtd.h>
43385 #include <linux/mtd/nand.h>
43386 #include <linux/mtd/nftl.h>
43387 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43388 index 4b8e895..6b3c498 100644
43389 --- a/drivers/mtd/sm_ftl.c
43390 +++ b/drivers/mtd/sm_ftl.c
43391 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43392 #define SM_CIS_VENDOR_OFFSET 0x59
43393 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43394 {
43395 - struct attribute_group *attr_group;
43396 + attribute_group_no_const *attr_group;
43397 struct attribute **attributes;
43398 struct sm_sysfs_attribute *vendor_attribute;
43399
43400 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43401 index e883bfe..e51a1ec 100644
43402 --- a/drivers/net/bonding/bond_main.c
43403 +++ b/drivers/net/bonding/bond_main.c
43404 @@ -4511,7 +4511,7 @@ static unsigned int bond_get_num_tx_queues(void)
43405 return tx_queues;
43406 }
43407
43408 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43409 +static struct rtnl_link_ops bond_link_ops = {
43410 .kind = "bond",
43411 .priv_size = sizeof(struct bonding),
43412 .setup = bond_setup,
43413 @@ -4636,8 +4636,8 @@ static void __exit bonding_exit(void)
43414
43415 bond_destroy_debugfs();
43416
43417 - rtnl_link_unregister(&bond_link_ops);
43418 unregister_pernet_subsys(&bond_net_ops);
43419 + rtnl_link_unregister(&bond_link_ops);
43420
43421 #ifdef CONFIG_NET_POLL_CONTROLLER
43422 /*
43423 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43424 index f92f001..0b2f9bf 100644
43425 --- a/drivers/net/ethernet/8390/ax88796.c
43426 +++ b/drivers/net/ethernet/8390/ax88796.c
43427 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43428 if (ax->plat->reg_offsets)
43429 ei_local->reg_offset = ax->plat->reg_offsets;
43430 else {
43431 + resource_size_t _mem_size = mem_size;
43432 + do_div(_mem_size, 0x18);
43433 ei_local->reg_offset = ax->reg_offsets;
43434 for (ret = 0; ret < 0x18; ret++)
43435 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43436 + ax->reg_offsets[ret] = _mem_size * ret;
43437 }
43438
43439 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43440 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43441 index da8fcaa..f4b5d3b 100644
43442 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43443 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43444 @@ -1138,7 +1138,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43445 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43446 {
43447 /* RX_MODE controlling object */
43448 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43449 + bnx2x_init_rx_mode_obj(bp);
43450
43451 /* multicast configuration controlling object */
43452 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43453 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43454 index 9fbeee5..5e3e37a 100644
43455 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43456 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43457 @@ -2590,15 +2590,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43458 return rc;
43459 }
43460
43461 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43462 - struct bnx2x_rx_mode_obj *o)
43463 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43464 {
43465 if (CHIP_IS_E1x(bp)) {
43466 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43467 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43468 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43469 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43470 } else {
43471 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43472 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43473 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43474 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43475 }
43476 }
43477
43478 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43479 index 658f4e3..15074a6 100644
43480 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43481 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43482 @@ -1325,8 +1325,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43483
43484 /********************* RX MODE ****************/
43485
43486 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43487 - struct bnx2x_rx_mode_obj *o);
43488 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43489
43490 /**
43491 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43492 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43493 index 7025780..e55a71c 100644
43494 --- a/drivers/net/ethernet/broadcom/tg3.h
43495 +++ b/drivers/net/ethernet/broadcom/tg3.h
43496 @@ -147,6 +147,7 @@
43497 #define CHIPREV_ID_5750_A0 0x4000
43498 #define CHIPREV_ID_5750_A1 0x4001
43499 #define CHIPREV_ID_5750_A3 0x4003
43500 +#define CHIPREV_ID_5750_C1 0x4201
43501 #define CHIPREV_ID_5750_C2 0x4202
43502 #define CHIPREV_ID_5752_A0_HW 0x5000
43503 #define CHIPREV_ID_5752_A0 0x6000
43504 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43505 index 8cffcdf..aadf043 100644
43506 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43507 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43508 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43509 */
43510 struct l2t_skb_cb {
43511 arp_failure_handler_func arp_failure_handler;
43512 -};
43513 +} __no_const;
43514
43515 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43516
43517 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43518 index c73cabd..cd278b1 100644
43519 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43520 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43521 @@ -2186,7 +2186,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
43522
43523 int i;
43524 struct adapter *ap = netdev2adap(dev);
43525 - static const unsigned int *reg_ranges;
43526 + const unsigned int *reg_ranges;
43527 int arr_size = 0, buf_size = 0;
43528
43529 if (is_t4(ap->chip)) {
43530 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43531 index 263b92c..f05134b 100644
43532 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43533 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43534 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43535 for (i=0; i<ETH_ALEN; i++) {
43536 tmp.addr[i] = dev->dev_addr[i];
43537 }
43538 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43539 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43540 break;
43541
43542 case DE4X5_SET_HWADDR: /* Set the hardware address */
43543 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43544 spin_lock_irqsave(&lp->lock, flags);
43545 memcpy(&statbuf, &lp->pktStats, ioc->len);
43546 spin_unlock_irqrestore(&lp->lock, flags);
43547 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43548 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43549 return -EFAULT;
43550 break;
43551 }
43552 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43553 index 2c38cc4..0323f6e 100644
43554 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43555 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43556 @@ -470,7 +470,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43557
43558 if (wrapped)
43559 newacc += 65536;
43560 - ACCESS_ONCE(*acc) = newacc;
43561 + ACCESS_ONCE_RW(*acc) = newacc;
43562 }
43563
43564 static void populate_erx_stats(struct be_adapter *adapter,
43565 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43566 index 212f44b..fb69959 100644
43567 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43568 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43569 @@ -31,6 +31,8 @@
43570 #include <linux/netdevice.h>
43571 #include <linux/phy.h>
43572 #include <linux/platform_device.h>
43573 +#include <linux/interrupt.h>
43574 +#include <linux/irqreturn.h>
43575 #include <net/ip.h>
43576
43577 #include "ftgmac100.h"
43578 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43579 index 8be5b40..081bc1b 100644
43580 --- a/drivers/net/ethernet/faraday/ftmac100.c
43581 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43582 @@ -31,6 +31,8 @@
43583 #include <linux/module.h>
43584 #include <linux/netdevice.h>
43585 #include <linux/platform_device.h>
43586 +#include <linux/interrupt.h>
43587 +#include <linux/irqreturn.h>
43588
43589 #include "ftmac100.h"
43590
43591 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43592 index 5184e2a..acb28c3 100644
43593 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43594 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43595 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43596 }
43597
43598 /* update the base incval used to calculate frequency adjustment */
43599 - ACCESS_ONCE(adapter->base_incval) = incval;
43600 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43601 smp_mb();
43602
43603 /* need lock to prevent incorrect read while modifying cyclecounter */
43604 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43605 index fbe5363..266b4e3 100644
43606 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
43607 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43608 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43609 struct __vxge_hw_fifo *fifo;
43610 struct vxge_hw_fifo_config *config;
43611 u32 txdl_size, txdl_per_memblock;
43612 - struct vxge_hw_mempool_cbs fifo_mp_callback;
43613 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
43614 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
43615 + };
43616 +
43617 struct __vxge_hw_virtualpath *vpath;
43618
43619 if ((vp == NULL) || (attr == NULL)) {
43620 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43621 goto exit;
43622 }
43623
43624 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
43625 -
43626 fifo->mempool =
43627 __vxge_hw_mempool_create(vpath->hldev,
43628 fifo->config->memblock_size,
43629 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43630 index f09e787..f3916a8 100644
43631 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43632 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43633 @@ -2055,7 +2055,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
43634
43635 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
43636 ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
43637 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43638 + pax_open_kernel();
43639 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43640 + pax_close_kernel();
43641 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43642 } else {
43643 return -EIO;
43644 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43645 index 0248a4c..9648d96 100644
43646 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43647 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43648 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
43649 case QLCNIC_NON_PRIV_FUNC:
43650 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
43651 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43652 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43653 + pax_open_kernel();
43654 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43655 + pax_close_kernel();
43656 break;
43657 case QLCNIC_PRIV_FUNC:
43658 ahw->op_mode = QLCNIC_PRIV_FUNC;
43659 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
43660 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43661 + pax_open_kernel();
43662 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43663 + pax_close_kernel();
43664 break;
43665 case QLCNIC_MGMT_FUNC:
43666 ahw->op_mode = QLCNIC_MGMT_FUNC;
43667 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43668 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43669 + pax_open_kernel();
43670 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43671 + pax_close_kernel();
43672 break;
43673 default:
43674 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
43675 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43676 index 1551360..ed6510f 100644
43677 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43678 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43679 @@ -1108,7 +1108,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
43680 struct qlcnic_dump_entry *entry;
43681 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
43682 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
43683 - static const struct qlcnic_dump_operations *fw_dump_ops;
43684 + const struct qlcnic_dump_operations *fw_dump_ops;
43685 struct device *dev = &adapter->pdev->dev;
43686 struct qlcnic_hardware_context *ahw;
43687 void *temp_buffer;
43688 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
43689 index 3397cee..101f8fa 100644
43690 --- a/drivers/net/ethernet/realtek/r8169.c
43691 +++ b/drivers/net/ethernet/realtek/r8169.c
43692 @@ -759,22 +759,22 @@ struct rtl8169_private {
43693 struct mdio_ops {
43694 void (*write)(struct rtl8169_private *, int, int);
43695 int (*read)(struct rtl8169_private *, int);
43696 - } mdio_ops;
43697 + } __no_const mdio_ops;
43698
43699 struct pll_power_ops {
43700 void (*down)(struct rtl8169_private *);
43701 void (*up)(struct rtl8169_private *);
43702 - } pll_power_ops;
43703 + } __no_const pll_power_ops;
43704
43705 struct jumbo_ops {
43706 void (*enable)(struct rtl8169_private *);
43707 void (*disable)(struct rtl8169_private *);
43708 - } jumbo_ops;
43709 + } __no_const jumbo_ops;
43710
43711 struct csi_ops {
43712 void (*write)(struct rtl8169_private *, int, int);
43713 u32 (*read)(struct rtl8169_private *, int);
43714 - } csi_ops;
43715 + } __no_const csi_ops;
43716
43717 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
43718 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
43719 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
43720 index 03acf57..e1251ff 100644
43721 --- a/drivers/net/ethernet/sfc/ptp.c
43722 +++ b/drivers/net/ethernet/sfc/ptp.c
43723 @@ -539,7 +539,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
43724 ptp->start.dma_addr);
43725
43726 /* Clear flag that signals MC ready */
43727 - ACCESS_ONCE(*start) = 0;
43728 + ACCESS_ONCE_RW(*start) = 0;
43729 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
43730 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
43731 EFX_BUG_ON_PARANOID(rc);
43732 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43733 index 50617c5..b13724c 100644
43734 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43735 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43736 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
43737
43738 writel(value, ioaddr + MMC_CNTRL);
43739
43740 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
43741 - MMC_CNTRL, value);
43742 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
43743 +// MMC_CNTRL, value);
43744 }
43745
43746 /* To mask all all interrupts.*/
43747 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
43748 index e6fe0d8..2b7d752 100644
43749 --- a/drivers/net/hyperv/hyperv_net.h
43750 +++ b/drivers/net/hyperv/hyperv_net.h
43751 @@ -101,7 +101,7 @@ struct rndis_device {
43752
43753 enum rndis_device_state state;
43754 bool link_state;
43755 - atomic_t new_req_id;
43756 + atomic_unchecked_t new_req_id;
43757
43758 spinlock_t request_lock;
43759 struct list_head req_list;
43760 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
43761 index 0775f0a..d4fb316 100644
43762 --- a/drivers/net/hyperv/rndis_filter.c
43763 +++ b/drivers/net/hyperv/rndis_filter.c
43764 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
43765 * template
43766 */
43767 set = &rndis_msg->msg.set_req;
43768 - set->req_id = atomic_inc_return(&dev->new_req_id);
43769 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
43770
43771 /* Add to the request list */
43772 spin_lock_irqsave(&dev->request_lock, flags);
43773 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
43774
43775 /* Setup the rndis set */
43776 halt = &request->request_msg.msg.halt_req;
43777 - halt->req_id = atomic_inc_return(&dev->new_req_id);
43778 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
43779
43780 /* Ignore return since this msg is optional. */
43781 rndis_filter_send_request(dev, request);
43782 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
43783 index bf0d55e..82bcfbd1 100644
43784 --- a/drivers/net/ieee802154/fakehard.c
43785 +++ b/drivers/net/ieee802154/fakehard.c
43786 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
43787 phy->transmit_power = 0xbf;
43788
43789 dev->netdev_ops = &fake_ops;
43790 - dev->ml_priv = &fake_mlme;
43791 + dev->ml_priv = (void *)&fake_mlme;
43792
43793 priv = netdev_priv(dev);
43794 priv->phy = phy;
43795 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
43796 index 9bf46bd..bfdaa84 100644
43797 --- a/drivers/net/macvlan.c
43798 +++ b/drivers/net/macvlan.c
43799 @@ -939,13 +939,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
43800 int macvlan_link_register(struct rtnl_link_ops *ops)
43801 {
43802 /* common fields */
43803 - ops->priv_size = sizeof(struct macvlan_dev);
43804 - ops->validate = macvlan_validate;
43805 - ops->maxtype = IFLA_MACVLAN_MAX;
43806 - ops->policy = macvlan_policy;
43807 - ops->changelink = macvlan_changelink;
43808 - ops->get_size = macvlan_get_size;
43809 - ops->fill_info = macvlan_fill_info;
43810 + pax_open_kernel();
43811 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
43812 + *(void **)&ops->validate = macvlan_validate;
43813 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
43814 + *(const void **)&ops->policy = macvlan_policy;
43815 + *(void **)&ops->changelink = macvlan_changelink;
43816 + *(void **)&ops->get_size = macvlan_get_size;
43817 + *(void **)&ops->fill_info = macvlan_fill_info;
43818 + pax_close_kernel();
43819
43820 return rtnl_link_register(ops);
43821 };
43822 @@ -1001,7 +1003,7 @@ static int macvlan_device_event(struct notifier_block *unused,
43823 return NOTIFY_DONE;
43824 }
43825
43826 -static struct notifier_block macvlan_notifier_block __read_mostly = {
43827 +static struct notifier_block macvlan_notifier_block = {
43828 .notifier_call = macvlan_device_event,
43829 };
43830
43831 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
43832 index 9dccb1e..19fd4c9 100644
43833 --- a/drivers/net/macvtap.c
43834 +++ b/drivers/net/macvtap.c
43835 @@ -1183,7 +1183,7 @@ static int macvtap_device_event(struct notifier_block *unused,
43836 return NOTIFY_DONE;
43837 }
43838
43839 -static struct notifier_block macvtap_notifier_block __read_mostly = {
43840 +static struct notifier_block macvtap_notifier_block = {
43841 .notifier_call = macvtap_device_event,
43842 };
43843
43844 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
43845 index daec9b0..6428fcb 100644
43846 --- a/drivers/net/phy/mdio-bitbang.c
43847 +++ b/drivers/net/phy/mdio-bitbang.c
43848 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
43849 struct mdiobb_ctrl *ctrl = bus->priv;
43850
43851 module_put(ctrl->ops->owner);
43852 + mdiobus_unregister(bus);
43853 mdiobus_free(bus);
43854 }
43855 EXPORT_SYMBOL(free_mdio_bitbang);
43856 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
43857 index 72ff14b..11d442d 100644
43858 --- a/drivers/net/ppp/ppp_generic.c
43859 +++ b/drivers/net/ppp/ppp_generic.c
43860 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43861 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
43862 struct ppp_stats stats;
43863 struct ppp_comp_stats cstats;
43864 - char *vers;
43865
43866 switch (cmd) {
43867 case SIOCGPPPSTATS:
43868 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43869 break;
43870
43871 case SIOCGPPPVER:
43872 - vers = PPP_VERSION;
43873 - if (copy_to_user(addr, vers, strlen(vers) + 1))
43874 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
43875 break;
43876 err = 0;
43877 break;
43878 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
43879 index 1252d9c..80e660b 100644
43880 --- a/drivers/net/slip/slhc.c
43881 +++ b/drivers/net/slip/slhc.c
43882 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
43883 register struct tcphdr *thp;
43884 register struct iphdr *ip;
43885 register struct cstate *cs;
43886 - int len, hdrlen;
43887 + long len, hdrlen;
43888 unsigned char *cp = icp;
43889
43890 /* We've got a compressed packet; read the change byte */
43891 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
43892 index 50e43e6..e1a5807 100644
43893 --- a/drivers/net/team/team.c
43894 +++ b/drivers/net/team/team.c
43895 @@ -2869,7 +2869,7 @@ static int team_device_event(struct notifier_block *unused,
43896 return NOTIFY_DONE;
43897 }
43898
43899 -static struct notifier_block team_notifier_block __read_mostly = {
43900 +static struct notifier_block team_notifier_block = {
43901 .notifier_call = team_device_event,
43902 };
43903
43904 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
43905 index 7cb105c..11214ff 100644
43906 --- a/drivers/net/tun.c
43907 +++ b/drivers/net/tun.c
43908 @@ -1826,7 +1826,7 @@ unlock:
43909 }
43910
43911 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
43912 - unsigned long arg, int ifreq_len)
43913 + unsigned long arg, size_t ifreq_len)
43914 {
43915 struct tun_file *tfile = file->private_data;
43916 struct tun_struct *tun;
43917 @@ -1839,6 +1839,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
43918 unsigned int ifindex;
43919 int ret;
43920
43921 + if (ifreq_len > sizeof ifr)
43922 + return -EFAULT;
43923 +
43924 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
43925 if (copy_from_user(&ifr, argp, ifreq_len))
43926 return -EFAULT;
43927 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
43928 index 86292e6..8d34433 100644
43929 --- a/drivers/net/usb/hso.c
43930 +++ b/drivers/net/usb/hso.c
43931 @@ -71,7 +71,7 @@
43932 #include <asm/byteorder.h>
43933 #include <linux/serial_core.h>
43934 #include <linux/serial.h>
43935 -
43936 +#include <asm/local.h>
43937
43938 #define MOD_AUTHOR "Option Wireless"
43939 #define MOD_DESCRIPTION "USB High Speed Option driver"
43940 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
43941 struct urb *urb;
43942
43943 urb = serial->rx_urb[0];
43944 - if (serial->port.count > 0) {
43945 + if (atomic_read(&serial->port.count) > 0) {
43946 count = put_rxbuf_data(urb, serial);
43947 if (count == -1)
43948 return;
43949 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
43950 DUMP1(urb->transfer_buffer, urb->actual_length);
43951
43952 /* Anyone listening? */
43953 - if (serial->port.count == 0)
43954 + if (atomic_read(&serial->port.count) == 0)
43955 return;
43956
43957 if (status == 0) {
43958 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
43959 tty_port_tty_set(&serial->port, tty);
43960
43961 /* check for port already opened, if not set the termios */
43962 - serial->port.count++;
43963 - if (serial->port.count == 1) {
43964 + if (atomic_inc_return(&serial->port.count) == 1) {
43965 serial->rx_state = RX_IDLE;
43966 /* Force default termio settings */
43967 _hso_serial_set_termios(tty, NULL);
43968 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
43969 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
43970 if (result) {
43971 hso_stop_serial_device(serial->parent);
43972 - serial->port.count--;
43973 + atomic_dec(&serial->port.count);
43974 kref_put(&serial->parent->ref, hso_serial_ref_free);
43975 }
43976 } else {
43977 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
43978
43979 /* reset the rts and dtr */
43980 /* do the actual close */
43981 - serial->port.count--;
43982 + atomic_dec(&serial->port.count);
43983
43984 - if (serial->port.count <= 0) {
43985 - serial->port.count = 0;
43986 + if (atomic_read(&serial->port.count) <= 0) {
43987 + atomic_set(&serial->port.count, 0);
43988 tty_port_tty_set(&serial->port, NULL);
43989 if (!usb_gone)
43990 hso_stop_serial_device(serial->parent);
43991 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
43992
43993 /* the actual setup */
43994 spin_lock_irqsave(&serial->serial_lock, flags);
43995 - if (serial->port.count)
43996 + if (atomic_read(&serial->port.count))
43997 _hso_serial_set_termios(tty, old);
43998 else
43999 tty->termios = *old;
44000 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44001 D1("Pending read interrupt on port %d\n", i);
44002 spin_lock(&serial->serial_lock);
44003 if (serial->rx_state == RX_IDLE &&
44004 - serial->port.count > 0) {
44005 + atomic_read(&serial->port.count) > 0) {
44006 /* Setup and send a ctrl req read on
44007 * port i */
44008 if (!serial->rx_urb_filled[0]) {
44009 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44010 /* Start all serial ports */
44011 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44012 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44013 - if (dev2ser(serial_table[i])->port.count) {
44014 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44015 result =
44016 hso_start_serial_device(serial_table[i], GFP_NOIO);
44017 hso_kick_transmit(dev2ser(serial_table[i]));
44018 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44019 index a79e9d3..78cd4fa 100644
44020 --- a/drivers/net/usb/sierra_net.c
44021 +++ b/drivers/net/usb/sierra_net.c
44022 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44023 /* atomic counter partially included in MAC address to make sure 2 devices
44024 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44025 */
44026 -static atomic_t iface_counter = ATOMIC_INIT(0);
44027 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44028
44029 /*
44030 * SYNC Timer Delay definition used to set the expiry time
44031 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44032 dev->net->netdev_ops = &sierra_net_device_ops;
44033
44034 /* change MAC addr to include, ifacenum, and to be unique */
44035 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44036 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44037 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44038
44039 /* we will have to manufacture ethernet headers, prepare template */
44040 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44041 index 2ef5b62..6fa0ec3 100644
44042 --- a/drivers/net/vxlan.c
44043 +++ b/drivers/net/vxlan.c
44044 @@ -2615,7 +2615,7 @@ nla_put_failure:
44045 return -EMSGSIZE;
44046 }
44047
44048 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44049 +static struct rtnl_link_ops vxlan_link_ops = {
44050 .kind = "vxlan",
44051 .maxtype = IFLA_VXLAN_MAX,
44052 .policy = vxlan_policy,
44053 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44054 index 0b60295..b8bfa5b 100644
44055 --- a/drivers/net/wimax/i2400m/rx.c
44056 +++ b/drivers/net/wimax/i2400m/rx.c
44057 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44058 if (i2400m->rx_roq == NULL)
44059 goto error_roq_alloc;
44060
44061 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44062 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44063 GFP_KERNEL);
44064 if (rd == NULL) {
44065 result = -ENOMEM;
44066 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44067 index 7fe1964..7016de0 100644
44068 --- a/drivers/net/wireless/airo.c
44069 +++ b/drivers/net/wireless/airo.c
44070 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44071 struct airo_info *ai = dev->ml_priv;
44072 int ridcode;
44073 int enabled;
44074 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44075 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44076 unsigned char *iobuf;
44077
44078 /* Only super-user can write RIDs */
44079 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44080 index 34c8a33..3261fdc 100644
44081 --- a/drivers/net/wireless/at76c50x-usb.c
44082 +++ b/drivers/net/wireless/at76c50x-usb.c
44083 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44084 }
44085
44086 /* Convert timeout from the DFU status to jiffies */
44087 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44088 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44089 {
44090 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44091 | (s->poll_timeout[1] << 8)
44092 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44093 index ef3329e..c28ff5d 100644
44094 --- a/drivers/net/wireless/ath/ath10k/htc.c
44095 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44096 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44097 /* registered target arrival callback from the HIF layer */
44098 int ath10k_htc_init(struct ath10k *ar)
44099 {
44100 - struct ath10k_hif_cb htc_callbacks;
44101 + static struct ath10k_hif_cb htc_callbacks = {
44102 + .rx_completion = ath10k_htc_rx_completion_handler,
44103 + .tx_completion = ath10k_htc_tx_completion_handler,
44104 + };
44105 struct ath10k_htc_ep *ep = NULL;
44106 struct ath10k_htc *htc = &ar->htc;
44107
44108 @@ -973,8 +976,6 @@ int ath10k_htc_init(struct ath10k *ar)
44109 ath10k_htc_reset_endpoint_states(htc);
44110
44111 /* setup HIF layer callbacks */
44112 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44113 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44114 htc->ar = ar;
44115
44116 /* Get HIF default pipe for HTC message exchange */
44117 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
44118 index e1dd8c7..9f91b3f 100644
44119 --- a/drivers/net/wireless/ath/ath10k/htc.h
44120 +++ b/drivers/net/wireless/ath/ath10k/htc.h
44121 @@ -271,12 +271,12 @@ enum ath10k_htc_ep_id {
44122
44123 struct ath10k_htc_ops {
44124 void (*target_send_suspend_complete)(struct ath10k *ar);
44125 -};
44126 +} __no_const;
44127
44128 struct ath10k_htc_ep_ops {
44129 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
44130 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
44131 -};
44132 +} __no_const;
44133
44134 /* service connection information */
44135 struct ath10k_htc_svc_conn_req {
44136 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44137 index 8d78253..bebbb68 100644
44138 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44139 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44140 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44141 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44142 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44143
44144 - ACCESS_ONCE(ads->ds_link) = i->link;
44145 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44146 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44147 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44148
44149 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44150 ctl6 = SM(i->keytype, AR_EncrType);
44151 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44152
44153 if ((i->is_first || i->is_last) &&
44154 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44155 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44156 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44157 | set11nTries(i->rates, 1)
44158 | set11nTries(i->rates, 2)
44159 | set11nTries(i->rates, 3)
44160 | (i->dur_update ? AR_DurUpdateEna : 0)
44161 | SM(0, AR_BurstDur);
44162
44163 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44164 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44165 | set11nRate(i->rates, 1)
44166 | set11nRate(i->rates, 2)
44167 | set11nRate(i->rates, 3);
44168 } else {
44169 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44170 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44171 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44172 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44173 }
44174
44175 if (!i->is_first) {
44176 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44177 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44178 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44179 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44180 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44181 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44182 return;
44183 }
44184
44185 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44186 break;
44187 }
44188
44189 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44190 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44191 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44192 | SM(i->txpower, AR_XmitPower)
44193 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44194 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44195 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44196 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44197
44198 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44199 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44200 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44201 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44202
44203 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44204 return;
44205
44206 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44207 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44208 | set11nPktDurRTSCTS(i->rates, 1);
44209
44210 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44211 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44212 | set11nPktDurRTSCTS(i->rates, 3);
44213
44214 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44215 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44216 | set11nRateFlags(i->rates, 1)
44217 | set11nRateFlags(i->rates, 2)
44218 | set11nRateFlags(i->rates, 3)
44219 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44220 index f6c5c1b..6058354 100644
44221 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44222 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44223 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44224 (i->qcu << AR_TxQcuNum_S) | desc_len;
44225
44226 checksum += val;
44227 - ACCESS_ONCE(ads->info) = val;
44228 + ACCESS_ONCE_RW(ads->info) = val;
44229
44230 checksum += i->link;
44231 - ACCESS_ONCE(ads->link) = i->link;
44232 + ACCESS_ONCE_RW(ads->link) = i->link;
44233
44234 checksum += i->buf_addr[0];
44235 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44236 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44237 checksum += i->buf_addr[1];
44238 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44239 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44240 checksum += i->buf_addr[2];
44241 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44242 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44243 checksum += i->buf_addr[3];
44244 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44245 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44246
44247 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44248 - ACCESS_ONCE(ads->ctl3) = val;
44249 + ACCESS_ONCE_RW(ads->ctl3) = val;
44250 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44251 - ACCESS_ONCE(ads->ctl5) = val;
44252 + ACCESS_ONCE_RW(ads->ctl5) = val;
44253 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44254 - ACCESS_ONCE(ads->ctl7) = val;
44255 + ACCESS_ONCE_RW(ads->ctl7) = val;
44256 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44257 - ACCESS_ONCE(ads->ctl9) = val;
44258 + ACCESS_ONCE_RW(ads->ctl9) = val;
44259
44260 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44261 - ACCESS_ONCE(ads->ctl10) = checksum;
44262 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44263
44264 if (i->is_first || i->is_last) {
44265 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44266 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44267 | set11nTries(i->rates, 1)
44268 | set11nTries(i->rates, 2)
44269 | set11nTries(i->rates, 3)
44270 | (i->dur_update ? AR_DurUpdateEna : 0)
44271 | SM(0, AR_BurstDur);
44272
44273 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44274 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44275 | set11nRate(i->rates, 1)
44276 | set11nRate(i->rates, 2)
44277 | set11nRate(i->rates, 3);
44278 } else {
44279 - ACCESS_ONCE(ads->ctl13) = 0;
44280 - ACCESS_ONCE(ads->ctl14) = 0;
44281 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44282 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44283 }
44284
44285 ads->ctl20 = 0;
44286 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44287
44288 ctl17 = SM(i->keytype, AR_EncrType);
44289 if (!i->is_first) {
44290 - ACCESS_ONCE(ads->ctl11) = 0;
44291 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44292 - ACCESS_ONCE(ads->ctl15) = 0;
44293 - ACCESS_ONCE(ads->ctl16) = 0;
44294 - ACCESS_ONCE(ads->ctl17) = ctl17;
44295 - ACCESS_ONCE(ads->ctl18) = 0;
44296 - ACCESS_ONCE(ads->ctl19) = 0;
44297 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44298 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44299 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44300 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44301 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44302 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44303 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44304 return;
44305 }
44306
44307 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44308 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44309 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44310 | SM(i->txpower, AR_XmitPower)
44311 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44312 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44313 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44314 ctl12 |= SM(val, AR_PAPRDChainMask);
44315
44316 - ACCESS_ONCE(ads->ctl12) = ctl12;
44317 - ACCESS_ONCE(ads->ctl17) = ctl17;
44318 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44319 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44320
44321 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44322 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44323 | set11nPktDurRTSCTS(i->rates, 1);
44324
44325 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44326 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44327 | set11nPktDurRTSCTS(i->rates, 3);
44328
44329 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44330 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44331 | set11nRateFlags(i->rates, 1)
44332 | set11nRateFlags(i->rates, 2)
44333 | set11nRateFlags(i->rates, 3)
44334 | SM(i->rtscts_rate, AR_RTSCTSRate);
44335
44336 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44337 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44338 }
44339
44340 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44341 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44342 index 69a907b..91e071c 100644
44343 --- a/drivers/net/wireless/ath/ath9k/hw.h
44344 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44345 @@ -657,7 +657,7 @@ struct ath_hw_private_ops {
44346
44347 /* ANI */
44348 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44349 -};
44350 +} __no_const;
44351
44352 /**
44353 * struct ath_spec_scan - parameters for Atheros spectral scan
44354 @@ -729,7 +729,7 @@ struct ath_hw_ops {
44355 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
44356 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
44357 #endif
44358 -};
44359 +} __no_const;
44360
44361 struct ath_nf_limits {
44362 s16 max;
44363 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44364 index 92190da..f3a4c4c 100644
44365 --- a/drivers/net/wireless/b43/phy_lp.c
44366 +++ b/drivers/net/wireless/b43/phy_lp.c
44367 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44368 {
44369 struct ssb_bus *bus = dev->dev->sdev->bus;
44370
44371 - static const struct b206x_channel *chandata = NULL;
44372 + const struct b206x_channel *chandata = NULL;
44373 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44374 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44375 u16 old_comm15, scale;
44376 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44377 index 9581d07..84f6a76 100644
44378 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44379 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44380 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44381 */
44382 if (il3945_mod_params.disable_hw_scan) {
44383 D_INFO("Disabling hw_scan\n");
44384 - il3945_mac_ops.hw_scan = NULL;
44385 + pax_open_kernel();
44386 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44387 + pax_close_kernel();
44388 }
44389
44390 D_INFO("*** LOAD DRIVER ***\n");
44391 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44392 index d94f8ab..5b568c8 100644
44393 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44394 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44395 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44396 {
44397 struct iwl_priv *priv = file->private_data;
44398 char buf[64];
44399 - int buf_size;
44400 + size_t buf_size;
44401 u32 offset, len;
44402
44403 memset(buf, 0, sizeof(buf));
44404 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44405 struct iwl_priv *priv = file->private_data;
44406
44407 char buf[8];
44408 - int buf_size;
44409 + size_t buf_size;
44410 u32 reset_flag;
44411
44412 memset(buf, 0, sizeof(buf));
44413 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44414 {
44415 struct iwl_priv *priv = file->private_data;
44416 char buf[8];
44417 - int buf_size;
44418 + size_t buf_size;
44419 int ht40;
44420
44421 memset(buf, 0, sizeof(buf));
44422 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44423 {
44424 struct iwl_priv *priv = file->private_data;
44425 char buf[8];
44426 - int buf_size;
44427 + size_t buf_size;
44428 int value;
44429
44430 memset(buf, 0, sizeof(buf));
44431 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44432 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44433 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44434
44435 -static const char *fmt_value = " %-30s %10u\n";
44436 -static const char *fmt_hex = " %-30s 0x%02X\n";
44437 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44438 -static const char *fmt_header =
44439 +static const char fmt_value[] = " %-30s %10u\n";
44440 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44441 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44442 +static const char fmt_header[] =
44443 "%-32s current cumulative delta max\n";
44444
44445 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44446 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44447 {
44448 struct iwl_priv *priv = file->private_data;
44449 char buf[8];
44450 - int buf_size;
44451 + size_t buf_size;
44452 int clear;
44453
44454 memset(buf, 0, sizeof(buf));
44455 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44456 {
44457 struct iwl_priv *priv = file->private_data;
44458 char buf[8];
44459 - int buf_size;
44460 + size_t buf_size;
44461 int trace;
44462
44463 memset(buf, 0, sizeof(buf));
44464 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44465 {
44466 struct iwl_priv *priv = file->private_data;
44467 char buf[8];
44468 - int buf_size;
44469 + size_t buf_size;
44470 int missed;
44471
44472 memset(buf, 0, sizeof(buf));
44473 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44474
44475 struct iwl_priv *priv = file->private_data;
44476 char buf[8];
44477 - int buf_size;
44478 + size_t buf_size;
44479 int plcp;
44480
44481 memset(buf, 0, sizeof(buf));
44482 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44483
44484 struct iwl_priv *priv = file->private_data;
44485 char buf[8];
44486 - int buf_size;
44487 + size_t buf_size;
44488 int flush;
44489
44490 memset(buf, 0, sizeof(buf));
44491 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44492
44493 struct iwl_priv *priv = file->private_data;
44494 char buf[8];
44495 - int buf_size;
44496 + size_t buf_size;
44497 int rts;
44498
44499 if (!priv->cfg->ht_params)
44500 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44501 {
44502 struct iwl_priv *priv = file->private_data;
44503 char buf[8];
44504 - int buf_size;
44505 + size_t buf_size;
44506
44507 memset(buf, 0, sizeof(buf));
44508 buf_size = min(count, sizeof(buf) - 1);
44509 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44510 struct iwl_priv *priv = file->private_data;
44511 u32 event_log_flag;
44512 char buf[8];
44513 - int buf_size;
44514 + size_t buf_size;
44515
44516 /* check that the interface is up */
44517 if (!iwl_is_ready(priv))
44518 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44519 struct iwl_priv *priv = file->private_data;
44520 char buf[8];
44521 u32 calib_disabled;
44522 - int buf_size;
44523 + size_t buf_size;
44524
44525 memset(buf, 0, sizeof(buf));
44526 buf_size = min(count, sizeof(buf) - 1);
44527 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44528 index 7aad766..06addb4 100644
44529 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44530 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44531 @@ -1123,7 +1123,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44532 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44533 {
44534 struct iwl_nvm_data *data = priv->nvm_data;
44535 - char *debug_msg;
44536 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44537
44538 if (data->sku_cap_11n_enable &&
44539 !priv->cfg->ht_params) {
44540 @@ -1137,7 +1137,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44541 return -EINVAL;
44542 }
44543
44544 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44545 IWL_DEBUG_INFO(priv, debug_msg,
44546 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44547 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44548 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44549 index c3f904d..4cadf83 100644
44550 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44551 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44552 @@ -1252,7 +1252,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44553 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44554
44555 char buf[8];
44556 - int buf_size;
44557 + size_t buf_size;
44558 u32 reset_flag;
44559
44560 memset(buf, 0, sizeof(buf));
44561 @@ -1273,7 +1273,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44562 {
44563 struct iwl_trans *trans = file->private_data;
44564 char buf[8];
44565 - int buf_size;
44566 + size_t buf_size;
44567 int csr;
44568
44569 memset(buf, 0, sizeof(buf));
44570 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44571 index 2cd3f54..e936f90 100644
44572 --- a/drivers/net/wireless/mac80211_hwsim.c
44573 +++ b/drivers/net/wireless/mac80211_hwsim.c
44574 @@ -2196,25 +2196,19 @@ static int __init init_mac80211_hwsim(void)
44575
44576 if (channels > 1) {
44577 hwsim_if_comb.num_different_channels = channels;
44578 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44579 - mac80211_hwsim_ops.cancel_hw_scan =
44580 - mac80211_hwsim_cancel_hw_scan;
44581 - mac80211_hwsim_ops.sw_scan_start = NULL;
44582 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44583 - mac80211_hwsim_ops.remain_on_channel =
44584 - mac80211_hwsim_roc;
44585 - mac80211_hwsim_ops.cancel_remain_on_channel =
44586 - mac80211_hwsim_croc;
44587 - mac80211_hwsim_ops.add_chanctx =
44588 - mac80211_hwsim_add_chanctx;
44589 - mac80211_hwsim_ops.remove_chanctx =
44590 - mac80211_hwsim_remove_chanctx;
44591 - mac80211_hwsim_ops.change_chanctx =
44592 - mac80211_hwsim_change_chanctx;
44593 - mac80211_hwsim_ops.assign_vif_chanctx =
44594 - mac80211_hwsim_assign_vif_chanctx;
44595 - mac80211_hwsim_ops.unassign_vif_chanctx =
44596 - mac80211_hwsim_unassign_vif_chanctx;
44597 + pax_open_kernel();
44598 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44599 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
44600 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
44601 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
44602 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
44603 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
44604 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
44605 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
44606 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
44607 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
44608 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
44609 + pax_close_kernel();
44610 }
44611
44612 spin_lock_init(&hwsim_radio_lock);
44613 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
44614 index 8169a85..7fa3b47 100644
44615 --- a/drivers/net/wireless/rndis_wlan.c
44616 +++ b/drivers/net/wireless/rndis_wlan.c
44617 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
44618
44619 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
44620
44621 - if (rts_threshold < 0 || rts_threshold > 2347)
44622 + if (rts_threshold > 2347)
44623 rts_threshold = 2347;
44624
44625 tmp = cpu_to_le32(rts_threshold);
44626 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
44627 index fe4c572..99dedfa 100644
44628 --- a/drivers/net/wireless/rt2x00/rt2x00.h
44629 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
44630 @@ -387,7 +387,7 @@ struct rt2x00_intf {
44631 * for hardware which doesn't support hardware
44632 * sequence counting.
44633 */
44634 - atomic_t seqno;
44635 + atomic_unchecked_t seqno;
44636 };
44637
44638 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
44639 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
44640 index 6c8a33b..78212fa 100644
44641 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
44642 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
44643 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
44644 * sequence counter given by mac80211.
44645 */
44646 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
44647 - seqno = atomic_add_return(0x10, &intf->seqno);
44648 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
44649 else
44650 - seqno = atomic_read(&intf->seqno);
44651 + seqno = atomic_read_unchecked(&intf->seqno);
44652
44653 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
44654 hdr->seq_ctrl |= cpu_to_le16(seqno);
44655 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
44656 index e2b3d9c..67a5184 100644
44657 --- a/drivers/net/wireless/ti/wl1251/sdio.c
44658 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
44659 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
44660
44661 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
44662
44663 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44664 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44665 + pax_open_kernel();
44666 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44667 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44668 + pax_close_kernel();
44669
44670 wl1251_info("using dedicated interrupt line");
44671 } else {
44672 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44673 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44674 + pax_open_kernel();
44675 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44676 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44677 + pax_close_kernel();
44678
44679 wl1251_info("using SDIO interrupt");
44680 }
44681 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
44682 index 1c627da..69f7d17 100644
44683 --- a/drivers/net/wireless/ti/wl12xx/main.c
44684 +++ b/drivers/net/wireless/ti/wl12xx/main.c
44685 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44686 sizeof(wl->conf.mem));
44687
44688 /* read data preparation is only needed by wl127x */
44689 - wl->ops->prepare_read = wl127x_prepare_read;
44690 + pax_open_kernel();
44691 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44692 + pax_close_kernel();
44693
44694 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44695 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44696 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44697 sizeof(wl->conf.mem));
44698
44699 /* read data preparation is only needed by wl127x */
44700 - wl->ops->prepare_read = wl127x_prepare_read;
44701 + pax_open_kernel();
44702 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44703 + pax_close_kernel();
44704
44705 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44706 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44707 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
44708 index 7aa0eb8..5a9ef38 100644
44709 --- a/drivers/net/wireless/ti/wl18xx/main.c
44710 +++ b/drivers/net/wireless/ti/wl18xx/main.c
44711 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
44712 }
44713
44714 if (!checksum_param) {
44715 - wl18xx_ops.set_rx_csum = NULL;
44716 - wl18xx_ops.init_vif = NULL;
44717 + pax_open_kernel();
44718 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
44719 + *(void **)&wl18xx_ops.init_vif = NULL;
44720 + pax_close_kernel();
44721 }
44722
44723 /* Enable 11a Band only if we have 5G antennas */
44724 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
44725 index 7ef0b4a..ff65c28 100644
44726 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
44727 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
44728 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
44729 {
44730 struct zd_usb *usb = urb->context;
44731 struct zd_usb_interrupt *intr = &usb->intr;
44732 - int len;
44733 + unsigned int len;
44734 u16 int_num;
44735
44736 ZD_ASSERT(in_interrupt());
44737 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
44738 index 59f95d8..53e0e7f 100644
44739 --- a/drivers/nfc/nfcwilink.c
44740 +++ b/drivers/nfc/nfcwilink.c
44741 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
44742
44743 static int nfcwilink_probe(struct platform_device *pdev)
44744 {
44745 - static struct nfcwilink *drv;
44746 + struct nfcwilink *drv;
44747 int rc;
44748 __u32 protocols;
44749
44750 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
44751 index d93b2b6..ae50401 100644
44752 --- a/drivers/oprofile/buffer_sync.c
44753 +++ b/drivers/oprofile/buffer_sync.c
44754 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
44755 if (cookie == NO_COOKIE)
44756 offset = pc;
44757 if (cookie == INVALID_COOKIE) {
44758 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
44759 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
44760 offset = pc;
44761 }
44762 if (cookie != last_cookie) {
44763 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
44764 /* add userspace sample */
44765
44766 if (!mm) {
44767 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
44768 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
44769 return 0;
44770 }
44771
44772 cookie = lookup_dcookie(mm, s->eip, &offset);
44773
44774 if (cookie == INVALID_COOKIE) {
44775 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
44776 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
44777 return 0;
44778 }
44779
44780 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
44781 /* ignore backtraces if failed to add a sample */
44782 if (state == sb_bt_start) {
44783 state = sb_bt_ignore;
44784 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
44785 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
44786 }
44787 }
44788 release_mm(mm);
44789 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
44790 index c0cc4e7..44d4e54 100644
44791 --- a/drivers/oprofile/event_buffer.c
44792 +++ b/drivers/oprofile/event_buffer.c
44793 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
44794 }
44795
44796 if (buffer_pos == buffer_size) {
44797 - atomic_inc(&oprofile_stats.event_lost_overflow);
44798 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
44799 return;
44800 }
44801
44802 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
44803 index ed2c3ec..deda85a 100644
44804 --- a/drivers/oprofile/oprof.c
44805 +++ b/drivers/oprofile/oprof.c
44806 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
44807 if (oprofile_ops.switch_events())
44808 return;
44809
44810 - atomic_inc(&oprofile_stats.multiplex_counter);
44811 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
44812 start_switch_worker();
44813 }
44814
44815 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
44816 index ee2cfce..7f8f699 100644
44817 --- a/drivers/oprofile/oprofile_files.c
44818 +++ b/drivers/oprofile/oprofile_files.c
44819 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
44820
44821 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
44822
44823 -static ssize_t timeout_read(struct file *file, char __user *buf,
44824 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
44825 size_t count, loff_t *offset)
44826 {
44827 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
44828 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
44829 index 59659ce..6c860a0 100644
44830 --- a/drivers/oprofile/oprofile_stats.c
44831 +++ b/drivers/oprofile/oprofile_stats.c
44832 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
44833 cpu_buf->sample_invalid_eip = 0;
44834 }
44835
44836 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
44837 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
44838 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
44839 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
44840 - atomic_set(&oprofile_stats.multiplex_counter, 0);
44841 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
44842 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
44843 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
44844 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
44845 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
44846 }
44847
44848
44849 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
44850 index 1fc622b..8c48fc3 100644
44851 --- a/drivers/oprofile/oprofile_stats.h
44852 +++ b/drivers/oprofile/oprofile_stats.h
44853 @@ -13,11 +13,11 @@
44854 #include <linux/atomic.h>
44855
44856 struct oprofile_stat_struct {
44857 - atomic_t sample_lost_no_mm;
44858 - atomic_t sample_lost_no_mapping;
44859 - atomic_t bt_lost_no_mapping;
44860 - atomic_t event_lost_overflow;
44861 - atomic_t multiplex_counter;
44862 + atomic_unchecked_t sample_lost_no_mm;
44863 + atomic_unchecked_t sample_lost_no_mapping;
44864 + atomic_unchecked_t bt_lost_no_mapping;
44865 + atomic_unchecked_t event_lost_overflow;
44866 + atomic_unchecked_t multiplex_counter;
44867 };
44868
44869 extern struct oprofile_stat_struct oprofile_stats;
44870 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
44871 index 3f49345..c750d0b 100644
44872 --- a/drivers/oprofile/oprofilefs.c
44873 +++ b/drivers/oprofile/oprofilefs.c
44874 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
44875
44876 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
44877 {
44878 - atomic_t *val = file->private_data;
44879 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
44880 + atomic_unchecked_t *val = file->private_data;
44881 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
44882 }
44883
44884
44885 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
44886
44887
44888 int oprofilefs_create_ro_atomic(struct dentry *root,
44889 - char const *name, atomic_t *val)
44890 + char const *name, atomic_unchecked_t *val)
44891 {
44892 return __oprofilefs_create_file(root, name,
44893 &atomic_ro_fops, 0444, val);
44894 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
44895 index 61be1d9..dec05d7 100644
44896 --- a/drivers/oprofile/timer_int.c
44897 +++ b/drivers/oprofile/timer_int.c
44898 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
44899 return NOTIFY_OK;
44900 }
44901
44902 -static struct notifier_block __refdata oprofile_cpu_notifier = {
44903 +static struct notifier_block oprofile_cpu_notifier = {
44904 .notifier_call = oprofile_cpu_notify,
44905 };
44906
44907 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
44908 index 92ed045..62d39bd7 100644
44909 --- a/drivers/parport/procfs.c
44910 +++ b/drivers/parport/procfs.c
44911 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
44912
44913 *ppos += len;
44914
44915 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
44916 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
44917 }
44918
44919 #ifdef CONFIG_PARPORT_1284
44920 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
44921
44922 *ppos += len;
44923
44924 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
44925 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
44926 }
44927 #endif /* IEEE1284.3 support. */
44928
44929 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
44930 index 2f5786c..61ab4d1 100644
44931 --- a/drivers/pci/hotplug/acpiphp_ibm.c
44932 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
44933 @@ -463,7 +463,9 @@ static int __init ibm_acpiphp_init(void)
44934 goto init_cleanup;
44935 }
44936
44937 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
44938 + pax_open_kernel();
44939 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
44940 + pax_close_kernel();
44941 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
44942
44943 return retval;
44944 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
44945 index a6a71c4..c91097b 100644
44946 --- a/drivers/pci/hotplug/cpcihp_generic.c
44947 +++ b/drivers/pci/hotplug/cpcihp_generic.c
44948 @@ -73,7 +73,6 @@ static u16 port;
44949 static unsigned int enum_bit;
44950 static u8 enum_mask;
44951
44952 -static struct cpci_hp_controller_ops generic_hpc_ops;
44953 static struct cpci_hp_controller generic_hpc;
44954
44955 static int __init validate_parameters(void)
44956 @@ -139,6 +138,10 @@ static int query_enum(void)
44957 return ((value & enum_mask) == enum_mask);
44958 }
44959
44960 +static struct cpci_hp_controller_ops generic_hpc_ops = {
44961 + .query_enum = query_enum,
44962 +};
44963 +
44964 static int __init cpcihp_generic_init(void)
44965 {
44966 int status;
44967 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
44968 pci_dev_put(dev);
44969
44970 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
44971 - generic_hpc_ops.query_enum = query_enum;
44972 generic_hpc.ops = &generic_hpc_ops;
44973
44974 status = cpci_hp_register_controller(&generic_hpc);
44975 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
44976 index 449b4bb..257e2e8 100644
44977 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
44978 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
44979 @@ -59,7 +59,6 @@
44980 /* local variables */
44981 static bool debug;
44982 static bool poll;
44983 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
44984 static struct cpci_hp_controller zt5550_hpc;
44985
44986 /* Primary cPCI bus bridge device */
44987 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
44988 return 0;
44989 }
44990
44991 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
44992 + .query_enum = zt5550_hc_query_enum,
44993 +};
44994 +
44995 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
44996 {
44997 int status;
44998 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
44999 dbg("returned from zt5550_hc_config");
45000
45001 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45002 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45003 zt5550_hpc.ops = &zt5550_hpc_ops;
45004 if(!poll) {
45005 zt5550_hpc.irq = hc_dev->irq;
45006 zt5550_hpc.irq_flags = IRQF_SHARED;
45007 zt5550_hpc.dev_id = hc_dev;
45008
45009 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45010 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45011 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45012 + pax_open_kernel();
45013 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45014 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45015 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45016 + pax_open_kernel();
45017 } else {
45018 info("using ENUM# polling mode");
45019 }
45020 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45021 index 76ba8a1..20ca857 100644
45022 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45023 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45024 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45025
45026 void compaq_nvram_init (void __iomem *rom_start)
45027 {
45028 +
45029 +#ifndef CONFIG_PAX_KERNEXEC
45030 if (rom_start) {
45031 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45032 }
45033 +#endif
45034 +
45035 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45036
45037 /* initialize our int15 lock */
45038 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45039 index ec20f74..c1d961e 100644
45040 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45041 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45042 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45043 return -EINVAL;
45044 }
45045
45046 - slot->ops->owner = owner;
45047 - slot->ops->mod_name = mod_name;
45048 + pax_open_kernel();
45049 + *(struct module **)&slot->ops->owner = owner;
45050 + *(const char **)&slot->ops->mod_name = mod_name;
45051 + pax_close_kernel();
45052
45053 mutex_lock(&pci_hp_mutex);
45054 /*
45055 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45056 index f4a18f5..ff2463c 100644
45057 --- a/drivers/pci/hotplug/pciehp_core.c
45058 +++ b/drivers/pci/hotplug/pciehp_core.c
45059 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
45060 struct slot *slot = ctrl->slot;
45061 struct hotplug_slot *hotplug = NULL;
45062 struct hotplug_slot_info *info = NULL;
45063 - struct hotplug_slot_ops *ops = NULL;
45064 + hotplug_slot_ops_no_const *ops = NULL;
45065 char name[SLOT_NAME_SIZE];
45066 int retval = -ENOMEM;
45067
45068 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45069 index 7128cfd..a0640d6 100644
45070 --- a/drivers/pci/pci-sysfs.c
45071 +++ b/drivers/pci/pci-sysfs.c
45072 @@ -1083,7 +1083,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45073 {
45074 /* allocate attribute structure, piggyback attribute name */
45075 int name_len = write_combine ? 13 : 10;
45076 - struct bin_attribute *res_attr;
45077 + bin_attribute_no_const *res_attr;
45078 int retval;
45079
45080 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45081 @@ -1268,7 +1268,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45082 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45083 {
45084 int retval;
45085 - struct bin_attribute *attr;
45086 + bin_attribute_no_const *attr;
45087
45088 /* If the device has VPD, try to expose it in sysfs. */
45089 if (dev->vpd) {
45090 @@ -1315,7 +1315,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45091 {
45092 int retval;
45093 int rom_size = 0;
45094 - struct bin_attribute *attr;
45095 + bin_attribute_no_const *attr;
45096
45097 if (!sysfs_initialized)
45098 return -EACCES;
45099 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45100 index 8a00c06..18a9715 100644
45101 --- a/drivers/pci/pci.h
45102 +++ b/drivers/pci/pci.h
45103 @@ -95,7 +95,7 @@ struct pci_vpd_ops {
45104 struct pci_vpd {
45105 unsigned int len;
45106 const struct pci_vpd_ops *ops;
45107 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45108 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45109 };
45110
45111 int pci_vpd_pci22_init(struct pci_dev *dev);
45112 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45113 index 403a443..034e050 100644
45114 --- a/drivers/pci/pcie/aspm.c
45115 +++ b/drivers/pci/pcie/aspm.c
45116 @@ -27,9 +27,9 @@
45117 #define MODULE_PARAM_PREFIX "pcie_aspm."
45118
45119 /* Note: those are not register definitions */
45120 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45121 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45122 -#define ASPM_STATE_L1 (4) /* L1 state */
45123 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45124 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45125 +#define ASPM_STATE_L1 (4U) /* L1 state */
45126 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45127 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45128
45129 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45130 index 7ef0f86..17b710f 100644
45131 --- a/drivers/pci/probe.c
45132 +++ b/drivers/pci/probe.c
45133 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45134 struct pci_bus_region region, inverted_region;
45135 bool bar_too_big = false, bar_disabled = false;
45136
45137 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45138 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45139
45140 /* No printks while decoding is disabled! */
45141 if (!dev->mmio_always_on) {
45142 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45143 index cdc7836..528635c 100644
45144 --- a/drivers/pci/proc.c
45145 +++ b/drivers/pci/proc.c
45146 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45147 static int __init pci_proc_init(void)
45148 {
45149 struct pci_dev *dev = NULL;
45150 +
45151 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45152 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45153 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45154 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45155 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45156 +#endif
45157 +#else
45158 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45159 +#endif
45160 proc_create("devices", 0, proc_bus_pci_dir,
45161 &proc_bus_pci_dev_operations);
45162 proc_initialized = 1;
45163 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45164 index 3e5b4497..dcdfb70 100644
45165 --- a/drivers/platform/x86/chromeos_laptop.c
45166 +++ b/drivers/platform/x86/chromeos_laptop.c
45167 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45168 return 0;
45169 }
45170
45171 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45172 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45173 {
45174 .ident = "Samsung Series 5 550 - Touchpad",
45175 .matches = {
45176 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45177 index 62f8030..c7f2a45 100644
45178 --- a/drivers/platform/x86/msi-laptop.c
45179 +++ b/drivers/platform/x86/msi-laptop.c
45180 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45181
45182 if (!quirks->ec_read_only) {
45183 /* allow userland write sysfs file */
45184 - dev_attr_bluetooth.store = store_bluetooth;
45185 - dev_attr_wlan.store = store_wlan;
45186 - dev_attr_threeg.store = store_threeg;
45187 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45188 - dev_attr_wlan.attr.mode |= S_IWUSR;
45189 - dev_attr_threeg.attr.mode |= S_IWUSR;
45190 + pax_open_kernel();
45191 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45192 + *(void **)&dev_attr_wlan.store = store_wlan;
45193 + *(void **)&dev_attr_threeg.store = store_threeg;
45194 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45195 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45196 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45197 + pax_close_kernel();
45198 }
45199
45200 /* disable hardware control by fn key */
45201 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45202 index 70222f2..8c8ce66 100644
45203 --- a/drivers/platform/x86/msi-wmi.c
45204 +++ b/drivers/platform/x86/msi-wmi.c
45205 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45206 static void msi_wmi_notify(u32 value, void *context)
45207 {
45208 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45209 - static struct key_entry *key;
45210 + struct key_entry *key;
45211 union acpi_object *obj;
45212 acpi_status status;
45213
45214 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45215 index 13ec195..6af61af 100644
45216 --- a/drivers/platform/x86/sony-laptop.c
45217 +++ b/drivers/platform/x86/sony-laptop.c
45218 @@ -2475,7 +2475,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45219 }
45220
45221 /* High speed charging function */
45222 -static struct device_attribute *hsc_handle;
45223 +static device_attribute_no_const *hsc_handle;
45224
45225 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45226 struct device_attribute *attr,
45227 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45228 index 03ca6c1..1ef2ddd 100644
45229 --- a/drivers/platform/x86/thinkpad_acpi.c
45230 +++ b/drivers/platform/x86/thinkpad_acpi.c
45231 @@ -2091,7 +2091,7 @@ static int hotkey_mask_get(void)
45232 return 0;
45233 }
45234
45235 -void static hotkey_mask_warn_incomplete_mask(void)
45236 +static void hotkey_mask_warn_incomplete_mask(void)
45237 {
45238 /* log only what the user can fix... */
45239 const u32 wantedmask = hotkey_driver_mask &
45240 @@ -2318,11 +2318,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45241 }
45242 }
45243
45244 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45245 - struct tp_nvram_state *newn,
45246 - const u32 event_mask)
45247 -{
45248 -
45249 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45250 do { \
45251 if ((event_mask & (1 << __scancode)) && \
45252 @@ -2336,36 +2331,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45253 tpacpi_hotkey_send_key(__scancode); \
45254 } while (0)
45255
45256 - void issue_volchange(const unsigned int oldvol,
45257 - const unsigned int newvol)
45258 - {
45259 - unsigned int i = oldvol;
45260 +static void issue_volchange(const unsigned int oldvol,
45261 + const unsigned int newvol,
45262 + const u32 event_mask)
45263 +{
45264 + unsigned int i = oldvol;
45265
45266 - while (i > newvol) {
45267 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45268 - i--;
45269 - }
45270 - while (i < newvol) {
45271 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45272 - i++;
45273 - }
45274 + while (i > newvol) {
45275 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45276 + i--;
45277 }
45278 + while (i < newvol) {
45279 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45280 + i++;
45281 + }
45282 +}
45283
45284 - void issue_brightnesschange(const unsigned int oldbrt,
45285 - const unsigned int newbrt)
45286 - {
45287 - unsigned int i = oldbrt;
45288 +static void issue_brightnesschange(const unsigned int oldbrt,
45289 + const unsigned int newbrt,
45290 + const u32 event_mask)
45291 +{
45292 + unsigned int i = oldbrt;
45293
45294 - while (i > newbrt) {
45295 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45296 - i--;
45297 - }
45298 - while (i < newbrt) {
45299 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45300 - i++;
45301 - }
45302 + while (i > newbrt) {
45303 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45304 + i--;
45305 + }
45306 + while (i < newbrt) {
45307 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45308 + i++;
45309 }
45310 +}
45311
45312 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45313 + struct tp_nvram_state *newn,
45314 + const u32 event_mask)
45315 +{
45316 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45317 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45318 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45319 @@ -2399,7 +2400,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45320 oldn->volume_level != newn->volume_level) {
45321 /* recently muted, or repeated mute keypress, or
45322 * multiple presses ending in mute */
45323 - issue_volchange(oldn->volume_level, newn->volume_level);
45324 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45325 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45326 }
45327 } else {
45328 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45329 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45330 }
45331 if (oldn->volume_level != newn->volume_level) {
45332 - issue_volchange(oldn->volume_level, newn->volume_level);
45333 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45334 } else if (oldn->volume_toggle != newn->volume_toggle) {
45335 /* repeated vol up/down keypress at end of scale ? */
45336 if (newn->volume_level == 0)
45337 @@ -2422,7 +2423,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45338 /* handle brightness */
45339 if (oldn->brightness_level != newn->brightness_level) {
45340 issue_brightnesschange(oldn->brightness_level,
45341 - newn->brightness_level);
45342 + newn->brightness_level,
45343 + event_mask);
45344 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45345 /* repeated key presses that didn't change state */
45346 if (newn->brightness_level == 0)
45347 @@ -2431,10 +2433,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45348 && !tp_features.bright_unkfw)
45349 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45350 }
45351 +}
45352
45353 #undef TPACPI_COMPARE_KEY
45354 #undef TPACPI_MAY_SEND_KEY
45355 -}
45356
45357 /*
45358 * Polling driver
45359 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45360 index 769d265..a3a05ca 100644
45361 --- a/drivers/pnp/pnpbios/bioscalls.c
45362 +++ b/drivers/pnp/pnpbios/bioscalls.c
45363 @@ -58,7 +58,7 @@ do { \
45364 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45365 } while(0)
45366
45367 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45368 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45369 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45370
45371 /*
45372 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45373
45374 cpu = get_cpu();
45375 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45376 +
45377 + pax_open_kernel();
45378 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45379 + pax_close_kernel();
45380
45381 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45382 spin_lock_irqsave(&pnp_bios_lock, flags);
45383 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45384 :"memory");
45385 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45386
45387 + pax_open_kernel();
45388 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45389 + pax_close_kernel();
45390 +
45391 put_cpu();
45392
45393 /* If we get here and this is set then the PnP BIOS faulted on us. */
45394 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45395 return status;
45396 }
45397
45398 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45399 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45400 {
45401 int i;
45402
45403 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45404 pnp_bios_callpoint.offset = header->fields.pm16offset;
45405 pnp_bios_callpoint.segment = PNP_CS16;
45406
45407 + pax_open_kernel();
45408 +
45409 for_each_possible_cpu(i) {
45410 struct desc_struct *gdt = get_cpu_gdt_table(i);
45411 if (!gdt)
45412 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45413 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45414 (unsigned long)__va(header->fields.pm16dseg));
45415 }
45416 +
45417 + pax_close_kernel();
45418 }
45419 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45420 index d95e101..67f0c3f 100644
45421 --- a/drivers/pnp/resource.c
45422 +++ b/drivers/pnp/resource.c
45423 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45424 return 1;
45425
45426 /* check if the resource is valid */
45427 - if (*irq < 0 || *irq > 15)
45428 + if (*irq > 15)
45429 return 0;
45430
45431 /* check if the resource is reserved */
45432 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45433 return 1;
45434
45435 /* check if the resource is valid */
45436 - if (*dma < 0 || *dma == 4 || *dma > 7)
45437 + if (*dma == 4 || *dma > 7)
45438 return 0;
45439
45440 /* check if the resource is reserved */
45441 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45442 index 0c52e2a..3421ab7 100644
45443 --- a/drivers/power/pda_power.c
45444 +++ b/drivers/power/pda_power.c
45445 @@ -37,7 +37,11 @@ static int polling;
45446
45447 #if IS_ENABLED(CONFIG_USB_PHY)
45448 static struct usb_phy *transceiver;
45449 -static struct notifier_block otg_nb;
45450 +static int otg_handle_notification(struct notifier_block *nb,
45451 + unsigned long event, void *unused);
45452 +static struct notifier_block otg_nb = {
45453 + .notifier_call = otg_handle_notification
45454 +};
45455 #endif
45456
45457 static struct regulator *ac_draw;
45458 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45459
45460 #if IS_ENABLED(CONFIG_USB_PHY)
45461 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45462 - otg_nb.notifier_call = otg_handle_notification;
45463 ret = usb_register_notifier(transceiver, &otg_nb);
45464 if (ret) {
45465 dev_err(dev, "failure to register otg notifier\n");
45466 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45467 index cc439fd..8fa30df 100644
45468 --- a/drivers/power/power_supply.h
45469 +++ b/drivers/power/power_supply.h
45470 @@ -16,12 +16,12 @@ struct power_supply;
45471
45472 #ifdef CONFIG_SYSFS
45473
45474 -extern void power_supply_init_attrs(struct device_type *dev_type);
45475 +extern void power_supply_init_attrs(void);
45476 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45477
45478 #else
45479
45480 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45481 +static inline void power_supply_init_attrs(void) {}
45482 #define power_supply_uevent NULL
45483
45484 #endif /* CONFIG_SYSFS */
45485 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45486 index 00e6672..2642c08 100644
45487 --- a/drivers/power/power_supply_core.c
45488 +++ b/drivers/power/power_supply_core.c
45489 @@ -24,7 +24,10 @@
45490 struct class *power_supply_class;
45491 EXPORT_SYMBOL_GPL(power_supply_class);
45492
45493 -static struct device_type power_supply_dev_type;
45494 +extern const struct attribute_group *power_supply_attr_groups[];
45495 +static struct device_type power_supply_dev_type = {
45496 + .groups = power_supply_attr_groups,
45497 +};
45498
45499 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45500 struct power_supply *supply)
45501 @@ -584,7 +587,7 @@ static int __init power_supply_class_init(void)
45502 return PTR_ERR(power_supply_class);
45503
45504 power_supply_class->dev_uevent = power_supply_uevent;
45505 - power_supply_init_attrs(&power_supply_dev_type);
45506 + power_supply_init_attrs();
45507
45508 return 0;
45509 }
45510 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45511 index 44420d1..967126e 100644
45512 --- a/drivers/power/power_supply_sysfs.c
45513 +++ b/drivers/power/power_supply_sysfs.c
45514 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45515 .is_visible = power_supply_attr_is_visible,
45516 };
45517
45518 -static const struct attribute_group *power_supply_attr_groups[] = {
45519 +const struct attribute_group *power_supply_attr_groups[] = {
45520 &power_supply_attr_group,
45521 NULL,
45522 };
45523
45524 -void power_supply_init_attrs(struct device_type *dev_type)
45525 +void power_supply_init_attrs(void)
45526 {
45527 int i;
45528
45529 - dev_type->groups = power_supply_attr_groups;
45530 -
45531 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45532 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45533 }
45534 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45535 index a01b8b3..37c2afe 100644
45536 --- a/drivers/regulator/core.c
45537 +++ b/drivers/regulator/core.c
45538 @@ -3307,7 +3307,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45539 {
45540 const struct regulation_constraints *constraints = NULL;
45541 const struct regulator_init_data *init_data;
45542 - static atomic_t regulator_no = ATOMIC_INIT(0);
45543 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45544 struct regulator_dev *rdev;
45545 struct device *dev;
45546 int ret, i;
45547 @@ -3377,7 +3377,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45548 rdev->dev.of_node = config->of_node;
45549 rdev->dev.parent = dev;
45550 dev_set_name(&rdev->dev, "regulator.%d",
45551 - atomic_inc_return(&regulator_no) - 1);
45552 + atomic_inc_return_unchecked(&regulator_no) - 1);
45553 ret = device_register(&rdev->dev);
45554 if (ret != 0) {
45555 put_device(&rdev->dev);
45556 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45557 index 144bcac..d20e7db 100644
45558 --- a/drivers/regulator/max8660.c
45559 +++ b/drivers/regulator/max8660.c
45560 @@ -420,8 +420,10 @@ static int max8660_probe(struct i2c_client *client,
45561 max8660->shadow_regs[MAX8660_OVER1] = 5;
45562 } else {
45563 /* Otherwise devices can be toggled via software */
45564 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45565 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45566 + pax_open_kernel();
45567 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45568 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45569 + pax_close_kernel();
45570 }
45571
45572 /*
45573 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45574 index 5b77ab7..a62f061 100644
45575 --- a/drivers/regulator/max8973-regulator.c
45576 +++ b/drivers/regulator/max8973-regulator.c
45577 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45578 if (!pdata || !pdata->enable_ext_control) {
45579 max->desc.enable_reg = MAX8973_VOUT;
45580 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45581 - max->ops.enable = regulator_enable_regmap;
45582 - max->ops.disable = regulator_disable_regmap;
45583 - max->ops.is_enabled = regulator_is_enabled_regmap;
45584 + pax_open_kernel();
45585 + *(void **)&max->ops.enable = regulator_enable_regmap;
45586 + *(void **)&max->ops.disable = regulator_disable_regmap;
45587 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45588 + pax_close_kernel();
45589 }
45590
45591 if (pdata) {
45592 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45593 index 1037e07..e64dea1 100644
45594 --- a/drivers/regulator/mc13892-regulator.c
45595 +++ b/drivers/regulator/mc13892-regulator.c
45596 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45597 }
45598 mc13xxx_unlock(mc13892);
45599
45600 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45601 + pax_open_kernel();
45602 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45603 = mc13892_vcam_set_mode;
45604 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45605 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45606 = mc13892_vcam_get_mode;
45607 + pax_close_kernel();
45608
45609 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
45610 ARRAY_SIZE(mc13892_regulators));
45611 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
45612 index 24e733c..bfbaa3e 100644
45613 --- a/drivers/rtc/rtc-cmos.c
45614 +++ b/drivers/rtc/rtc-cmos.c
45615 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
45616 hpet_rtc_timer_init();
45617
45618 /* export at least the first block of NVRAM */
45619 - nvram.size = address_space - NVRAM_OFFSET;
45620 + pax_open_kernel();
45621 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
45622 + pax_close_kernel();
45623 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
45624 if (retval < 0) {
45625 dev_dbg(dev, "can't create nvram file? %d\n", retval);
45626 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
45627 index d049393..bb20be0 100644
45628 --- a/drivers/rtc/rtc-dev.c
45629 +++ b/drivers/rtc/rtc-dev.c
45630 @@ -16,6 +16,7 @@
45631 #include <linux/module.h>
45632 #include <linux/rtc.h>
45633 #include <linux/sched.h>
45634 +#include <linux/grsecurity.h>
45635 #include "rtc-core.h"
45636
45637 static dev_t rtc_devt;
45638 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
45639 if (copy_from_user(&tm, uarg, sizeof(tm)))
45640 return -EFAULT;
45641
45642 + gr_log_timechange();
45643 +
45644 return rtc_set_time(rtc, &tm);
45645
45646 case RTC_PIE_ON:
45647 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
45648 index ca18fd1..055e42d 100644
45649 --- a/drivers/rtc/rtc-ds1307.c
45650 +++ b/drivers/rtc/rtc-ds1307.c
45651 @@ -107,7 +107,7 @@ struct ds1307 {
45652 u8 offset; /* register's offset */
45653 u8 regs[11];
45654 u16 nvram_offset;
45655 - struct bin_attribute *nvram;
45656 + bin_attribute_no_const *nvram;
45657 enum ds_type type;
45658 unsigned long flags;
45659 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
45660 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
45661 index fcb0329..d77b7f2 100644
45662 --- a/drivers/rtc/rtc-m48t59.c
45663 +++ b/drivers/rtc/rtc-m48t59.c
45664 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
45665 if (IS_ERR(m48t59->rtc))
45666 return PTR_ERR(m48t59->rtc);
45667
45668 - m48t59_nvram_attr.size = pdata->offset;
45669 + pax_open_kernel();
45670 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
45671 + pax_close_kernel();
45672
45673 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
45674 if (ret)
45675 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
45676 index 14b5f8d..cc9bd26 100644
45677 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
45678 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
45679 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
45680 for (bit = 0; bit < 8; bit++) {
45681
45682 if ((pci_status[i] & (0x1 << bit)) != 0) {
45683 - static const char *s;
45684 + const char *s;
45685
45686 s = pci_status_strings[bit];
45687 if (i == 7/*TARG*/ && bit == 3)
45688 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
45689
45690 for (bit = 0; bit < 8; bit++) {
45691
45692 - if ((split_status[i] & (0x1 << bit)) != 0) {
45693 - static const char *s;
45694 -
45695 - s = split_status_strings[bit];
45696 - printk(s, ahd_name(ahd),
45697 + if ((split_status[i] & (0x1 << bit)) != 0)
45698 + printk(split_status_strings[bit], ahd_name(ahd),
45699 split_status_source[i]);
45700 - }
45701
45702 if (i > 1)
45703 continue;
45704
45705 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
45706 - static const char *s;
45707 -
45708 - s = split_status_strings[bit];
45709 - printk(s, ahd_name(ahd), "SG");
45710 - }
45711 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
45712 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
45713 }
45714 }
45715 /*
45716 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
45717 index e693af6..2e525b6 100644
45718 --- a/drivers/scsi/bfa/bfa_fcpim.h
45719 +++ b/drivers/scsi/bfa/bfa_fcpim.h
45720 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
45721
45722 struct bfa_itn_s {
45723 bfa_isr_func_t isr;
45724 -};
45725 +} __no_const;
45726
45727 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
45728 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
45729 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
45730 index 90814fe..4384138 100644
45731 --- a/drivers/scsi/bfa/bfa_ioc.h
45732 +++ b/drivers/scsi/bfa/bfa_ioc.h
45733 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
45734 bfa_ioc_disable_cbfn_t disable_cbfn;
45735 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
45736 bfa_ioc_reset_cbfn_t reset_cbfn;
45737 -};
45738 +} __no_const;
45739
45740 /*
45741 * IOC event notification mechanism.
45742 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
45743 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
45744 enum bfi_ioc_state fwstate);
45745 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
45746 -};
45747 +} __no_const;
45748
45749 /*
45750 * Queue element to wait for room in request queue. FIFO order is
45751 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
45752 index c9382d6..6619864 100644
45753 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
45754 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
45755 @@ -33,8 +33,8 @@
45756 */
45757 #include "libfcoe.h"
45758
45759 -static atomic_t ctlr_num;
45760 -static atomic_t fcf_num;
45761 +static atomic_unchecked_t ctlr_num;
45762 +static atomic_unchecked_t fcf_num;
45763
45764 /*
45765 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
45766 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
45767 if (!ctlr)
45768 goto out;
45769
45770 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
45771 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
45772 ctlr->f = f;
45773 ctlr->mode = FIP_CONN_TYPE_FABRIC;
45774 INIT_LIST_HEAD(&ctlr->fcfs);
45775 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
45776 fcf->dev.parent = &ctlr->dev;
45777 fcf->dev.bus = &fcoe_bus_type;
45778 fcf->dev.type = &fcoe_fcf_device_type;
45779 - fcf->id = atomic_inc_return(&fcf_num) - 1;
45780 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
45781 fcf->state = FCOE_FCF_STATE_UNKNOWN;
45782
45783 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
45784 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
45785 {
45786 int error;
45787
45788 - atomic_set(&ctlr_num, 0);
45789 - atomic_set(&fcf_num, 0);
45790 + atomic_set_unchecked(&ctlr_num, 0);
45791 + atomic_set_unchecked(&fcf_num, 0);
45792
45793 error = bus_register(&fcoe_bus_type);
45794 if (error)
45795 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
45796 index df0c3c7..b00e1d0 100644
45797 --- a/drivers/scsi/hosts.c
45798 +++ b/drivers/scsi/hosts.c
45799 @@ -42,7 +42,7 @@
45800 #include "scsi_logging.h"
45801
45802
45803 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
45804 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
45805
45806
45807 static void scsi_host_cls_release(struct device *dev)
45808 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
45809 * subtract one because we increment first then return, but we need to
45810 * know what the next host number was before increment
45811 */
45812 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
45813 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
45814 shost->dma_channel = 0xff;
45815
45816 /* These three are default values which can be overridden */
45817 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
45818 index 891c86b..dd1224a0 100644
45819 --- a/drivers/scsi/hpsa.c
45820 +++ b/drivers/scsi/hpsa.c
45821 @@ -578,7 +578,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
45822 unsigned long flags;
45823
45824 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
45825 - return h->access.command_completed(h, q);
45826 + return h->access->command_completed(h, q);
45827
45828 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
45829 a = rq->head[rq->current_entry];
45830 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
45831 while (!list_empty(&h->reqQ)) {
45832 c = list_entry(h->reqQ.next, struct CommandList, list);
45833 /* can't do anything if fifo is full */
45834 - if ((h->access.fifo_full(h))) {
45835 + if ((h->access->fifo_full(h))) {
45836 dev_warn(&h->pdev->dev, "fifo full\n");
45837 break;
45838 }
45839 @@ -3466,7 +3466,7 @@ static void start_io(struct ctlr_info *h)
45840
45841 /* Tell the controller execute command */
45842 spin_unlock_irqrestore(&h->lock, flags);
45843 - h->access.submit_command(h, c);
45844 + h->access->submit_command(h, c);
45845 spin_lock_irqsave(&h->lock, flags);
45846 }
45847 spin_unlock_irqrestore(&h->lock, flags);
45848 @@ -3474,17 +3474,17 @@ static void start_io(struct ctlr_info *h)
45849
45850 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
45851 {
45852 - return h->access.command_completed(h, q);
45853 + return h->access->command_completed(h, q);
45854 }
45855
45856 static inline bool interrupt_pending(struct ctlr_info *h)
45857 {
45858 - return h->access.intr_pending(h);
45859 + return h->access->intr_pending(h);
45860 }
45861
45862 static inline long interrupt_not_for_us(struct ctlr_info *h)
45863 {
45864 - return (h->access.intr_pending(h) == 0) ||
45865 + return (h->access->intr_pending(h) == 0) ||
45866 (h->interrupts_enabled == 0);
45867 }
45868
45869 @@ -4386,7 +4386,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
45870 if (prod_index < 0)
45871 return -ENODEV;
45872 h->product_name = products[prod_index].product_name;
45873 - h->access = *(products[prod_index].access);
45874 + h->access = products[prod_index].access;
45875
45876 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
45877 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
45878 @@ -4668,7 +4668,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
45879
45880 assert_spin_locked(&lockup_detector_lock);
45881 remove_ctlr_from_lockup_detector_list(h);
45882 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45883 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45884 spin_lock_irqsave(&h->lock, flags);
45885 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
45886 spin_unlock_irqrestore(&h->lock, flags);
45887 @@ -4845,7 +4845,7 @@ reinit_after_soft_reset:
45888 }
45889
45890 /* make sure the board interrupts are off */
45891 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45892 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45893
45894 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
45895 goto clean2;
45896 @@ -4879,7 +4879,7 @@ reinit_after_soft_reset:
45897 * fake ones to scoop up any residual completions.
45898 */
45899 spin_lock_irqsave(&h->lock, flags);
45900 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45901 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45902 spin_unlock_irqrestore(&h->lock, flags);
45903 free_irqs(h);
45904 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
45905 @@ -4898,9 +4898,9 @@ reinit_after_soft_reset:
45906 dev_info(&h->pdev->dev, "Board READY.\n");
45907 dev_info(&h->pdev->dev,
45908 "Waiting for stale completions to drain.\n");
45909 - h->access.set_intr_mask(h, HPSA_INTR_ON);
45910 + h->access->set_intr_mask(h, HPSA_INTR_ON);
45911 msleep(10000);
45912 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45913 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45914
45915 rc = controller_reset_failed(h->cfgtable);
45916 if (rc)
45917 @@ -4921,7 +4921,7 @@ reinit_after_soft_reset:
45918 }
45919
45920 /* Turn the interrupts on so we can service requests */
45921 - h->access.set_intr_mask(h, HPSA_INTR_ON);
45922 + h->access->set_intr_mask(h, HPSA_INTR_ON);
45923
45924 hpsa_hba_inquiry(h);
45925 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
45926 @@ -4976,7 +4976,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
45927 * To write all data in the battery backed cache to disks
45928 */
45929 hpsa_flush_cache(h);
45930 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45931 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45932 hpsa_free_irqs_and_disable_msix(h);
45933 }
45934
45935 @@ -5144,7 +5144,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
45936 return;
45937 }
45938 /* Change the access methods to the performant access methods */
45939 - h->access = SA5_performant_access;
45940 + h->access = &SA5_performant_access;
45941 h->transMethod = CFGTBL_Trans_Performant;
45942 }
45943
45944 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
45945 index bc85e72..ae04a39 100644
45946 --- a/drivers/scsi/hpsa.h
45947 +++ b/drivers/scsi/hpsa.h
45948 @@ -79,7 +79,7 @@ struct ctlr_info {
45949 unsigned int msix_vector;
45950 unsigned int msi_vector;
45951 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
45952 - struct access_method access;
45953 + struct access_method *access;
45954
45955 /* queue and queue Info */
45956 struct list_head reqQ;
45957 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
45958 index 5879929..32b241d 100644
45959 --- a/drivers/scsi/libfc/fc_exch.c
45960 +++ b/drivers/scsi/libfc/fc_exch.c
45961 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
45962 u16 pool_max_index;
45963
45964 struct {
45965 - atomic_t no_free_exch;
45966 - atomic_t no_free_exch_xid;
45967 - atomic_t xid_not_found;
45968 - atomic_t xid_busy;
45969 - atomic_t seq_not_found;
45970 - atomic_t non_bls_resp;
45971 + atomic_unchecked_t no_free_exch;
45972 + atomic_unchecked_t no_free_exch_xid;
45973 + atomic_unchecked_t xid_not_found;
45974 + atomic_unchecked_t xid_busy;
45975 + atomic_unchecked_t seq_not_found;
45976 + atomic_unchecked_t non_bls_resp;
45977 } stats;
45978 };
45979
45980 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
45981 /* allocate memory for exchange */
45982 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
45983 if (!ep) {
45984 - atomic_inc(&mp->stats.no_free_exch);
45985 + atomic_inc_unchecked(&mp->stats.no_free_exch);
45986 goto out;
45987 }
45988 memset(ep, 0, sizeof(*ep));
45989 @@ -797,7 +797,7 @@ out:
45990 return ep;
45991 err:
45992 spin_unlock_bh(&pool->lock);
45993 - atomic_inc(&mp->stats.no_free_exch_xid);
45994 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
45995 mempool_free(ep, mp->ep_pool);
45996 return NULL;
45997 }
45998 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
45999 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46000 ep = fc_exch_find(mp, xid);
46001 if (!ep) {
46002 - atomic_inc(&mp->stats.xid_not_found);
46003 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46004 reject = FC_RJT_OX_ID;
46005 goto out;
46006 }
46007 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46008 ep = fc_exch_find(mp, xid);
46009 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46010 if (ep) {
46011 - atomic_inc(&mp->stats.xid_busy);
46012 + atomic_inc_unchecked(&mp->stats.xid_busy);
46013 reject = FC_RJT_RX_ID;
46014 goto rel;
46015 }
46016 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46017 }
46018 xid = ep->xid; /* get our XID */
46019 } else if (!ep) {
46020 - atomic_inc(&mp->stats.xid_not_found);
46021 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46022 reject = FC_RJT_RX_ID; /* XID not found */
46023 goto out;
46024 }
46025 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46026 } else {
46027 sp = &ep->seq;
46028 if (sp->id != fh->fh_seq_id) {
46029 - atomic_inc(&mp->stats.seq_not_found);
46030 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46031 if (f_ctl & FC_FC_END_SEQ) {
46032 /*
46033 * Update sequence_id based on incoming last
46034 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46035
46036 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46037 if (!ep) {
46038 - atomic_inc(&mp->stats.xid_not_found);
46039 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46040 goto out;
46041 }
46042 if (ep->esb_stat & ESB_ST_COMPLETE) {
46043 - atomic_inc(&mp->stats.xid_not_found);
46044 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46045 goto rel;
46046 }
46047 if (ep->rxid == FC_XID_UNKNOWN)
46048 ep->rxid = ntohs(fh->fh_rx_id);
46049 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46050 - atomic_inc(&mp->stats.xid_not_found);
46051 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46052 goto rel;
46053 }
46054 if (ep->did != ntoh24(fh->fh_s_id) &&
46055 ep->did != FC_FID_FLOGI) {
46056 - atomic_inc(&mp->stats.xid_not_found);
46057 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46058 goto rel;
46059 }
46060 sof = fr_sof(fp);
46061 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46062 sp->ssb_stat |= SSB_ST_RESP;
46063 sp->id = fh->fh_seq_id;
46064 } else if (sp->id != fh->fh_seq_id) {
46065 - atomic_inc(&mp->stats.seq_not_found);
46066 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46067 goto rel;
46068 }
46069
46070 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46071 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46072
46073 if (!sp)
46074 - atomic_inc(&mp->stats.xid_not_found);
46075 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46076 else
46077 - atomic_inc(&mp->stats.non_bls_resp);
46078 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46079
46080 fc_frame_free(fp);
46081 }
46082 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46083
46084 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46085 mp = ema->mp;
46086 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46087 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46088 st->fc_no_free_exch_xid +=
46089 - atomic_read(&mp->stats.no_free_exch_xid);
46090 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46091 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46092 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46093 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46094 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46095 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46096 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46097 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46098 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46099 }
46100 }
46101 EXPORT_SYMBOL(fc_exch_update_stats);
46102 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46103 index 161c98e..6d563b3 100644
46104 --- a/drivers/scsi/libsas/sas_ata.c
46105 +++ b/drivers/scsi/libsas/sas_ata.c
46106 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46107 .postreset = ata_std_postreset,
46108 .error_handler = ata_std_error_handler,
46109 .post_internal_cmd = sas_ata_post_internal,
46110 - .qc_defer = ata_std_qc_defer,
46111 + .qc_defer = ata_std_qc_defer,
46112 .qc_prep = ata_noop_qc_prep,
46113 .qc_issue = sas_ata_qc_issue,
46114 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46115 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46116 index 4e1b75c..0bbdfa9 100644
46117 --- a/drivers/scsi/lpfc/lpfc.h
46118 +++ b/drivers/scsi/lpfc/lpfc.h
46119 @@ -432,7 +432,7 @@ struct lpfc_vport {
46120 struct dentry *debug_nodelist;
46121 struct dentry *vport_debugfs_root;
46122 struct lpfc_debugfs_trc *disc_trc;
46123 - atomic_t disc_trc_cnt;
46124 + atomic_unchecked_t disc_trc_cnt;
46125 #endif
46126 uint8_t stat_data_enabled;
46127 uint8_t stat_data_blocked;
46128 @@ -865,8 +865,8 @@ struct lpfc_hba {
46129 struct timer_list fabric_block_timer;
46130 unsigned long bit_flags;
46131 #define FABRIC_COMANDS_BLOCKED 0
46132 - atomic_t num_rsrc_err;
46133 - atomic_t num_cmd_success;
46134 + atomic_unchecked_t num_rsrc_err;
46135 + atomic_unchecked_t num_cmd_success;
46136 unsigned long last_rsrc_error_time;
46137 unsigned long last_ramp_down_time;
46138 unsigned long last_ramp_up_time;
46139 @@ -902,7 +902,7 @@ struct lpfc_hba {
46140
46141 struct dentry *debug_slow_ring_trc;
46142 struct lpfc_debugfs_trc *slow_ring_trc;
46143 - atomic_t slow_ring_trc_cnt;
46144 + atomic_unchecked_t slow_ring_trc_cnt;
46145 /* iDiag debugfs sub-directory */
46146 struct dentry *idiag_root;
46147 struct dentry *idiag_pci_cfg;
46148 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46149 index 60084e6..0e2e700 100644
46150 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46151 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46152 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46153
46154 #include <linux/debugfs.h>
46155
46156 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46157 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46158 static unsigned long lpfc_debugfs_start_time = 0L;
46159
46160 /* iDiag */
46161 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46162 lpfc_debugfs_enable = 0;
46163
46164 len = 0;
46165 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46166 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46167 (lpfc_debugfs_max_disc_trc - 1);
46168 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46169 dtp = vport->disc_trc + i;
46170 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46171 lpfc_debugfs_enable = 0;
46172
46173 len = 0;
46174 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46175 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46176 (lpfc_debugfs_max_slow_ring_trc - 1);
46177 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46178 dtp = phba->slow_ring_trc + i;
46179 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46180 !vport || !vport->disc_trc)
46181 return;
46182
46183 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46184 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46185 (lpfc_debugfs_max_disc_trc - 1);
46186 dtp = vport->disc_trc + index;
46187 dtp->fmt = fmt;
46188 dtp->data1 = data1;
46189 dtp->data2 = data2;
46190 dtp->data3 = data3;
46191 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46192 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46193 dtp->jif = jiffies;
46194 #endif
46195 return;
46196 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46197 !phba || !phba->slow_ring_trc)
46198 return;
46199
46200 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46201 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46202 (lpfc_debugfs_max_slow_ring_trc - 1);
46203 dtp = phba->slow_ring_trc + index;
46204 dtp->fmt = fmt;
46205 dtp->data1 = data1;
46206 dtp->data2 = data2;
46207 dtp->data3 = data3;
46208 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46209 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46210 dtp->jif = jiffies;
46211 #endif
46212 return;
46213 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46214 "slow_ring buffer\n");
46215 goto debug_failed;
46216 }
46217 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46218 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46219 memset(phba->slow_ring_trc, 0,
46220 (sizeof(struct lpfc_debugfs_trc) *
46221 lpfc_debugfs_max_slow_ring_trc));
46222 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46223 "buffer\n");
46224 goto debug_failed;
46225 }
46226 - atomic_set(&vport->disc_trc_cnt, 0);
46227 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46228
46229 snprintf(name, sizeof(name), "discovery_trace");
46230 vport->debug_disc_trc =
46231 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46232 index 647f5bf..d0068b9 100644
46233 --- a/drivers/scsi/lpfc/lpfc_init.c
46234 +++ b/drivers/scsi/lpfc/lpfc_init.c
46235 @@ -10952,8 +10952,10 @@ lpfc_init(void)
46236 "misc_register returned with status %d", error);
46237
46238 if (lpfc_enable_npiv) {
46239 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46240 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46241 + pax_open_kernel();
46242 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46243 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46244 + pax_close_kernel();
46245 }
46246 lpfc_transport_template =
46247 fc_attach_transport(&lpfc_transport_functions);
46248 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46249 index c913e8c..d34a119 100644
46250 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46251 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46252 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46253 uint32_t evt_posted;
46254
46255 spin_lock_irqsave(&phba->hbalock, flags);
46256 - atomic_inc(&phba->num_rsrc_err);
46257 + atomic_inc_unchecked(&phba->num_rsrc_err);
46258 phba->last_rsrc_error_time = jiffies;
46259
46260 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46261 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46262 unsigned long flags;
46263 struct lpfc_hba *phba = vport->phba;
46264 uint32_t evt_posted;
46265 - atomic_inc(&phba->num_cmd_success);
46266 + atomic_inc_unchecked(&phba->num_cmd_success);
46267
46268 if (vport->cfg_lun_queue_depth <= queue_depth)
46269 return;
46270 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46271 unsigned long num_rsrc_err, num_cmd_success;
46272 int i;
46273
46274 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46275 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46276 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46277 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46278
46279 /*
46280 * The error and success command counters are global per
46281 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46282 }
46283 }
46284 lpfc_destroy_vport_work_array(phba, vports);
46285 - atomic_set(&phba->num_rsrc_err, 0);
46286 - atomic_set(&phba->num_cmd_success, 0);
46287 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46288 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46289 }
46290
46291 /**
46292 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46293 }
46294 }
46295 lpfc_destroy_vport_work_array(phba, vports);
46296 - atomic_set(&phba->num_rsrc_err, 0);
46297 - atomic_set(&phba->num_cmd_success, 0);
46298 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46299 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46300 }
46301
46302 /**
46303 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46304 index 7f0af4f..193ac3e 100644
46305 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46306 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46307 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
46308 {
46309 struct scsi_device *sdev = to_scsi_device(dev);
46310 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46311 - static struct _raid_device *raid_device;
46312 + struct _raid_device *raid_device;
46313 unsigned long flags;
46314 Mpi2RaidVolPage0_t vol_pg0;
46315 Mpi2ConfigReply_t mpi_reply;
46316 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
46317 {
46318 struct scsi_device *sdev = to_scsi_device(dev);
46319 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46320 - static struct _raid_device *raid_device;
46321 + struct _raid_device *raid_device;
46322 unsigned long flags;
46323 Mpi2RaidVolPage0_t vol_pg0;
46324 Mpi2ConfigReply_t mpi_reply;
46325 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46326 struct fw_event_work *fw_event)
46327 {
46328 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46329 - static struct _raid_device *raid_device;
46330 + struct _raid_device *raid_device;
46331 unsigned long flags;
46332 u16 handle;
46333
46334 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46335 u64 sas_address;
46336 struct _sas_device *sas_device;
46337 struct _sas_node *expander_device;
46338 - static struct _raid_device *raid_device;
46339 + struct _raid_device *raid_device;
46340 u8 retry_count;
46341 unsigned long flags;
46342
46343 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46344 index 1eb7b028..b2a6080 100644
46345 --- a/drivers/scsi/pmcraid.c
46346 +++ b/drivers/scsi/pmcraid.c
46347 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46348 res->scsi_dev = scsi_dev;
46349 scsi_dev->hostdata = res;
46350 res->change_detected = 0;
46351 - atomic_set(&res->read_failures, 0);
46352 - atomic_set(&res->write_failures, 0);
46353 + atomic_set_unchecked(&res->read_failures, 0);
46354 + atomic_set_unchecked(&res->write_failures, 0);
46355 rc = 0;
46356 }
46357 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46358 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46359
46360 /* If this was a SCSI read/write command keep count of errors */
46361 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46362 - atomic_inc(&res->read_failures);
46363 + atomic_inc_unchecked(&res->read_failures);
46364 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46365 - atomic_inc(&res->write_failures);
46366 + atomic_inc_unchecked(&res->write_failures);
46367
46368 if (!RES_IS_GSCSI(res->cfg_entry) &&
46369 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46370 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46371 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46372 * hrrq_id assigned here in queuecommand
46373 */
46374 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46375 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46376 pinstance->num_hrrq;
46377 cmd->cmd_done = pmcraid_io_done;
46378
46379 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46380 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46381 * hrrq_id assigned here in queuecommand
46382 */
46383 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46384 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46385 pinstance->num_hrrq;
46386
46387 if (request_size) {
46388 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46389
46390 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46391 /* add resources only after host is added into system */
46392 - if (!atomic_read(&pinstance->expose_resources))
46393 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46394 return;
46395
46396 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46397 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46398 init_waitqueue_head(&pinstance->reset_wait_q);
46399
46400 atomic_set(&pinstance->outstanding_cmds, 0);
46401 - atomic_set(&pinstance->last_message_id, 0);
46402 - atomic_set(&pinstance->expose_resources, 0);
46403 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46404 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46405
46406 INIT_LIST_HEAD(&pinstance->free_res_q);
46407 INIT_LIST_HEAD(&pinstance->used_res_q);
46408 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46409 /* Schedule worker thread to handle CCN and take care of adding and
46410 * removing devices to OS
46411 */
46412 - atomic_set(&pinstance->expose_resources, 1);
46413 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46414 schedule_work(&pinstance->worker_q);
46415 return rc;
46416
46417 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46418 index e1d150f..6c6df44 100644
46419 --- a/drivers/scsi/pmcraid.h
46420 +++ b/drivers/scsi/pmcraid.h
46421 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46422 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46423
46424 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46425 - atomic_t last_message_id;
46426 + atomic_unchecked_t last_message_id;
46427
46428 /* configuration table */
46429 struct pmcraid_config_table *cfg_table;
46430 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46431 atomic_t outstanding_cmds;
46432
46433 /* should add/delete resources to mid-layer now ?*/
46434 - atomic_t expose_resources;
46435 + atomic_unchecked_t expose_resources;
46436
46437
46438
46439 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46440 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46441 };
46442 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46443 - atomic_t read_failures; /* count of failed READ commands */
46444 - atomic_t write_failures; /* count of failed WRITE commands */
46445 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46446 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46447
46448 /* To indicate add/delete/modify during CCN */
46449 u8 change_detected;
46450 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46451 index 5f174b8..98d32b0 100644
46452 --- a/drivers/scsi/qla2xxx/qla_attr.c
46453 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46454 @@ -2040,7 +2040,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46455 return 0;
46456 }
46457
46458 -struct fc_function_template qla2xxx_transport_functions = {
46459 +fc_function_template_no_const qla2xxx_transport_functions = {
46460
46461 .show_host_node_name = 1,
46462 .show_host_port_name = 1,
46463 @@ -2088,7 +2088,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46464 .bsg_timeout = qla24xx_bsg_timeout,
46465 };
46466
46467 -struct fc_function_template qla2xxx_transport_vport_functions = {
46468 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46469
46470 .show_host_node_name = 1,
46471 .show_host_port_name = 1,
46472 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46473 index 4446bf5..9a3574d 100644
46474 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46475 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46476 @@ -538,8 +538,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46477 struct device_attribute;
46478 extern struct device_attribute *qla2x00_host_attrs[];
46479 struct fc_function_template;
46480 -extern struct fc_function_template qla2xxx_transport_functions;
46481 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46482 +extern fc_function_template_no_const qla2xxx_transport_functions;
46483 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46484 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46485 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46486 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46487 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46488 index 9f01bbb..5e1dcee 100644
46489 --- a/drivers/scsi/qla2xxx/qla_os.c
46490 +++ b/drivers/scsi/qla2xxx/qla_os.c
46491 @@ -1572,8 +1572,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46492 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46493 /* Ok, a 64bit DMA mask is applicable. */
46494 ha->flags.enable_64bit_addressing = 1;
46495 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46496 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46497 + pax_open_kernel();
46498 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46499 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46500 + pax_close_kernel();
46501 return;
46502 }
46503 }
46504 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46505 index 41327d4..feb03d479 100644
46506 --- a/drivers/scsi/qla4xxx/ql4_def.h
46507 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46508 @@ -296,7 +296,7 @@ struct ddb_entry {
46509 * (4000 only) */
46510 atomic_t relogin_timer; /* Max Time to wait for
46511 * relogin to complete */
46512 - atomic_t relogin_retry_count; /* Num of times relogin has been
46513 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46514 * retried */
46515 uint32_t default_time2wait; /* Default Min time between
46516 * relogins (+aens) */
46517 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46518 index f8a0a26..ec03cee 100644
46519 --- a/drivers/scsi/qla4xxx/ql4_os.c
46520 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46521 @@ -3066,12 +3066,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46522 */
46523 if (!iscsi_is_session_online(cls_sess)) {
46524 /* Reset retry relogin timer */
46525 - atomic_inc(&ddb_entry->relogin_retry_count);
46526 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46527 DEBUG2(ql4_printk(KERN_INFO, ha,
46528 "%s: index[%d] relogin timed out-retrying"
46529 " relogin (%d), retry (%d)\n", __func__,
46530 ddb_entry->fw_ddb_index,
46531 - atomic_read(&ddb_entry->relogin_retry_count),
46532 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46533 ddb_entry->default_time2wait + 4));
46534 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46535 atomic_set(&ddb_entry->retry_relogin_timer,
46536 @@ -5209,7 +5209,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46537
46538 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46539 atomic_set(&ddb_entry->relogin_timer, 0);
46540 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46541 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46542 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46543 ddb_entry->default_relogin_timeout =
46544 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46545 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46546 index eaa808e..95f8841 100644
46547 --- a/drivers/scsi/scsi.c
46548 +++ b/drivers/scsi/scsi.c
46549 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46550 unsigned long timeout;
46551 int rtn = 0;
46552
46553 - atomic_inc(&cmd->device->iorequest_cnt);
46554 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46555
46556 /* check if the device is still usable */
46557 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46558 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46559 index d1549b7..2f60767 100644
46560 --- a/drivers/scsi/scsi_lib.c
46561 +++ b/drivers/scsi/scsi_lib.c
46562 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46563 shost = sdev->host;
46564 scsi_init_cmd_errh(cmd);
46565 cmd->result = DID_NO_CONNECT << 16;
46566 - atomic_inc(&cmd->device->iorequest_cnt);
46567 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46568
46569 /*
46570 * SCSI request completion path will do scsi_device_unbusy(),
46571 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46572
46573 INIT_LIST_HEAD(&cmd->eh_entry);
46574
46575 - atomic_inc(&cmd->device->iodone_cnt);
46576 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46577 if (cmd->result)
46578 - atomic_inc(&cmd->device->ioerr_cnt);
46579 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46580
46581 disposition = scsi_decide_disposition(cmd);
46582 if (disposition != SUCCESS &&
46583 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46584 index 40c6394..62356c2 100644
46585 --- a/drivers/scsi/scsi_sysfs.c
46586 +++ b/drivers/scsi/scsi_sysfs.c
46587 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46588 char *buf) \
46589 { \
46590 struct scsi_device *sdev = to_scsi_device(dev); \
46591 - unsigned long long count = atomic_read(&sdev->field); \
46592 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46593 return snprintf(buf, 20, "0x%llx\n", count); \
46594 } \
46595 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46596 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46597 index 84a1fdf..693b0d6 100644
46598 --- a/drivers/scsi/scsi_tgt_lib.c
46599 +++ b/drivers/scsi/scsi_tgt_lib.c
46600 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46601 int err;
46602
46603 dprintk("%lx %u\n", uaddr, len);
46604 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46605 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46606 if (err) {
46607 /*
46608 * TODO: need to fixup sg_tablesize, max_segment_size,
46609 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46610 index 4628fd5..a94a1c2 100644
46611 --- a/drivers/scsi/scsi_transport_fc.c
46612 +++ b/drivers/scsi/scsi_transport_fc.c
46613 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
46614 * Netlink Infrastructure
46615 */
46616
46617 -static atomic_t fc_event_seq;
46618 +static atomic_unchecked_t fc_event_seq;
46619
46620 /**
46621 * fc_get_event_number - Obtain the next sequential FC event number
46622 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
46623 u32
46624 fc_get_event_number(void)
46625 {
46626 - return atomic_add_return(1, &fc_event_seq);
46627 + return atomic_add_return_unchecked(1, &fc_event_seq);
46628 }
46629 EXPORT_SYMBOL(fc_get_event_number);
46630
46631 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
46632 {
46633 int error;
46634
46635 - atomic_set(&fc_event_seq, 0);
46636 + atomic_set_unchecked(&fc_event_seq, 0);
46637
46638 error = transport_class_register(&fc_host_class);
46639 if (error)
46640 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
46641 char *cp;
46642
46643 *val = simple_strtoul(buf, &cp, 0);
46644 - if ((*cp && (*cp != '\n')) || (*val < 0))
46645 + if (*cp && (*cp != '\n'))
46646 return -EINVAL;
46647 /*
46648 * Check for overflow; dev_loss_tmo is u32
46649 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
46650 index e4a989f..293090c 100644
46651 --- a/drivers/scsi/scsi_transport_iscsi.c
46652 +++ b/drivers/scsi/scsi_transport_iscsi.c
46653 @@ -79,7 +79,7 @@ struct iscsi_internal {
46654 struct transport_container session_cont;
46655 };
46656
46657 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
46658 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
46659 static struct workqueue_struct *iscsi_eh_timer_workq;
46660
46661 static DEFINE_IDA(iscsi_sess_ida);
46662 @@ -1737,7 +1737,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
46663 int err;
46664
46665 ihost = shost->shost_data;
46666 - session->sid = atomic_add_return(1, &iscsi_session_nr);
46667 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
46668
46669 if (target_id == ISCSI_MAX_TARGET) {
46670 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
46671 @@ -4077,7 +4077,7 @@ static __init int iscsi_transport_init(void)
46672 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
46673 ISCSI_TRANSPORT_VERSION);
46674
46675 - atomic_set(&iscsi_session_nr, 0);
46676 + atomic_set_unchecked(&iscsi_session_nr, 0);
46677
46678 err = class_register(&iscsi_transport_class);
46679 if (err)
46680 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
46681 index f379c7f..e8fc69c 100644
46682 --- a/drivers/scsi/scsi_transport_srp.c
46683 +++ b/drivers/scsi/scsi_transport_srp.c
46684 @@ -33,7 +33,7 @@
46685 #include "scsi_transport_srp_internal.h"
46686
46687 struct srp_host_attrs {
46688 - atomic_t next_port_id;
46689 + atomic_unchecked_t next_port_id;
46690 };
46691 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
46692
46693 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
46694 struct Scsi_Host *shost = dev_to_shost(dev);
46695 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
46696
46697 - atomic_set(&srp_host->next_port_id, 0);
46698 + atomic_set_unchecked(&srp_host->next_port_id, 0);
46699 return 0;
46700 }
46701
46702 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
46703 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
46704 rport->roles = ids->roles;
46705
46706 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
46707 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
46708 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
46709
46710 transport_setup_device(&rport->dev);
46711 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
46712 index 5693f6d7..b0bf05a 100644
46713 --- a/drivers/scsi/sd.c
46714 +++ b/drivers/scsi/sd.c
46715 @@ -2934,7 +2934,7 @@ static int sd_probe(struct device *dev)
46716 sdkp->disk = gd;
46717 sdkp->index = index;
46718 atomic_set(&sdkp->openers, 0);
46719 - atomic_set(&sdkp->device->ioerr_cnt, 0);
46720 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
46721
46722 if (!sdp->request_queue->rq_timeout) {
46723 if (sdp->type != TYPE_MOD)
46724 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
46725 index df5e961..df6b97f 100644
46726 --- a/drivers/scsi/sg.c
46727 +++ b/drivers/scsi/sg.c
46728 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
46729 sdp->disk->disk_name,
46730 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
46731 NULL,
46732 - (char *)arg);
46733 + (char __user *)arg);
46734 case BLKTRACESTART:
46735 return blk_trace_startstop(sdp->device->request_queue, 1);
46736 case BLKTRACESTOP:
46737 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
46738 index 9e039c6..ae9e800 100644
46739 --- a/drivers/spi/spi.c
46740 +++ b/drivers/spi/spi.c
46741 @@ -1762,7 +1762,7 @@ int spi_bus_unlock(struct spi_master *master)
46742 EXPORT_SYMBOL_GPL(spi_bus_unlock);
46743
46744 /* portable code must never pass more than 32 bytes */
46745 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
46746 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
46747
46748 static u8 *buf;
46749
46750 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
46751 index 2c61783..4d49e4e 100644
46752 --- a/drivers/staging/android/timed_output.c
46753 +++ b/drivers/staging/android/timed_output.c
46754 @@ -25,7 +25,7 @@
46755 #include "timed_output.h"
46756
46757 static struct class *timed_output_class;
46758 -static atomic_t device_count;
46759 +static atomic_unchecked_t device_count;
46760
46761 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
46762 char *buf)
46763 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
46764 timed_output_class = class_create(THIS_MODULE, "timed_output");
46765 if (IS_ERR(timed_output_class))
46766 return PTR_ERR(timed_output_class);
46767 - atomic_set(&device_count, 0);
46768 + atomic_set_unchecked(&device_count, 0);
46769 timed_output_class->dev_groups = timed_output_groups;
46770 }
46771
46772 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
46773 if (ret < 0)
46774 return ret;
46775
46776 - tdev->index = atomic_inc_return(&device_count);
46777 + tdev->index = atomic_inc_return_unchecked(&device_count);
46778 tdev->dev = device_create(timed_output_class, NULL,
46779 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
46780 if (IS_ERR(tdev->dev))
46781 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
46782 index 0247a20..cb9595c 100644
46783 --- a/drivers/staging/gdm724x/gdm_tty.c
46784 +++ b/drivers/staging/gdm724x/gdm_tty.c
46785 @@ -45,7 +45,7 @@
46786 #define gdm_tty_send_control(n, r, v, d, l) (\
46787 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
46788
46789 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
46790 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
46791
46792 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
46793 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
46794 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
46795 index ef5064e..fce01db 100644
46796 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
46797 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
46798 @@ -478,13 +478,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
46799 return 0;
46800 }
46801
46802 -sfw_test_client_ops_t brw_test_client;
46803 -void brw_init_test_client(void)
46804 -{
46805 - brw_test_client.tso_init = brw_client_init;
46806 - brw_test_client.tso_fini = brw_client_fini;
46807 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
46808 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
46809 +sfw_test_client_ops_t brw_test_client = {
46810 + .tso_init = brw_client_init,
46811 + .tso_fini = brw_client_fini,
46812 + .tso_prep_rpc = brw_client_prep_rpc,
46813 + .tso_done_rpc = brw_client_done_rpc,
46814 };
46815
46816 srpc_service_t brw_test_service;
46817 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
46818 index 483c785..e1a2a7b 100644
46819 --- a/drivers/staging/lustre/lnet/selftest/framework.c
46820 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
46821 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
46822
46823 extern sfw_test_client_ops_t ping_test_client;
46824 extern srpc_service_t ping_test_service;
46825 -extern void ping_init_test_client(void);
46826 extern void ping_init_test_service(void);
46827
46828 extern sfw_test_client_ops_t brw_test_client;
46829 extern srpc_service_t brw_test_service;
46830 -extern void brw_init_test_client(void);
46831 extern void brw_init_test_service(void);
46832
46833
46834 @@ -1684,12 +1682,10 @@ sfw_startup (void)
46835 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
46836 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
46837
46838 - brw_init_test_client();
46839 brw_init_test_service();
46840 rc = sfw_register_test(&brw_test_service, &brw_test_client);
46841 LASSERT (rc == 0);
46842
46843 - ping_init_test_client();
46844 ping_init_test_service();
46845 rc = sfw_register_test(&ping_test_service, &ping_test_client);
46846 LASSERT (rc == 0);
46847 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
46848 index f0f9194..b589047 100644
46849 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
46850 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
46851 @@ -210,14 +210,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
46852 return 0;
46853 }
46854
46855 -sfw_test_client_ops_t ping_test_client;
46856 -void ping_init_test_client(void)
46857 -{
46858 - ping_test_client.tso_init = ping_client_init;
46859 - ping_test_client.tso_fini = ping_client_fini;
46860 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
46861 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
46862 -}
46863 +sfw_test_client_ops_t ping_test_client = {
46864 + .tso_init = ping_client_init,
46865 + .tso_fini = ping_client_fini,
46866 + .tso_prep_rpc = ping_client_prep_rpc,
46867 + .tso_done_rpc = ping_client_done_rpc,
46868 +};
46869
46870 srpc_service_t ping_test_service;
46871 void ping_init_test_service(void)
46872 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
46873 index 7020d9c..0d3b580 100644
46874 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
46875 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
46876 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
46877 ldlm_completion_callback lcs_completion;
46878 ldlm_blocking_callback lcs_blocking;
46879 ldlm_glimpse_callback lcs_glimpse;
46880 -};
46881 +} __no_const;
46882
46883 /* ldlm_lockd.c */
46884 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
46885 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
46886 index a612255..9a9e2dd 100644
46887 --- a/drivers/staging/lustre/lustre/include/obd.h
46888 +++ b/drivers/staging/lustre/lustre/include/obd.h
46889 @@ -1417,7 +1417,7 @@ struct md_ops {
46890 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
46891 * wrapper function in include/linux/obd_class.h.
46892 */
46893 -};
46894 +} __no_const;
46895
46896 struct lsm_operations {
46897 void (*lsm_free)(struct lov_stripe_md *);
46898 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46899 index fc6c977..df1f956 100644
46900 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46901 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46902 @@ -219,7 +219,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
46903 int LL_PROC_PROTO(proc_console_max_delay_cs)
46904 {
46905 int rc, max_delay_cs;
46906 - ctl_table_t dummy = *table;
46907 + ctl_table_no_const dummy = *table;
46908 cfs_duration_t d;
46909
46910 dummy.data = &max_delay_cs;
46911 @@ -250,7 +250,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
46912 int LL_PROC_PROTO(proc_console_min_delay_cs)
46913 {
46914 int rc, min_delay_cs;
46915 - ctl_table_t dummy = *table;
46916 + ctl_table_no_const dummy = *table;
46917 cfs_duration_t d;
46918
46919 dummy.data = &min_delay_cs;
46920 @@ -281,7 +281,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
46921 int LL_PROC_PROTO(proc_console_backoff)
46922 {
46923 int rc, backoff;
46924 - ctl_table_t dummy = *table;
46925 + ctl_table_no_const dummy = *table;
46926
46927 dummy.data = &backoff;
46928 dummy.proc_handler = &proc_dointvec;
46929 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
46930 index 3675020..e80d92c 100644
46931 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
46932 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
46933 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
46934
46935 static int solo_sysfs_init(struct solo_dev *solo_dev)
46936 {
46937 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
46938 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
46939 struct device *dev = &solo_dev->dev;
46940 const char *driver;
46941 int i;
46942 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
46943 index 3335941..2b26186 100644
46944 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
46945 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
46946 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
46947
46948 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
46949 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
46950 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
46951 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
46952 if (p2m_id < 0)
46953 p2m_id = -p2m_id;
46954 }
46955 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
46956 index 6f91d2e..3f011d2 100644
46957 --- a/drivers/staging/media/solo6x10/solo6x10.h
46958 +++ b/drivers/staging/media/solo6x10/solo6x10.h
46959 @@ -238,7 +238,7 @@ struct solo_dev {
46960
46961 /* P2M DMA Engine */
46962 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
46963 - atomic_t p2m_count;
46964 + atomic_unchecked_t p2m_count;
46965 int p2m_jiffies;
46966 unsigned int p2m_timeouts;
46967
46968 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
46969 index e14a1bb..9cb9bbe 100644
46970 --- a/drivers/staging/octeon/ethernet-rx.c
46971 +++ b/drivers/staging/octeon/ethernet-rx.c
46972 @@ -419,11 +419,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
46973 /* Increment RX stats for virtual ports */
46974 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
46975 #ifdef CONFIG_64BIT
46976 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
46977 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
46978 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
46979 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
46980 #else
46981 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
46982 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
46983 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
46984 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
46985 #endif
46986 }
46987 netif_receive_skb(skb);
46988 @@ -434,9 +434,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
46989 dev->name);
46990 */
46991 #ifdef CONFIG_64BIT
46992 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
46993 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
46994 #else
46995 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
46996 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
46997 #endif
46998 dev_kfree_skb_irq(skb);
46999 }
47000 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47001 index c3a90e7..023619a 100644
47002 --- a/drivers/staging/octeon/ethernet.c
47003 +++ b/drivers/staging/octeon/ethernet.c
47004 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47005 * since the RX tasklet also increments it.
47006 */
47007 #ifdef CONFIG_64BIT
47008 - atomic64_add(rx_status.dropped_packets,
47009 - (atomic64_t *)&priv->stats.rx_dropped);
47010 + atomic64_add_unchecked(rx_status.dropped_packets,
47011 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47012 #else
47013 - atomic_add(rx_status.dropped_packets,
47014 - (atomic_t *)&priv->stats.rx_dropped);
47015 + atomic_add_unchecked(rx_status.dropped_packets,
47016 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47017 #endif
47018 }
47019
47020 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
47021 index 439c3c9..2d74293 100644
47022 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
47023 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
47024 @@ -271,7 +271,7 @@ struct hal_ops {
47025 s32 (*c2h_handler)(struct adapter *padapter,
47026 struct c2h_evt_hdr *c2h_evt);
47027 c2h_id_filter c2h_id_filter_ccx;
47028 -};
47029 +} __no_const;
47030
47031 enum rt_eeprom_type {
47032 EEPROM_93C46,
47033 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
47034 index eb6f0e5..e6a0958 100644
47035 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
47036 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
47037 @@ -126,7 +126,7 @@ struct _io_ops {
47038 u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
47039 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
47040 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
47041 -};
47042 +} __no_const;
47043
47044 struct io_req {
47045 struct list_head list;
47046 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47047 index dc23395..cf7e9b1 100644
47048 --- a/drivers/staging/rtl8712/rtl871x_io.h
47049 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47050 @@ -108,7 +108,7 @@ struct _io_ops {
47051 u8 *pmem);
47052 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47053 u8 *pmem);
47054 -};
47055 +} __no_const;
47056
47057 struct io_req {
47058 struct list_head list;
47059 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47060 index 1f5088b..0e59820 100644
47061 --- a/drivers/staging/sbe-2t3e3/netdev.c
47062 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47063 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47064 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47065
47066 if (rlen)
47067 - if (copy_to_user(data, &resp, rlen))
47068 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47069 return -EFAULT;
47070
47071 return 0;
47072 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47073 index a863a98..d272795 100644
47074 --- a/drivers/staging/usbip/vhci.h
47075 +++ b/drivers/staging/usbip/vhci.h
47076 @@ -83,7 +83,7 @@ struct vhci_hcd {
47077 unsigned resuming:1;
47078 unsigned long re_timeout;
47079
47080 - atomic_t seqnum;
47081 + atomic_unchecked_t seqnum;
47082
47083 /*
47084 * NOTE:
47085 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47086 index d7974cb..d78076b 100644
47087 --- a/drivers/staging/usbip/vhci_hcd.c
47088 +++ b/drivers/staging/usbip/vhci_hcd.c
47089 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47090
47091 spin_lock(&vdev->priv_lock);
47092
47093 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47094 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47095 if (priv->seqnum == 0xffff)
47096 dev_info(&urb->dev->dev, "seqnum max\n");
47097
47098 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47099 return -ENOMEM;
47100 }
47101
47102 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47103 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47104 if (unlink->seqnum == 0xffff)
47105 pr_info("seqnum max\n");
47106
47107 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47108 vdev->rhport = rhport;
47109 }
47110
47111 - atomic_set(&vhci->seqnum, 0);
47112 + atomic_set_unchecked(&vhci->seqnum, 0);
47113 spin_lock_init(&vhci->lock);
47114
47115 hcd->power_budget = 0; /* no limit */
47116 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47117 index d07fcb5..358e1e1 100644
47118 --- a/drivers/staging/usbip/vhci_rx.c
47119 +++ b/drivers/staging/usbip/vhci_rx.c
47120 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47121 if (!urb) {
47122 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47123 pr_info("max seqnum %d\n",
47124 - atomic_read(&the_controller->seqnum));
47125 + atomic_read_unchecked(&the_controller->seqnum));
47126 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47127 return;
47128 }
47129 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47130 index 8acff44..bdb2fca 100644
47131 --- a/drivers/staging/vt6655/hostap.c
47132 +++ b/drivers/staging/vt6655/hostap.c
47133 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47134 *
47135 */
47136
47137 +static net_device_ops_no_const apdev_netdev_ops;
47138 +
47139 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47140 {
47141 PSDevice apdev_priv;
47142 struct net_device *dev = pDevice->dev;
47143 int ret;
47144 - const struct net_device_ops apdev_netdev_ops = {
47145 - .ndo_start_xmit = pDevice->tx_80211,
47146 - };
47147
47148 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47149
47150 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47151 *apdev_priv = *pDevice;
47152 eth_hw_addr_inherit(pDevice->apdev, dev);
47153
47154 + /* only half broken now */
47155 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47156 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47157
47158 pDevice->apdev->type = ARPHRD_IEEE80211;
47159 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47160 index c699a30..b90a5fd 100644
47161 --- a/drivers/staging/vt6656/hostap.c
47162 +++ b/drivers/staging/vt6656/hostap.c
47163 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47164 *
47165 */
47166
47167 +static net_device_ops_no_const apdev_netdev_ops;
47168 +
47169 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47170 {
47171 struct vnt_private *apdev_priv;
47172 struct net_device *dev = pDevice->dev;
47173 int ret;
47174 - const struct net_device_ops apdev_netdev_ops = {
47175 - .ndo_start_xmit = pDevice->tx_80211,
47176 - };
47177
47178 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47179
47180 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47181 *apdev_priv = *pDevice;
47182 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47183
47184 + /* only half broken now */
47185 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47186 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47187
47188 pDevice->apdev->type = ARPHRD_IEEE80211;
47189 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47190 index e51b09a..5ebac31 100644
47191 --- a/drivers/target/sbp/sbp_target.c
47192 +++ b/drivers/target/sbp/sbp_target.c
47193 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47194
47195 #define SESSION_MAINTENANCE_INTERVAL HZ
47196
47197 -static atomic_t login_id = ATOMIC_INIT(0);
47198 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47199
47200 static void session_maintenance_work(struct work_struct *);
47201 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47202 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47203 login->lun = se_lun;
47204 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47205 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47206 - login->login_id = atomic_inc_return(&login_id);
47207 + login->login_id = atomic_inc_return_unchecked(&login_id);
47208
47209 login->tgt_agt = sbp_target_agent_register(login);
47210 if (IS_ERR(login->tgt_agt)) {
47211 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47212 index d90dbb0..6cbe585 100644
47213 --- a/drivers/target/target_core_device.c
47214 +++ b/drivers/target/target_core_device.c
47215 @@ -1431,7 +1431,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47216 spin_lock_init(&dev->se_tmr_lock);
47217 spin_lock_init(&dev->qf_cmd_lock);
47218 sema_init(&dev->caw_sem, 1);
47219 - atomic_set(&dev->dev_ordered_id, 0);
47220 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47221 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47222 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47223 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47224 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47225 index 81e945e..e40c92f 100644
47226 --- a/drivers/target/target_core_transport.c
47227 +++ b/drivers/target/target_core_transport.c
47228 @@ -1137,7 +1137,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47229 * Used to determine when ORDERED commands should go from
47230 * Dormant to Active status.
47231 */
47232 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47233 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47234 smp_mb__after_atomic_inc();
47235 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47236 cmd->se_ordered_id, cmd->sam_task_attr,
47237 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47238 index 33f83fe..d80f8e1 100644
47239 --- a/drivers/tty/cyclades.c
47240 +++ b/drivers/tty/cyclades.c
47241 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47242 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47243 info->port.count);
47244 #endif
47245 - info->port.count++;
47246 + atomic_inc(&info->port.count);
47247 #ifdef CY_DEBUG_COUNT
47248 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47249 - current->pid, info->port.count);
47250 + current->pid, atomic_read(&info->port.count));
47251 #endif
47252
47253 /*
47254 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47255 for (j = 0; j < cy_card[i].nports; j++) {
47256 info = &cy_card[i].ports[j];
47257
47258 - if (info->port.count) {
47259 + if (atomic_read(&info->port.count)) {
47260 /* XXX is the ldisc num worth this? */
47261 struct tty_struct *tty;
47262 struct tty_ldisc *ld;
47263 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47264 index 9eba119..5070303 100644
47265 --- a/drivers/tty/hvc/hvc_console.c
47266 +++ b/drivers/tty/hvc/hvc_console.c
47267 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47268
47269 spin_lock_irqsave(&hp->port.lock, flags);
47270 /* Check and then increment for fast path open. */
47271 - if (hp->port.count++ > 0) {
47272 + if (atomic_inc_return(&hp->port.count) > 1) {
47273 spin_unlock_irqrestore(&hp->port.lock, flags);
47274 hvc_kick();
47275 return 0;
47276 @@ -393,7 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47277
47278 spin_lock_irqsave(&hp->port.lock, flags);
47279
47280 - if (--hp->port.count == 0) {
47281 + if (atomic_dec_return(&hp->port.count) == 0) {
47282 spin_unlock_irqrestore(&hp->port.lock, flags);
47283 /* We are done with the tty pointer now. */
47284 tty_port_tty_set(&hp->port, NULL);
47285 @@ -415,9 +415,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47286 */
47287 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47288 } else {
47289 - if (hp->port.count < 0)
47290 + if (atomic_read(&hp->port.count) < 0)
47291 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47292 - hp->vtermno, hp->port.count);
47293 + hp->vtermno, atomic_read(&hp->port.count));
47294 spin_unlock_irqrestore(&hp->port.lock, flags);
47295 }
47296 }
47297 @@ -447,12 +447,12 @@ static void hvc_hangup(struct tty_struct *tty)
47298 * open->hangup case this can be called after the final close so prevent
47299 * that from happening for now.
47300 */
47301 - if (hp->port.count <= 0) {
47302 + if (atomic_read(&hp->port.count) <= 0) {
47303 spin_unlock_irqrestore(&hp->port.lock, flags);
47304 return;
47305 }
47306
47307 - hp->port.count = 0;
47308 + atomic_set(&hp->port.count, 0);
47309 spin_unlock_irqrestore(&hp->port.lock, flags);
47310 tty_port_tty_set(&hp->port, NULL);
47311
47312 @@ -500,7 +500,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47313 return -EPIPE;
47314
47315 /* FIXME what's this (unprotected) check for? */
47316 - if (hp->port.count <= 0)
47317 + if (atomic_read(&hp->port.count) <= 0)
47318 return -EIO;
47319
47320 spin_lock_irqsave(&hp->lock, flags);
47321 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47322 index 81e939e..95ead10 100644
47323 --- a/drivers/tty/hvc/hvcs.c
47324 +++ b/drivers/tty/hvc/hvcs.c
47325 @@ -83,6 +83,7 @@
47326 #include <asm/hvcserver.h>
47327 #include <asm/uaccess.h>
47328 #include <asm/vio.h>
47329 +#include <asm/local.h>
47330
47331 /*
47332 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47333 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47334
47335 spin_lock_irqsave(&hvcsd->lock, flags);
47336
47337 - if (hvcsd->port.count > 0) {
47338 + if (atomic_read(&hvcsd->port.count) > 0) {
47339 spin_unlock_irqrestore(&hvcsd->lock, flags);
47340 printk(KERN_INFO "HVCS: vterm state unchanged. "
47341 "The hvcs device node is still in use.\n");
47342 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47343 }
47344 }
47345
47346 - hvcsd->port.count = 0;
47347 + atomic_set(&hvcsd->port.count, 0);
47348 hvcsd->port.tty = tty;
47349 tty->driver_data = hvcsd;
47350
47351 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47352 unsigned long flags;
47353
47354 spin_lock_irqsave(&hvcsd->lock, flags);
47355 - hvcsd->port.count++;
47356 + atomic_inc(&hvcsd->port.count);
47357 hvcsd->todo_mask |= HVCS_SCHED_READ;
47358 spin_unlock_irqrestore(&hvcsd->lock, flags);
47359
47360 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47361 hvcsd = tty->driver_data;
47362
47363 spin_lock_irqsave(&hvcsd->lock, flags);
47364 - if (--hvcsd->port.count == 0) {
47365 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47366
47367 vio_disable_interrupts(hvcsd->vdev);
47368
47369 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47370
47371 free_irq(irq, hvcsd);
47372 return;
47373 - } else if (hvcsd->port.count < 0) {
47374 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47375 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47376 " is missmanaged.\n",
47377 - hvcsd->vdev->unit_address, hvcsd->port.count);
47378 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47379 }
47380
47381 spin_unlock_irqrestore(&hvcsd->lock, flags);
47382 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47383
47384 spin_lock_irqsave(&hvcsd->lock, flags);
47385 /* Preserve this so that we know how many kref refs to put */
47386 - temp_open_count = hvcsd->port.count;
47387 + temp_open_count = atomic_read(&hvcsd->port.count);
47388
47389 /*
47390 * Don't kref put inside the spinlock because the destruction
47391 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47392 tty->driver_data = NULL;
47393 hvcsd->port.tty = NULL;
47394
47395 - hvcsd->port.count = 0;
47396 + atomic_set(&hvcsd->port.count, 0);
47397
47398 /* This will drop any buffered data on the floor which is OK in a hangup
47399 * scenario. */
47400 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47401 * the middle of a write operation? This is a crummy place to do this
47402 * but we want to keep it all in the spinlock.
47403 */
47404 - if (hvcsd->port.count <= 0) {
47405 + if (atomic_read(&hvcsd->port.count) <= 0) {
47406 spin_unlock_irqrestore(&hvcsd->lock, flags);
47407 return -ENODEV;
47408 }
47409 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47410 {
47411 struct hvcs_struct *hvcsd = tty->driver_data;
47412
47413 - if (!hvcsd || hvcsd->port.count <= 0)
47414 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47415 return 0;
47416
47417 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47418 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47419 index 4190199..48f2920 100644
47420 --- a/drivers/tty/hvc/hvsi.c
47421 +++ b/drivers/tty/hvc/hvsi.c
47422 @@ -85,7 +85,7 @@ struct hvsi_struct {
47423 int n_outbuf;
47424 uint32_t vtermno;
47425 uint32_t virq;
47426 - atomic_t seqno; /* HVSI packet sequence number */
47427 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47428 uint16_t mctrl;
47429 uint8_t state; /* HVSI protocol state */
47430 uint8_t flags;
47431 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47432
47433 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47434 packet.hdr.len = sizeof(struct hvsi_query_response);
47435 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47436 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47437 packet.verb = VSV_SEND_VERSION_NUMBER;
47438 packet.u.version = HVSI_VERSION;
47439 packet.query_seqno = query_seqno+1;
47440 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47441
47442 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47443 packet.hdr.len = sizeof(struct hvsi_query);
47444 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47445 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47446 packet.verb = verb;
47447
47448 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47449 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47450 int wrote;
47451
47452 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47453 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47454 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47455 packet.hdr.len = sizeof(struct hvsi_control);
47456 packet.verb = VSV_SET_MODEM_CTL;
47457 packet.mask = HVSI_TSDTR;
47458 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47459 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47460
47461 packet.hdr.type = VS_DATA_PACKET_HEADER;
47462 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47463 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47464 packet.hdr.len = count + sizeof(struct hvsi_header);
47465 memcpy(&packet.data, buf, count);
47466
47467 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47468 struct hvsi_control packet __ALIGNED__;
47469
47470 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47471 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47472 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47473 packet.hdr.len = 6;
47474 packet.verb = VSV_CLOSE_PROTOCOL;
47475
47476 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47477 index ac27671..0f627ee 100644
47478 --- a/drivers/tty/hvc/hvsi_lib.c
47479 +++ b/drivers/tty/hvc/hvsi_lib.c
47480 @@ -9,7 +9,7 @@
47481
47482 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47483 {
47484 - packet->seqno = atomic_inc_return(&pv->seqno);
47485 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47486
47487 /* Assumes that always succeeds, works in practice */
47488 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47489 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47490
47491 /* Reset state */
47492 pv->established = 0;
47493 - atomic_set(&pv->seqno, 0);
47494 + atomic_set_unchecked(&pv->seqno, 0);
47495
47496 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47497
47498 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47499 pv->mctrl_update = 0;
47500 q.hdr.type = VS_QUERY_PACKET_HEADER;
47501 q.hdr.len = sizeof(struct hvsi_query);
47502 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47503 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47504 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47505 rc = hvsi_send_packet(pv, &q.hdr);
47506 if (rc <= 0) {
47507 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47508 index 8fd72ff..34a0bed 100644
47509 --- a/drivers/tty/ipwireless/tty.c
47510 +++ b/drivers/tty/ipwireless/tty.c
47511 @@ -29,6 +29,7 @@
47512 #include <linux/tty_driver.h>
47513 #include <linux/tty_flip.h>
47514 #include <linux/uaccess.h>
47515 +#include <asm/local.h>
47516
47517 #include "tty.h"
47518 #include "network.h"
47519 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47520 mutex_unlock(&tty->ipw_tty_mutex);
47521 return -ENODEV;
47522 }
47523 - if (tty->port.count == 0)
47524 + if (atomic_read(&tty->port.count) == 0)
47525 tty->tx_bytes_queued = 0;
47526
47527 - tty->port.count++;
47528 + atomic_inc(&tty->port.count);
47529
47530 tty->port.tty = linux_tty;
47531 linux_tty->driver_data = tty;
47532 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47533
47534 static void do_ipw_close(struct ipw_tty *tty)
47535 {
47536 - tty->port.count--;
47537 -
47538 - if (tty->port.count == 0) {
47539 + if (atomic_dec_return(&tty->port.count) == 0) {
47540 struct tty_struct *linux_tty = tty->port.tty;
47541
47542 if (linux_tty != NULL) {
47543 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47544 return;
47545
47546 mutex_lock(&tty->ipw_tty_mutex);
47547 - if (tty->port.count == 0) {
47548 + if (atomic_read(&tty->port.count) == 0) {
47549 mutex_unlock(&tty->ipw_tty_mutex);
47550 return;
47551 }
47552 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47553
47554 mutex_lock(&tty->ipw_tty_mutex);
47555
47556 - if (!tty->port.count) {
47557 + if (!atomic_read(&tty->port.count)) {
47558 mutex_unlock(&tty->ipw_tty_mutex);
47559 return;
47560 }
47561 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47562 return -ENODEV;
47563
47564 mutex_lock(&tty->ipw_tty_mutex);
47565 - if (!tty->port.count) {
47566 + if (!atomic_read(&tty->port.count)) {
47567 mutex_unlock(&tty->ipw_tty_mutex);
47568 return -EINVAL;
47569 }
47570 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47571 if (!tty)
47572 return -ENODEV;
47573
47574 - if (!tty->port.count)
47575 + if (!atomic_read(&tty->port.count))
47576 return -EINVAL;
47577
47578 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47579 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47580 if (!tty)
47581 return 0;
47582
47583 - if (!tty->port.count)
47584 + if (!atomic_read(&tty->port.count))
47585 return 0;
47586
47587 return tty->tx_bytes_queued;
47588 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47589 if (!tty)
47590 return -ENODEV;
47591
47592 - if (!tty->port.count)
47593 + if (!atomic_read(&tty->port.count))
47594 return -EINVAL;
47595
47596 return get_control_lines(tty);
47597 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47598 if (!tty)
47599 return -ENODEV;
47600
47601 - if (!tty->port.count)
47602 + if (!atomic_read(&tty->port.count))
47603 return -EINVAL;
47604
47605 return set_control_lines(tty, set, clear);
47606 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47607 if (!tty)
47608 return -ENODEV;
47609
47610 - if (!tty->port.count)
47611 + if (!atomic_read(&tty->port.count))
47612 return -EINVAL;
47613
47614 /* FIXME: Exactly how is the tty object locked here .. */
47615 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47616 * are gone */
47617 mutex_lock(&ttyj->ipw_tty_mutex);
47618 }
47619 - while (ttyj->port.count)
47620 + while (atomic_read(&ttyj->port.count))
47621 do_ipw_close(ttyj);
47622 ipwireless_disassociate_network_ttys(network,
47623 ttyj->channel_idx);
47624 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47625 index 1deaca4..c8582d4 100644
47626 --- a/drivers/tty/moxa.c
47627 +++ b/drivers/tty/moxa.c
47628 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47629 }
47630
47631 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47632 - ch->port.count++;
47633 + atomic_inc(&ch->port.count);
47634 tty->driver_data = ch;
47635 tty_port_tty_set(&ch->port, tty);
47636 mutex_lock(&ch->port.mutex);
47637 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47638 index c0f76da..d974c32 100644
47639 --- a/drivers/tty/n_gsm.c
47640 +++ b/drivers/tty/n_gsm.c
47641 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47642 spin_lock_init(&dlci->lock);
47643 mutex_init(&dlci->mutex);
47644 dlci->fifo = &dlci->_fifo;
47645 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47646 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47647 kfree(dlci);
47648 return NULL;
47649 }
47650 @@ -2935,7 +2935,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47651 struct gsm_dlci *dlci = tty->driver_data;
47652 struct tty_port *port = &dlci->port;
47653
47654 - port->count++;
47655 + atomic_inc(&port->count);
47656 dlci_get(dlci);
47657 dlci_get(dlci->gsm->dlci[0]);
47658 mux_get(dlci->gsm);
47659 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47660 index 7a744b6..6aa4aa9 100644
47661 --- a/drivers/tty/n_tty.c
47662 +++ b/drivers/tty/n_tty.c
47663 @@ -2498,6 +2498,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47664 {
47665 *ops = tty_ldisc_N_TTY;
47666 ops->owner = NULL;
47667 - ops->refcount = ops->flags = 0;
47668 + atomic_set(&ops->refcount, 0);
47669 + ops->flags = 0;
47670 }
47671 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47672 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47673 index 25c9bc7..24077b7 100644
47674 --- a/drivers/tty/pty.c
47675 +++ b/drivers/tty/pty.c
47676 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
47677 panic("Couldn't register Unix98 pts driver");
47678
47679 /* Now create the /dev/ptmx special device */
47680 + pax_open_kernel();
47681 tty_default_fops(&ptmx_fops);
47682 - ptmx_fops.open = ptmx_open;
47683 + *(void **)&ptmx_fops.open = ptmx_open;
47684 + pax_close_kernel();
47685
47686 cdev_init(&ptmx_cdev, &ptmx_fops);
47687 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47688 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47689 index 354564e..fe50d9a 100644
47690 --- a/drivers/tty/rocket.c
47691 +++ b/drivers/tty/rocket.c
47692 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47693 tty->driver_data = info;
47694 tty_port_tty_set(port, tty);
47695
47696 - if (port->count++ == 0) {
47697 + if (atomic_inc_return(&port->count) == 1) {
47698 atomic_inc(&rp_num_ports_open);
47699
47700 #ifdef ROCKET_DEBUG_OPEN
47701 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47702 #endif
47703 }
47704 #ifdef ROCKET_DEBUG_OPEN
47705 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47706 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47707 #endif
47708
47709 /*
47710 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47711 spin_unlock_irqrestore(&info->port.lock, flags);
47712 return;
47713 }
47714 - if (info->port.count)
47715 + if (atomic_read(&info->port.count))
47716 atomic_dec(&rp_num_ports_open);
47717 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47718 spin_unlock_irqrestore(&info->port.lock, flags);
47719 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47720 index 1274499..f541382 100644
47721 --- a/drivers/tty/serial/ioc4_serial.c
47722 +++ b/drivers/tty/serial/ioc4_serial.c
47723 @@ -437,7 +437,7 @@ struct ioc4_soft {
47724 } is_intr_info[MAX_IOC4_INTR_ENTS];
47725
47726 /* Number of entries active in the above array */
47727 - atomic_t is_num_intrs;
47728 + atomic_unchecked_t is_num_intrs;
47729 } is_intr_type[IOC4_NUM_INTR_TYPES];
47730
47731 /* is_ir_lock must be held while
47732 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47733 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47734 || (type == IOC4_OTHER_INTR_TYPE)));
47735
47736 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47737 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47738 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47739
47740 /* Save off the lower level interrupt handler */
47741 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47742
47743 soft = arg;
47744 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47745 - num_intrs = (int)atomic_read(
47746 + num_intrs = (int)atomic_read_unchecked(
47747 &soft->is_intr_type[intr_type].is_num_intrs);
47748
47749 this_mir = this_ir = pending_intrs(soft, intr_type);
47750 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47751 index a260cde..6b2b5ce 100644
47752 --- a/drivers/tty/serial/kgdboc.c
47753 +++ b/drivers/tty/serial/kgdboc.c
47754 @@ -24,8 +24,9 @@
47755 #define MAX_CONFIG_LEN 40
47756
47757 static struct kgdb_io kgdboc_io_ops;
47758 +static struct kgdb_io kgdboc_io_ops_console;
47759
47760 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
47761 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
47762 static int configured = -1;
47763
47764 static char config[MAX_CONFIG_LEN];
47765 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
47766 kgdboc_unregister_kbd();
47767 if (configured == 1)
47768 kgdb_unregister_io_module(&kgdboc_io_ops);
47769 + else if (configured == 2)
47770 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
47771 }
47772
47773 static int configure_kgdboc(void)
47774 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
47775 int err;
47776 char *cptr = config;
47777 struct console *cons;
47778 + int is_console = 0;
47779
47780 err = kgdboc_option_setup(config);
47781 if (err || !strlen(config) || isspace(config[0]))
47782 goto noconfig;
47783
47784 err = -ENODEV;
47785 - kgdboc_io_ops.is_console = 0;
47786 kgdb_tty_driver = NULL;
47787
47788 kgdboc_use_kms = 0;
47789 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
47790 int idx;
47791 if (cons->device && cons->device(cons, &idx) == p &&
47792 idx == tty_line) {
47793 - kgdboc_io_ops.is_console = 1;
47794 + is_console = 1;
47795 break;
47796 }
47797 cons = cons->next;
47798 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
47799 kgdb_tty_line = tty_line;
47800
47801 do_register:
47802 - err = kgdb_register_io_module(&kgdboc_io_ops);
47803 + if (is_console) {
47804 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
47805 + configured = 2;
47806 + } else {
47807 + err = kgdb_register_io_module(&kgdboc_io_ops);
47808 + configured = 1;
47809 + }
47810 if (err)
47811 goto noconfig;
47812
47813 @@ -205,8 +214,6 @@ do_register:
47814 if (err)
47815 goto nmi_con_failed;
47816
47817 - configured = 1;
47818 -
47819 return 0;
47820
47821 nmi_con_failed:
47822 @@ -223,7 +230,7 @@ noconfig:
47823 static int __init init_kgdboc(void)
47824 {
47825 /* Already configured? */
47826 - if (configured == 1)
47827 + if (configured >= 1)
47828 return 0;
47829
47830 return configure_kgdboc();
47831 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
47832 if (config[len - 1] == '\n')
47833 config[len - 1] = '\0';
47834
47835 - if (configured == 1)
47836 + if (configured >= 1)
47837 cleanup_kgdboc();
47838
47839 /* Go and configure with the new params. */
47840 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
47841 .post_exception = kgdboc_post_exp_handler,
47842 };
47843
47844 +static struct kgdb_io kgdboc_io_ops_console = {
47845 + .name = "kgdboc",
47846 + .read_char = kgdboc_get_char,
47847 + .write_char = kgdboc_put_char,
47848 + .pre_exception = kgdboc_pre_exp_handler,
47849 + .post_exception = kgdboc_post_exp_handler,
47850 + .is_console = 1
47851 +};
47852 +
47853 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
47854 /* This is only available if kgdboc is a built in for early debugging */
47855 static int __init kgdboc_early_init(char *opt)
47856 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
47857 index b5d779c..3622cfe 100644
47858 --- a/drivers/tty/serial/msm_serial.c
47859 +++ b/drivers/tty/serial/msm_serial.c
47860 @@ -897,7 +897,7 @@ static struct uart_driver msm_uart_driver = {
47861 .cons = MSM_CONSOLE,
47862 };
47863
47864 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
47865 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
47866
47867 static const struct of_device_id msm_uartdm_table[] = {
47868 { .compatible = "qcom,msm-uartdm" },
47869 @@ -912,7 +912,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
47870 int irq;
47871
47872 if (pdev->id == -1)
47873 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
47874 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
47875
47876 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
47877 return -ENXIO;
47878 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
47879 index f3dfa19..342f2ff 100644
47880 --- a/drivers/tty/serial/samsung.c
47881 +++ b/drivers/tty/serial/samsung.c
47882 @@ -456,11 +456,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
47883 }
47884 }
47885
47886 +static int s3c64xx_serial_startup(struct uart_port *port);
47887 static int s3c24xx_serial_startup(struct uart_port *port)
47888 {
47889 struct s3c24xx_uart_port *ourport = to_ourport(port);
47890 int ret;
47891
47892 + /* Startup sequence is different for s3c64xx and higher SoC's */
47893 + if (s3c24xx_serial_has_interrupt_mask(port))
47894 + return s3c64xx_serial_startup(port);
47895 +
47896 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
47897 port->mapbase, port->membase);
47898
47899 @@ -1127,10 +1132,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
47900 /* setup info for port */
47901 port->dev = &platdev->dev;
47902
47903 - /* Startup sequence is different for s3c64xx and higher SoC's */
47904 - if (s3c24xx_serial_has_interrupt_mask(port))
47905 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
47906 -
47907 port->uartclk = 1;
47908
47909 if (cfg->uart_flags & UPF_CONS_FLOW) {
47910 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
47911 index 0f02351..07c59c5 100644
47912 --- a/drivers/tty/serial/serial_core.c
47913 +++ b/drivers/tty/serial/serial_core.c
47914 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
47915 uart_flush_buffer(tty);
47916 uart_shutdown(tty, state);
47917 spin_lock_irqsave(&port->lock, flags);
47918 - port->count = 0;
47919 + atomic_set(&port->count, 0);
47920 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
47921 spin_unlock_irqrestore(&port->lock, flags);
47922 tty_port_tty_set(port, NULL);
47923 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47924 goto end;
47925 }
47926
47927 - port->count++;
47928 + atomic_inc(&port->count);
47929 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
47930 retval = -ENXIO;
47931 goto err_dec_count;
47932 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47933 /*
47934 * Make sure the device is in D0 state.
47935 */
47936 - if (port->count == 1)
47937 + if (atomic_read(&port->count) == 1)
47938 uart_change_pm(state, UART_PM_STATE_ON);
47939
47940 /*
47941 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47942 end:
47943 return retval;
47944 err_dec_count:
47945 - port->count--;
47946 + atomic_inc(&port->count);
47947 mutex_unlock(&port->mutex);
47948 goto end;
47949 }
47950 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
47951 index e1ce141..6d4ed80 100644
47952 --- a/drivers/tty/synclink.c
47953 +++ b/drivers/tty/synclink.c
47954 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
47955
47956 if (debug_level >= DEBUG_LEVEL_INFO)
47957 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
47958 - __FILE__,__LINE__, info->device_name, info->port.count);
47959 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
47960
47961 if (tty_port_close_start(&info->port, tty, filp) == 0)
47962 goto cleanup;
47963 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
47964 cleanup:
47965 if (debug_level >= DEBUG_LEVEL_INFO)
47966 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
47967 - tty->driver->name, info->port.count);
47968 + tty->driver->name, atomic_read(&info->port.count));
47969
47970 } /* end of mgsl_close() */
47971
47972 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
47973
47974 mgsl_flush_buffer(tty);
47975 shutdown(info);
47976 -
47977 - info->port.count = 0;
47978 +
47979 + atomic_set(&info->port.count, 0);
47980 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
47981 info->port.tty = NULL;
47982
47983 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
47984
47985 if (debug_level >= DEBUG_LEVEL_INFO)
47986 printk("%s(%d):block_til_ready before block on %s count=%d\n",
47987 - __FILE__,__LINE__, tty->driver->name, port->count );
47988 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
47989
47990 spin_lock_irqsave(&info->irq_spinlock, flags);
47991 if (!tty_hung_up_p(filp)) {
47992 extra_count = true;
47993 - port->count--;
47994 + atomic_dec(&port->count);
47995 }
47996 spin_unlock_irqrestore(&info->irq_spinlock, flags);
47997 port->blocked_open++;
47998 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
47999
48000 if (debug_level >= DEBUG_LEVEL_INFO)
48001 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48002 - __FILE__,__LINE__, tty->driver->name, port->count );
48003 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48004
48005 tty_unlock(tty);
48006 schedule();
48007 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48008
48009 /* FIXME: Racy on hangup during close wait */
48010 if (extra_count)
48011 - port->count++;
48012 + atomic_inc(&port->count);
48013 port->blocked_open--;
48014
48015 if (debug_level >= DEBUG_LEVEL_INFO)
48016 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48017 - __FILE__,__LINE__, tty->driver->name, port->count );
48018 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48019
48020 if (!retval)
48021 port->flags |= ASYNC_NORMAL_ACTIVE;
48022 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48023
48024 if (debug_level >= DEBUG_LEVEL_INFO)
48025 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48026 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48027 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48028
48029 /* If port is closing, signal caller to try again */
48030 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48031 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48032 spin_unlock_irqrestore(&info->netlock, flags);
48033 goto cleanup;
48034 }
48035 - info->port.count++;
48036 + atomic_inc(&info->port.count);
48037 spin_unlock_irqrestore(&info->netlock, flags);
48038
48039 - if (info->port.count == 1) {
48040 + if (atomic_read(&info->port.count) == 1) {
48041 /* 1st open on this device, init hardware */
48042 retval = startup(info);
48043 if (retval < 0)
48044 @@ -3446,8 +3446,8 @@ cleanup:
48045 if (retval) {
48046 if (tty->count == 1)
48047 info->port.tty = NULL; /* tty layer will release tty struct */
48048 - if(info->port.count)
48049 - info->port.count--;
48050 + if (atomic_read(&info->port.count))
48051 + atomic_dec(&info->port.count);
48052 }
48053
48054 return retval;
48055 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48056 unsigned short new_crctype;
48057
48058 /* return error if TTY interface open */
48059 - if (info->port.count)
48060 + if (atomic_read(&info->port.count))
48061 return -EBUSY;
48062
48063 switch (encoding)
48064 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48065
48066 /* arbitrate between network and tty opens */
48067 spin_lock_irqsave(&info->netlock, flags);
48068 - if (info->port.count != 0 || info->netcount != 0) {
48069 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48070 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48071 spin_unlock_irqrestore(&info->netlock, flags);
48072 return -EBUSY;
48073 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48074 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48075
48076 /* return error if TTY interface open */
48077 - if (info->port.count)
48078 + if (atomic_read(&info->port.count))
48079 return -EBUSY;
48080
48081 if (cmd != SIOCWANDEV)
48082 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48083 index 1abf946..1ee34fc 100644
48084 --- a/drivers/tty/synclink_gt.c
48085 +++ b/drivers/tty/synclink_gt.c
48086 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48087 tty->driver_data = info;
48088 info->port.tty = tty;
48089
48090 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48091 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48092
48093 /* If port is closing, signal caller to try again */
48094 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48095 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48096 mutex_unlock(&info->port.mutex);
48097 goto cleanup;
48098 }
48099 - info->port.count++;
48100 + atomic_inc(&info->port.count);
48101 spin_unlock_irqrestore(&info->netlock, flags);
48102
48103 - if (info->port.count == 1) {
48104 + if (atomic_read(&info->port.count) == 1) {
48105 /* 1st open on this device, init hardware */
48106 retval = startup(info);
48107 if (retval < 0) {
48108 @@ -715,8 +715,8 @@ cleanup:
48109 if (retval) {
48110 if (tty->count == 1)
48111 info->port.tty = NULL; /* tty layer will release tty struct */
48112 - if(info->port.count)
48113 - info->port.count--;
48114 + if(atomic_read(&info->port.count))
48115 + atomic_dec(&info->port.count);
48116 }
48117
48118 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48119 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48120
48121 if (sanity_check(info, tty->name, "close"))
48122 return;
48123 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48124 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48125
48126 if (tty_port_close_start(&info->port, tty, filp) == 0)
48127 goto cleanup;
48128 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48129 tty_port_close_end(&info->port, tty);
48130 info->port.tty = NULL;
48131 cleanup:
48132 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48133 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48134 }
48135
48136 static void hangup(struct tty_struct *tty)
48137 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48138 shutdown(info);
48139
48140 spin_lock_irqsave(&info->port.lock, flags);
48141 - info->port.count = 0;
48142 + atomic_set(&info->port.count, 0);
48143 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48144 info->port.tty = NULL;
48145 spin_unlock_irqrestore(&info->port.lock, flags);
48146 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48147 unsigned short new_crctype;
48148
48149 /* return error if TTY interface open */
48150 - if (info->port.count)
48151 + if (atomic_read(&info->port.count))
48152 return -EBUSY;
48153
48154 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48155 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48156
48157 /* arbitrate between network and tty opens */
48158 spin_lock_irqsave(&info->netlock, flags);
48159 - if (info->port.count != 0 || info->netcount != 0) {
48160 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48161 DBGINFO(("%s hdlc_open busy\n", dev->name));
48162 spin_unlock_irqrestore(&info->netlock, flags);
48163 return -EBUSY;
48164 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48165 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48166
48167 /* return error if TTY interface open */
48168 - if (info->port.count)
48169 + if (atomic_read(&info->port.count))
48170 return -EBUSY;
48171
48172 if (cmd != SIOCWANDEV)
48173 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48174 if (port == NULL)
48175 continue;
48176 spin_lock(&port->lock);
48177 - if ((port->port.count || port->netcount) &&
48178 + if ((atomic_read(&port->port.count) || port->netcount) &&
48179 port->pending_bh && !port->bh_running &&
48180 !port->bh_requested) {
48181 DBGISR(("%s bh queued\n", port->device_name));
48182 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48183 spin_lock_irqsave(&info->lock, flags);
48184 if (!tty_hung_up_p(filp)) {
48185 extra_count = true;
48186 - port->count--;
48187 + atomic_dec(&port->count);
48188 }
48189 spin_unlock_irqrestore(&info->lock, flags);
48190 port->blocked_open++;
48191 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48192 remove_wait_queue(&port->open_wait, &wait);
48193
48194 if (extra_count)
48195 - port->count++;
48196 + atomic_inc(&port->count);
48197 port->blocked_open--;
48198
48199 if (!retval)
48200 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48201 index dc6e969..5dc8786 100644
48202 --- a/drivers/tty/synclinkmp.c
48203 +++ b/drivers/tty/synclinkmp.c
48204 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48205
48206 if (debug_level >= DEBUG_LEVEL_INFO)
48207 printk("%s(%d):%s open(), old ref count = %d\n",
48208 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48209 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48210
48211 /* If port is closing, signal caller to try again */
48212 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48213 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48214 spin_unlock_irqrestore(&info->netlock, flags);
48215 goto cleanup;
48216 }
48217 - info->port.count++;
48218 + atomic_inc(&info->port.count);
48219 spin_unlock_irqrestore(&info->netlock, flags);
48220
48221 - if (info->port.count == 1) {
48222 + if (atomic_read(&info->port.count) == 1) {
48223 /* 1st open on this device, init hardware */
48224 retval = startup(info);
48225 if (retval < 0)
48226 @@ -796,8 +796,8 @@ cleanup:
48227 if (retval) {
48228 if (tty->count == 1)
48229 info->port.tty = NULL; /* tty layer will release tty struct */
48230 - if(info->port.count)
48231 - info->port.count--;
48232 + if(atomic_read(&info->port.count))
48233 + atomic_dec(&info->port.count);
48234 }
48235
48236 return retval;
48237 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48238
48239 if (debug_level >= DEBUG_LEVEL_INFO)
48240 printk("%s(%d):%s close() entry, count=%d\n",
48241 - __FILE__,__LINE__, info->device_name, info->port.count);
48242 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48243
48244 if (tty_port_close_start(&info->port, tty, filp) == 0)
48245 goto cleanup;
48246 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48247 cleanup:
48248 if (debug_level >= DEBUG_LEVEL_INFO)
48249 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48250 - tty->driver->name, info->port.count);
48251 + tty->driver->name, atomic_read(&info->port.count));
48252 }
48253
48254 /* Called by tty_hangup() when a hangup is signaled.
48255 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48256 shutdown(info);
48257
48258 spin_lock_irqsave(&info->port.lock, flags);
48259 - info->port.count = 0;
48260 + atomic_set(&info->port.count, 0);
48261 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48262 info->port.tty = NULL;
48263 spin_unlock_irqrestore(&info->port.lock, flags);
48264 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48265 unsigned short new_crctype;
48266
48267 /* return error if TTY interface open */
48268 - if (info->port.count)
48269 + if (atomic_read(&info->port.count))
48270 return -EBUSY;
48271
48272 switch (encoding)
48273 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48274
48275 /* arbitrate between network and tty opens */
48276 spin_lock_irqsave(&info->netlock, flags);
48277 - if (info->port.count != 0 || info->netcount != 0) {
48278 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48279 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48280 spin_unlock_irqrestore(&info->netlock, flags);
48281 return -EBUSY;
48282 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48283 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48284
48285 /* return error if TTY interface open */
48286 - if (info->port.count)
48287 + if (atomic_read(&info->port.count))
48288 return -EBUSY;
48289
48290 if (cmd != SIOCWANDEV)
48291 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48292 * do not request bottom half processing if the
48293 * device is not open in a normal mode.
48294 */
48295 - if ( port && (port->port.count || port->netcount) &&
48296 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48297 port->pending_bh && !port->bh_running &&
48298 !port->bh_requested ) {
48299 if ( debug_level >= DEBUG_LEVEL_ISR )
48300 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48301
48302 if (debug_level >= DEBUG_LEVEL_INFO)
48303 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48304 - __FILE__,__LINE__, tty->driver->name, port->count );
48305 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48306
48307 spin_lock_irqsave(&info->lock, flags);
48308 if (!tty_hung_up_p(filp)) {
48309 extra_count = true;
48310 - port->count--;
48311 + atomic_dec(&port->count);
48312 }
48313 spin_unlock_irqrestore(&info->lock, flags);
48314 port->blocked_open++;
48315 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48316
48317 if (debug_level >= DEBUG_LEVEL_INFO)
48318 printk("%s(%d):%s block_til_ready() count=%d\n",
48319 - __FILE__,__LINE__, tty->driver->name, port->count );
48320 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48321
48322 tty_unlock(tty);
48323 schedule();
48324 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48325 remove_wait_queue(&port->open_wait, &wait);
48326
48327 if (extra_count)
48328 - port->count++;
48329 + atomic_inc(&port->count);
48330 port->blocked_open--;
48331
48332 if (debug_level >= DEBUG_LEVEL_INFO)
48333 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48334 - __FILE__,__LINE__, tty->driver->name, port->count );
48335 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48336
48337 if (!retval)
48338 port->flags |= ASYNC_NORMAL_ACTIVE;
48339 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48340 index 40a9fe9..a3f10cc 100644
48341 --- a/drivers/tty/sysrq.c
48342 +++ b/drivers/tty/sysrq.c
48343 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48344 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48345 size_t count, loff_t *ppos)
48346 {
48347 - if (count) {
48348 + if (count && capable(CAP_SYS_ADMIN)) {
48349 char c;
48350
48351 if (get_user(c, buf))
48352 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48353 index 3a1a01a..b12cda2 100644
48354 --- a/drivers/tty/tty_io.c
48355 +++ b/drivers/tty/tty_io.c
48356 @@ -3473,7 +3473,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48357
48358 void tty_default_fops(struct file_operations *fops)
48359 {
48360 - *fops = tty_fops;
48361 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48362 }
48363
48364 /*
48365 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48366 index 6458e11..6cfc218 100644
48367 --- a/drivers/tty/tty_ldisc.c
48368 +++ b/drivers/tty/tty_ldisc.c
48369 @@ -72,7 +72,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48370 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48371 tty_ldiscs[disc] = new_ldisc;
48372 new_ldisc->num = disc;
48373 - new_ldisc->refcount = 0;
48374 + atomic_set(&new_ldisc->refcount, 0);
48375 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48376
48377 return ret;
48378 @@ -100,7 +100,7 @@ int tty_unregister_ldisc(int disc)
48379 return -EINVAL;
48380
48381 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48382 - if (tty_ldiscs[disc]->refcount)
48383 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48384 ret = -EBUSY;
48385 else
48386 tty_ldiscs[disc] = NULL;
48387 @@ -121,7 +121,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48388 if (ldops) {
48389 ret = ERR_PTR(-EAGAIN);
48390 if (try_module_get(ldops->owner)) {
48391 - ldops->refcount++;
48392 + atomic_inc(&ldops->refcount);
48393 ret = ldops;
48394 }
48395 }
48396 @@ -134,7 +134,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48397 unsigned long flags;
48398
48399 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48400 - ldops->refcount--;
48401 + atomic_dec(&ldops->refcount);
48402 module_put(ldops->owner);
48403 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48404 }
48405 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48406 index f597e88..b7f68ed 100644
48407 --- a/drivers/tty/tty_port.c
48408 +++ b/drivers/tty/tty_port.c
48409 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48410 unsigned long flags;
48411
48412 spin_lock_irqsave(&port->lock, flags);
48413 - port->count = 0;
48414 + atomic_set(&port->count, 0);
48415 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48416 tty = port->tty;
48417 if (tty)
48418 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48419 /* The port lock protects the port counts */
48420 spin_lock_irqsave(&port->lock, flags);
48421 if (!tty_hung_up_p(filp))
48422 - port->count--;
48423 + atomic_dec(&port->count);
48424 port->blocked_open++;
48425 spin_unlock_irqrestore(&port->lock, flags);
48426
48427 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48428 we must not mess that up further */
48429 spin_lock_irqsave(&port->lock, flags);
48430 if (!tty_hung_up_p(filp))
48431 - port->count++;
48432 + atomic_inc(&port->count);
48433 port->blocked_open--;
48434 if (retval == 0)
48435 port->flags |= ASYNC_NORMAL_ACTIVE;
48436 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48437 return 0;
48438 }
48439
48440 - if (tty->count == 1 && port->count != 1) {
48441 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48442 printk(KERN_WARNING
48443 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48444 - port->count);
48445 - port->count = 1;
48446 + atomic_read(&port->count));
48447 + atomic_set(&port->count, 1);
48448 }
48449 - if (--port->count < 0) {
48450 + if (atomic_dec_return(&port->count) < 0) {
48451 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48452 - port->count);
48453 - port->count = 0;
48454 + atomic_read(&port->count));
48455 + atomic_set(&port->count, 0);
48456 }
48457
48458 - if (port->count) {
48459 + if (atomic_read(&port->count)) {
48460 spin_unlock_irqrestore(&port->lock, flags);
48461 if (port->ops->drop)
48462 port->ops->drop(port);
48463 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48464 {
48465 spin_lock_irq(&port->lock);
48466 if (!tty_hung_up_p(filp))
48467 - ++port->count;
48468 + atomic_inc(&port->count);
48469 spin_unlock_irq(&port->lock);
48470 tty_port_tty_set(port, tty);
48471
48472 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48473 index d0e3a44..5f8b754 100644
48474 --- a/drivers/tty/vt/keyboard.c
48475 +++ b/drivers/tty/vt/keyboard.c
48476 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48477 kbd->kbdmode == VC_OFF) &&
48478 value != KVAL(K_SAK))
48479 return; /* SAK is allowed even in raw mode */
48480 +
48481 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48482 + {
48483 + void *func = fn_handler[value];
48484 + if (func == fn_show_state || func == fn_show_ptregs ||
48485 + func == fn_show_mem)
48486 + return;
48487 + }
48488 +#endif
48489 +
48490 fn_handler[value](vc);
48491 }
48492
48493 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48494 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48495 return -EFAULT;
48496
48497 - if (!capable(CAP_SYS_TTY_CONFIG))
48498 - perm = 0;
48499 -
48500 switch (cmd) {
48501 case KDGKBENT:
48502 /* Ensure another thread doesn't free it under us */
48503 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48504 spin_unlock_irqrestore(&kbd_event_lock, flags);
48505 return put_user(val, &user_kbe->kb_value);
48506 case KDSKBENT:
48507 + if (!capable(CAP_SYS_TTY_CONFIG))
48508 + perm = 0;
48509 +
48510 if (!perm)
48511 return -EPERM;
48512 if (!i && v == K_NOSUCHMAP) {
48513 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48514 int i, j, k;
48515 int ret;
48516
48517 - if (!capable(CAP_SYS_TTY_CONFIG))
48518 - perm = 0;
48519 -
48520 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48521 if (!kbs) {
48522 ret = -ENOMEM;
48523 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48524 kfree(kbs);
48525 return ((p && *p) ? -EOVERFLOW : 0);
48526 case KDSKBSENT:
48527 + if (!capable(CAP_SYS_TTY_CONFIG))
48528 + perm = 0;
48529 +
48530 if (!perm) {
48531 ret = -EPERM;
48532 goto reterr;
48533 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48534 index 0e808cf..26c24ab 100644
48535 --- a/drivers/uio/uio.c
48536 +++ b/drivers/uio/uio.c
48537 @@ -25,6 +25,7 @@
48538 #include <linux/kobject.h>
48539 #include <linux/cdev.h>
48540 #include <linux/uio_driver.h>
48541 +#include <asm/local.h>
48542
48543 #define UIO_MAX_DEVICES (1U << MINORBITS)
48544
48545 @@ -32,7 +33,7 @@ struct uio_device {
48546 struct module *owner;
48547 struct device *dev;
48548 int minor;
48549 - atomic_t event;
48550 + atomic_unchecked_t event;
48551 struct fasync_struct *async_queue;
48552 wait_queue_head_t wait;
48553 struct uio_info *info;
48554 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
48555 struct device_attribute *attr, char *buf)
48556 {
48557 struct uio_device *idev = dev_get_drvdata(dev);
48558 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48559 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48560 }
48561 static DEVICE_ATTR_RO(event);
48562
48563 @@ -401,7 +402,7 @@ void uio_event_notify(struct uio_info *info)
48564 {
48565 struct uio_device *idev = info->uio_dev;
48566
48567 - atomic_inc(&idev->event);
48568 + atomic_inc_unchecked(&idev->event);
48569 wake_up_interruptible(&idev->wait);
48570 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48571 }
48572 @@ -454,7 +455,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48573 }
48574
48575 listener->dev = idev;
48576 - listener->event_count = atomic_read(&idev->event);
48577 + listener->event_count = atomic_read_unchecked(&idev->event);
48578 filep->private_data = listener;
48579
48580 if (idev->info->open) {
48581 @@ -505,7 +506,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48582 return -EIO;
48583
48584 poll_wait(filep, &idev->wait, wait);
48585 - if (listener->event_count != atomic_read(&idev->event))
48586 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48587 return POLLIN | POLLRDNORM;
48588 return 0;
48589 }
48590 @@ -530,7 +531,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48591 do {
48592 set_current_state(TASK_INTERRUPTIBLE);
48593
48594 - event_count = atomic_read(&idev->event);
48595 + event_count = atomic_read_unchecked(&idev->event);
48596 if (event_count != listener->event_count) {
48597 if (copy_to_user(buf, &event_count, count))
48598 retval = -EFAULT;
48599 @@ -587,9 +588,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48600 static int uio_find_mem_index(struct vm_area_struct *vma)
48601 {
48602 struct uio_device *idev = vma->vm_private_data;
48603 + unsigned long size;
48604
48605 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48606 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48607 + size = idev->info->mem[vma->vm_pgoff].size;
48608 + if (size == 0)
48609 + return -1;
48610 + if (vma->vm_end - vma->vm_start > size)
48611 return -1;
48612 return (int)vma->vm_pgoff;
48613 }
48614 @@ -818,7 +823,7 @@ int __uio_register_device(struct module *owner,
48615 idev->owner = owner;
48616 idev->info = info;
48617 init_waitqueue_head(&idev->wait);
48618 - atomic_set(&idev->event, 0);
48619 + atomic_set_unchecked(&idev->event, 0);
48620
48621 ret = uio_get_minor(idev);
48622 if (ret)
48623 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48624 index 8a7eb77..c00402f 100644
48625 --- a/drivers/usb/atm/cxacru.c
48626 +++ b/drivers/usb/atm/cxacru.c
48627 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48628 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48629 if (ret < 2)
48630 return -EINVAL;
48631 - if (index < 0 || index > 0x7f)
48632 + if (index > 0x7f)
48633 return -EINVAL;
48634 pos += tmp;
48635
48636 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48637 index 25a7bfc..57f3cf5 100644
48638 --- a/drivers/usb/atm/usbatm.c
48639 +++ b/drivers/usb/atm/usbatm.c
48640 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48641 if (printk_ratelimit())
48642 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48643 __func__, vpi, vci);
48644 - atomic_inc(&vcc->stats->rx_err);
48645 + atomic_inc_unchecked(&vcc->stats->rx_err);
48646 return;
48647 }
48648
48649 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48650 if (length > ATM_MAX_AAL5_PDU) {
48651 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48652 __func__, length, vcc);
48653 - atomic_inc(&vcc->stats->rx_err);
48654 + atomic_inc_unchecked(&vcc->stats->rx_err);
48655 goto out;
48656 }
48657
48658 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48659 if (sarb->len < pdu_length) {
48660 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48661 __func__, pdu_length, sarb->len, vcc);
48662 - atomic_inc(&vcc->stats->rx_err);
48663 + atomic_inc_unchecked(&vcc->stats->rx_err);
48664 goto out;
48665 }
48666
48667 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48668 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48669 __func__, vcc);
48670 - atomic_inc(&vcc->stats->rx_err);
48671 + atomic_inc_unchecked(&vcc->stats->rx_err);
48672 goto out;
48673 }
48674
48675 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48676 if (printk_ratelimit())
48677 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48678 __func__, length);
48679 - atomic_inc(&vcc->stats->rx_drop);
48680 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48681 goto out;
48682 }
48683
48684 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48685
48686 vcc->push(vcc, skb);
48687
48688 - atomic_inc(&vcc->stats->rx);
48689 + atomic_inc_unchecked(&vcc->stats->rx);
48690 out:
48691 skb_trim(sarb, 0);
48692 }
48693 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
48694 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48695
48696 usbatm_pop(vcc, skb);
48697 - atomic_inc(&vcc->stats->tx);
48698 + atomic_inc_unchecked(&vcc->stats->tx);
48699
48700 skb = skb_dequeue(&instance->sndqueue);
48701 }
48702 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48703 if (!left--)
48704 return sprintf(page,
48705 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48706 - atomic_read(&atm_dev->stats.aal5.tx),
48707 - atomic_read(&atm_dev->stats.aal5.tx_err),
48708 - atomic_read(&atm_dev->stats.aal5.rx),
48709 - atomic_read(&atm_dev->stats.aal5.rx_err),
48710 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48711 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48712 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48713 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48714 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48715 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48716
48717 if (!left--) {
48718 if (instance->disconnected)
48719 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48720 index 2a3bbdf..91d72cf 100644
48721 --- a/drivers/usb/core/devices.c
48722 +++ b/drivers/usb/core/devices.c
48723 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48724 * time it gets called.
48725 */
48726 static struct device_connect_event {
48727 - atomic_t count;
48728 + atomic_unchecked_t count;
48729 wait_queue_head_t wait;
48730 } device_event = {
48731 .count = ATOMIC_INIT(1),
48732 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
48733
48734 void usbfs_conn_disc_event(void)
48735 {
48736 - atomic_add(2, &device_event.count);
48737 + atomic_add_unchecked(2, &device_event.count);
48738 wake_up(&device_event.wait);
48739 }
48740
48741 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
48742
48743 poll_wait(file, &device_event.wait, wait);
48744
48745 - event_count = atomic_read(&device_event.count);
48746 + event_count = atomic_read_unchecked(&device_event.count);
48747 if (file->f_version != event_count) {
48748 file->f_version = event_count;
48749 return POLLIN | POLLRDNORM;
48750 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
48751 index f20a044..d1059aa 100644
48752 --- a/drivers/usb/core/hcd.c
48753 +++ b/drivers/usb/core/hcd.c
48754 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48755 */
48756 usb_get_urb(urb);
48757 atomic_inc(&urb->use_count);
48758 - atomic_inc(&urb->dev->urbnum);
48759 + atomic_inc_unchecked(&urb->dev->urbnum);
48760 usbmon_urb_submit(&hcd->self, urb);
48761
48762 /* NOTE requirements on root-hub callers (usbfs and the hub
48763 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48764 urb->hcpriv = NULL;
48765 INIT_LIST_HEAD(&urb->urb_list);
48766 atomic_dec(&urb->use_count);
48767 - atomic_dec(&urb->dev->urbnum);
48768 + atomic_dec_unchecked(&urb->dev->urbnum);
48769 if (atomic_read(&urb->reject))
48770 wake_up(&usb_kill_urb_queue);
48771 usb_put_urb(urb);
48772 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
48773 index 879651c..87e0131 100644
48774 --- a/drivers/usb/core/hub.c
48775 +++ b/drivers/usb/core/hub.c
48776 @@ -27,6 +27,7 @@
48777 #include <linux/freezer.h>
48778 #include <linux/random.h>
48779 #include <linux/pm_qos.h>
48780 +#include <linux/grsecurity.h>
48781
48782 #include <asm/uaccess.h>
48783 #include <asm/byteorder.h>
48784 @@ -4435,6 +4436,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
48785 goto done;
48786 return;
48787 }
48788 +
48789 + if (gr_handle_new_usb())
48790 + goto done;
48791 +
48792 if (hub_is_superspeed(hub->hdev))
48793 unit_load = 150;
48794 else
48795 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
48796 index 82927e1..4993dbf 100644
48797 --- a/drivers/usb/core/message.c
48798 +++ b/drivers/usb/core/message.c
48799 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
48800 * Return: If successful, the number of bytes transferred. Otherwise, a negative
48801 * error number.
48802 */
48803 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48804 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48805 __u8 requesttype, __u16 value, __u16 index, void *data,
48806 __u16 size, int timeout)
48807 {
48808 @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
48809 * If successful, 0. Otherwise a negative error number. The number of actual
48810 * bytes transferred will be stored in the @actual_length paramater.
48811 */
48812 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
48813 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
48814 void *data, int len, int *actual_length, int timeout)
48815 {
48816 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
48817 @@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
48818 * bytes transferred will be stored in the @actual_length paramater.
48819 *
48820 */
48821 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
48822 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
48823 void *data, int len, int *actual_length, int timeout)
48824 {
48825 struct urb *urb;
48826 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
48827 index 6d2c8ed..3a794ca 100644
48828 --- a/drivers/usb/core/sysfs.c
48829 +++ b/drivers/usb/core/sysfs.c
48830 @@ -236,7 +236,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
48831 struct usb_device *udev;
48832
48833 udev = to_usb_device(dev);
48834 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
48835 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
48836 }
48837 static DEVICE_ATTR_RO(urbnum);
48838
48839 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
48840 index 0a6ee2e..6f8d7e8 100644
48841 --- a/drivers/usb/core/usb.c
48842 +++ b/drivers/usb/core/usb.c
48843 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
48844 set_dev_node(&dev->dev, dev_to_node(bus->controller));
48845 dev->state = USB_STATE_ATTACHED;
48846 dev->lpm_disable_count = 1;
48847 - atomic_set(&dev->urbnum, 0);
48848 + atomic_set_unchecked(&dev->urbnum, 0);
48849
48850 INIT_LIST_HEAD(&dev->ep0.urb_list);
48851 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
48852 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
48853 index 5452c0f..34c9145 100644
48854 --- a/drivers/usb/dwc3/gadget.c
48855 +++ b/drivers/usb/dwc3/gadget.c
48856 @@ -532,8 +532,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
48857 if (!usb_endpoint_xfer_isoc(desc))
48858 return 0;
48859
48860 - memset(&trb_link, 0, sizeof(trb_link));
48861 -
48862 /* Link TRB for ISOC. The HWO bit is never reset */
48863 trb_st_hw = &dep->trb_pool[0];
48864
48865 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
48866 index 5e29dde..eca992f 100644
48867 --- a/drivers/usb/early/ehci-dbgp.c
48868 +++ b/drivers/usb/early/ehci-dbgp.c
48869 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
48870
48871 #ifdef CONFIG_KGDB
48872 static struct kgdb_io kgdbdbgp_io_ops;
48873 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
48874 +static struct kgdb_io kgdbdbgp_io_ops_console;
48875 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
48876 #else
48877 #define dbgp_kgdb_mode (0)
48878 #endif
48879 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
48880 .write_char = kgdbdbgp_write_char,
48881 };
48882
48883 +static struct kgdb_io kgdbdbgp_io_ops_console = {
48884 + .name = "kgdbdbgp",
48885 + .read_char = kgdbdbgp_read_char,
48886 + .write_char = kgdbdbgp_write_char,
48887 + .is_console = 1
48888 +};
48889 +
48890 static int kgdbdbgp_wait_time;
48891
48892 static int __init kgdbdbgp_parse_config(char *str)
48893 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
48894 ptr++;
48895 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
48896 }
48897 - kgdb_register_io_module(&kgdbdbgp_io_ops);
48898 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
48899 + if (early_dbgp_console.index != -1)
48900 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
48901 + else
48902 + kgdb_register_io_module(&kgdbdbgp_io_ops);
48903
48904 return 0;
48905 }
48906 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
48907 index b369292..9f3ba40 100644
48908 --- a/drivers/usb/gadget/u_serial.c
48909 +++ b/drivers/usb/gadget/u_serial.c
48910 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
48911 spin_lock_irq(&port->port_lock);
48912
48913 /* already open? Great. */
48914 - if (port->port.count) {
48915 + if (atomic_read(&port->port.count)) {
48916 status = 0;
48917 - port->port.count++;
48918 + atomic_inc(&port->port.count);
48919
48920 /* currently opening/closing? wait ... */
48921 } else if (port->openclose) {
48922 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
48923 tty->driver_data = port;
48924 port->port.tty = tty;
48925
48926 - port->port.count = 1;
48927 + atomic_set(&port->port.count, 1);
48928 port->openclose = false;
48929
48930 /* if connected, start the I/O stream */
48931 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
48932
48933 spin_lock_irq(&port->port_lock);
48934
48935 - if (port->port.count != 1) {
48936 - if (port->port.count == 0)
48937 + if (atomic_read(&port->port.count) != 1) {
48938 + if (atomic_read(&port->port.count) == 0)
48939 WARN_ON(1);
48940 else
48941 - --port->port.count;
48942 + atomic_dec(&port->port.count);
48943 goto exit;
48944 }
48945
48946 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
48947 * and sleep if necessary
48948 */
48949 port->openclose = true;
48950 - port->port.count = 0;
48951 + atomic_set(&port->port.count, 0);
48952
48953 gser = port->port_usb;
48954 if (gser && gser->disconnect)
48955 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
48956 int cond;
48957
48958 spin_lock_irq(&port->port_lock);
48959 - cond = (port->port.count == 0) && !port->openclose;
48960 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
48961 spin_unlock_irq(&port->port_lock);
48962 return cond;
48963 }
48964 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
48965 /* if it's already open, start I/O ... and notify the serial
48966 * protocol about open/close status (connect/disconnect).
48967 */
48968 - if (port->port.count) {
48969 + if (atomic_read(&port->port.count)) {
48970 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
48971 gs_start_io(port);
48972 if (gser->connect)
48973 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
48974
48975 port->port_usb = NULL;
48976 gser->ioport = NULL;
48977 - if (port->port.count > 0 || port->openclose) {
48978 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
48979 wake_up_interruptible(&port->drain_wait);
48980 if (port->port.tty)
48981 tty_hangup(port->port.tty);
48982 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
48983
48984 /* finally, free any unused/unusable I/O buffers */
48985 spin_lock_irqsave(&port->port_lock, flags);
48986 - if (port->port.count == 0 && !port->openclose)
48987 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
48988 gs_buf_free(&port->port_write_buf);
48989 gs_free_requests(gser->out, &port->read_pool, NULL);
48990 gs_free_requests(gser->out, &port->read_queue, NULL);
48991 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
48992 index 835fc08..f8b22bf 100644
48993 --- a/drivers/usb/host/ehci-hub.c
48994 +++ b/drivers/usb/host/ehci-hub.c
48995 @@ -762,7 +762,7 @@ static struct urb *request_single_step_set_feature_urb(
48996 urb->transfer_flags = URB_DIR_IN;
48997 usb_get_urb(urb);
48998 atomic_inc(&urb->use_count);
48999 - atomic_inc(&urb->dev->urbnum);
49000 + atomic_inc_unchecked(&urb->dev->urbnum);
49001 urb->setup_dma = dma_map_single(
49002 hcd->self.controller,
49003 urb->setup_packet,
49004 @@ -829,7 +829,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
49005 urb->status = -EINPROGRESS;
49006 usb_get_urb(urb);
49007 atomic_inc(&urb->use_count);
49008 - atomic_inc(&urb->dev->urbnum);
49009 + atomic_inc_unchecked(&urb->dev->urbnum);
49010 retval = submit_single_step_set_feature(hcd, urb, 0);
49011 if (!retval && !wait_for_completion_timeout(&done,
49012 msecs_to_jiffies(2000))) {
49013 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49014 index ba6a5d6..f88f7f3 100644
49015 --- a/drivers/usb/misc/appledisplay.c
49016 +++ b/drivers/usb/misc/appledisplay.c
49017 @@ -83,7 +83,7 @@ struct appledisplay {
49018 spinlock_t lock;
49019 };
49020
49021 -static atomic_t count_displays = ATOMIC_INIT(0);
49022 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49023 static struct workqueue_struct *wq;
49024
49025 static void appledisplay_complete(struct urb *urb)
49026 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49027
49028 /* Register backlight device */
49029 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49030 - atomic_inc_return(&count_displays) - 1);
49031 + atomic_inc_return_unchecked(&count_displays) - 1);
49032 memset(&props, 0, sizeof(struct backlight_properties));
49033 props.type = BACKLIGHT_RAW;
49034 props.max_brightness = 0xff;
49035 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49036 index c69bb50..215ef37 100644
49037 --- a/drivers/usb/serial/console.c
49038 +++ b/drivers/usb/serial/console.c
49039 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49040
49041 info->port = port;
49042
49043 - ++port->port.count;
49044 + atomic_inc(&port->port.count);
49045 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49046 if (serial->type->set_termios) {
49047 /*
49048 @@ -170,7 +170,7 @@ static int usb_console_setup(struct console *co, char *options)
49049 }
49050 /* Now that any required fake tty operations are completed restore
49051 * the tty port count */
49052 - --port->port.count;
49053 + atomic_dec(&port->port.count);
49054 /* The console is special in terms of closing the device so
49055 * indicate this port is now acting as a system console. */
49056 port->port.console = 1;
49057 @@ -183,7 +183,7 @@ static int usb_console_setup(struct console *co, char *options)
49058 free_tty:
49059 kfree(tty);
49060 reset_open_count:
49061 - port->port.count = 0;
49062 + atomic_set(&port->port.count, 0);
49063 usb_autopm_put_interface(serial->interface);
49064 error_get_interface:
49065 usb_serial_put(serial);
49066 @@ -194,7 +194,7 @@ static int usb_console_setup(struct console *co, char *options)
49067 static void usb_console_write(struct console *co,
49068 const char *buf, unsigned count)
49069 {
49070 - static struct usbcons_info *info = &usbcons_info;
49071 + struct usbcons_info *info = &usbcons_info;
49072 struct usb_serial_port *port = info->port;
49073 struct usb_serial *serial;
49074 int retval = -ENODEV;
49075 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49076 index 75f70f0..d467e1a 100644
49077 --- a/drivers/usb/storage/usb.h
49078 +++ b/drivers/usb/storage/usb.h
49079 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49080 __u8 useProtocol;
49081 __u8 useTransport;
49082 int (*initFunction)(struct us_data *);
49083 -};
49084 +} __do_const;
49085
49086
49087 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49088 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49089 index cf250c2..ad9d904 100644
49090 --- a/drivers/usb/wusbcore/wa-hc.h
49091 +++ b/drivers/usb/wusbcore/wa-hc.h
49092 @@ -199,7 +199,7 @@ struct wahc {
49093 spinlock_t xfer_list_lock;
49094 struct work_struct xfer_enqueue_work;
49095 struct work_struct xfer_error_work;
49096 - atomic_t xfer_id_count;
49097 + atomic_unchecked_t xfer_id_count;
49098 };
49099
49100
49101 @@ -255,7 +255,7 @@ static inline void wa_init(struct wahc *wa)
49102 spin_lock_init(&wa->xfer_list_lock);
49103 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
49104 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
49105 - atomic_set(&wa->xfer_id_count, 1);
49106 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49107 }
49108
49109 /**
49110 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49111 index 6ad02f5..cc52c8b 100644
49112 --- a/drivers/usb/wusbcore/wa-xfer.c
49113 +++ b/drivers/usb/wusbcore/wa-xfer.c
49114 @@ -299,7 +299,7 @@ out:
49115 */
49116 static void wa_xfer_id_init(struct wa_xfer *xfer)
49117 {
49118 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49119 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49120 }
49121
49122 /*
49123 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49124 index 1eab4ac..e21efc9 100644
49125 --- a/drivers/vfio/vfio.c
49126 +++ b/drivers/vfio/vfio.c
49127 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49128 return 0;
49129
49130 /* TODO Prevent device auto probing */
49131 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49132 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49133 iommu_group_id(group->iommu_group));
49134
49135 return 0;
49136 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49137 index 5174eba..86e764a 100644
49138 --- a/drivers/vhost/vringh.c
49139 +++ b/drivers/vhost/vringh.c
49140 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49141
49142 static inline int putu16_kern(u16 *p, u16 val)
49143 {
49144 - ACCESS_ONCE(*p) = val;
49145 + ACCESS_ONCE_RW(*p) = val;
49146 return 0;
49147 }
49148
49149 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49150 index e43401a..dd49b3f 100644
49151 --- a/drivers/video/arcfb.c
49152 +++ b/drivers/video/arcfb.c
49153 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49154 return -ENOSPC;
49155
49156 err = 0;
49157 - if ((count + p) > fbmemlength) {
49158 + if (count > (fbmemlength - p)) {
49159 count = fbmemlength - p;
49160 err = -ENOSPC;
49161 }
49162 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49163 index a4dfe8c..297ddd9 100644
49164 --- a/drivers/video/aty/aty128fb.c
49165 +++ b/drivers/video/aty/aty128fb.c
49166 @@ -149,7 +149,7 @@ enum {
49167 };
49168
49169 /* Must match above enum */
49170 -static char * const r128_family[] = {
49171 +static const char * const r128_family[] = {
49172 "AGP",
49173 "PCI",
49174 "PRO AGP",
49175 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49176 index 9b0f12c..024673d 100644
49177 --- a/drivers/video/aty/atyfb_base.c
49178 +++ b/drivers/video/aty/atyfb_base.c
49179 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49180 par->accel_flags = var->accel_flags; /* hack */
49181
49182 if (var->accel_flags) {
49183 - info->fbops->fb_sync = atyfb_sync;
49184 + pax_open_kernel();
49185 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49186 + pax_close_kernel();
49187 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49188 } else {
49189 - info->fbops->fb_sync = NULL;
49190 + pax_open_kernel();
49191 + *(void **)&info->fbops->fb_sync = NULL;
49192 + pax_close_kernel();
49193 info->flags |= FBINFO_HWACCEL_DISABLED;
49194 }
49195
49196 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49197 index 95ec042..e6affdd 100644
49198 --- a/drivers/video/aty/mach64_cursor.c
49199 +++ b/drivers/video/aty/mach64_cursor.c
49200 @@ -7,6 +7,7 @@
49201 #include <linux/string.h>
49202
49203 #include <asm/io.h>
49204 +#include <asm/pgtable.h>
49205
49206 #ifdef __sparc__
49207 #include <asm/fbio.h>
49208 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49209 info->sprite.buf_align = 16; /* and 64 lines tall. */
49210 info->sprite.flags = FB_PIXMAP_IO;
49211
49212 - info->fbops->fb_cursor = atyfb_cursor;
49213 + pax_open_kernel();
49214 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49215 + pax_close_kernel();
49216
49217 return 0;
49218 }
49219 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49220 index bca6ccc..252107e 100644
49221 --- a/drivers/video/backlight/kb3886_bl.c
49222 +++ b/drivers/video/backlight/kb3886_bl.c
49223 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49224 static unsigned long kb3886bl_flags;
49225 #define KB3886BL_SUSPENDED 0x01
49226
49227 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49228 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49229 {
49230 .ident = "Sahara Touch-iT",
49231 .matches = {
49232 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49233 index 900aa4e..6d49418 100644
49234 --- a/drivers/video/fb_defio.c
49235 +++ b/drivers/video/fb_defio.c
49236 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49237
49238 BUG_ON(!fbdefio);
49239 mutex_init(&fbdefio->lock);
49240 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49241 + pax_open_kernel();
49242 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49243 + pax_close_kernel();
49244 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49245 INIT_LIST_HEAD(&fbdefio->pagelist);
49246 if (fbdefio->delay == 0) /* set a default of 1 s */
49247 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49248 page->mapping = NULL;
49249 }
49250
49251 - info->fbops->fb_mmap = NULL;
49252 + *(void **)&info->fbops->fb_mmap = NULL;
49253 mutex_destroy(&fbdefio->lock);
49254 }
49255 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49256 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49257 index dacaf74..8478a46 100644
49258 --- a/drivers/video/fbmem.c
49259 +++ b/drivers/video/fbmem.c
49260 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49261 image->dx += image->width + 8;
49262 }
49263 } else if (rotate == FB_ROTATE_UD) {
49264 - for (x = 0; x < num && image->dx >= 0; x++) {
49265 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49266 info->fbops->fb_imageblit(info, image);
49267 image->dx -= image->width + 8;
49268 }
49269 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49270 image->dy += image->height + 8;
49271 }
49272 } else if (rotate == FB_ROTATE_CCW) {
49273 - for (x = 0; x < num && image->dy >= 0; x++) {
49274 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49275 info->fbops->fb_imageblit(info, image);
49276 image->dy -= image->height + 8;
49277 }
49278 @@ -1175,7 +1175,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49279 return -EFAULT;
49280 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49281 return -EINVAL;
49282 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49283 + if (con2fb.framebuffer >= FB_MAX)
49284 return -EINVAL;
49285 if (!registered_fb[con2fb.framebuffer])
49286 request_module("fb%d", con2fb.framebuffer);
49287 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49288 index 8d456dc..b4fa44b 100644
49289 --- a/drivers/video/hyperv_fb.c
49290 +++ b/drivers/video/hyperv_fb.c
49291 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49292 static inline int synthvid_send(struct hv_device *hdev,
49293 struct synthvid_msg *msg)
49294 {
49295 - static atomic64_t request_id = ATOMIC64_INIT(0);
49296 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49297 int ret;
49298
49299 msg->pipe_hdr.type = PIPE_MSG_DATA;
49300 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49301
49302 ret = vmbus_sendpacket(hdev->channel, msg,
49303 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49304 - atomic64_inc_return(&request_id),
49305 + atomic64_inc_return_unchecked(&request_id),
49306 VM_PKT_DATA_INBAND, 0);
49307
49308 if (ret)
49309 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49310 index 7672d2e..b56437f 100644
49311 --- a/drivers/video/i810/i810_accel.c
49312 +++ b/drivers/video/i810/i810_accel.c
49313 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49314 }
49315 }
49316 printk("ringbuffer lockup!!!\n");
49317 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49318 i810_report_error(mmio);
49319 par->dev_flags |= LOCKUP;
49320 info->pixmap.scan_align = 1;
49321 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49322 index 3c14e43..2630570 100644
49323 --- a/drivers/video/logo/logo_linux_clut224.ppm
49324 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49325 @@ -2,1603 +2,1123 @@ P3
49326 # Standard 224-color Linux logo
49327 80 80
49328 255
49329 - 0 0 0 0 0 0 0 0 0 0 0 0
49330 - 0 0 0 0 0 0 0 0 0 0 0 0
49331 - 0 0 0 0 0 0 0 0 0 0 0 0
49332 - 0 0 0 0 0 0 0 0 0 0 0 0
49333 - 0 0 0 0 0 0 0 0 0 0 0 0
49334 - 0 0 0 0 0 0 0 0 0 0 0 0
49335 - 0 0 0 0 0 0 0 0 0 0 0 0
49336 - 0 0 0 0 0 0 0 0 0 0 0 0
49337 - 0 0 0 0 0 0 0 0 0 0 0 0
49338 - 6 6 6 6 6 6 10 10 10 10 10 10
49339 - 10 10 10 6 6 6 6 6 6 6 6 6
49340 - 0 0 0 0 0 0 0 0 0 0 0 0
49341 - 0 0 0 0 0 0 0 0 0 0 0 0
49342 - 0 0 0 0 0 0 0 0 0 0 0 0
49343 - 0 0 0 0 0 0 0 0 0 0 0 0
49344 - 0 0 0 0 0 0 0 0 0 0 0 0
49345 - 0 0 0 0 0 0 0 0 0 0 0 0
49346 - 0 0 0 0 0 0 0 0 0 0 0 0
49347 - 0 0 0 0 0 0 0 0 0 0 0 0
49348 - 0 0 0 0 0 0 0 0 0 0 0 0
49349 - 0 0 0 0 0 0 0 0 0 0 0 0
49350 - 0 0 0 0 0 0 0 0 0 0 0 0
49351 - 0 0 0 0 0 0 0 0 0 0 0 0
49352 - 0 0 0 0 0 0 0 0 0 0 0 0
49353 - 0 0 0 0 0 0 0 0 0 0 0 0
49354 - 0 0 0 0 0 0 0 0 0 0 0 0
49355 - 0 0 0 0 0 0 0 0 0 0 0 0
49356 - 0 0 0 0 0 0 0 0 0 0 0 0
49357 - 0 0 0 6 6 6 10 10 10 14 14 14
49358 - 22 22 22 26 26 26 30 30 30 34 34 34
49359 - 30 30 30 30 30 30 26 26 26 18 18 18
49360 - 14 14 14 10 10 10 6 6 6 0 0 0
49361 - 0 0 0 0 0 0 0 0 0 0 0 0
49362 - 0 0 0 0 0 0 0 0 0 0 0 0
49363 - 0 0 0 0 0 0 0 0 0 0 0 0
49364 - 0 0 0 0 0 0 0 0 0 0 0 0
49365 - 0 0 0 0 0 0 0 0 0 0 0 0
49366 - 0 0 0 0 0 0 0 0 0 0 0 0
49367 - 0 0 0 0 0 0 0 0 0 0 0 0
49368 - 0 0 0 0 0 0 0 0 0 0 0 0
49369 - 0 0 0 0 0 0 0 0 0 0 0 0
49370 - 0 0 0 0 0 1 0 0 1 0 0 0
49371 - 0 0 0 0 0 0 0 0 0 0 0 0
49372 - 0 0 0 0 0 0 0 0 0 0 0 0
49373 - 0 0 0 0 0 0 0 0 0 0 0 0
49374 - 0 0 0 0 0 0 0 0 0 0 0 0
49375 - 0 0 0 0 0 0 0 0 0 0 0 0
49376 - 0 0 0 0 0 0 0 0 0 0 0 0
49377 - 6 6 6 14 14 14 26 26 26 42 42 42
49378 - 54 54 54 66 66 66 78 78 78 78 78 78
49379 - 78 78 78 74 74 74 66 66 66 54 54 54
49380 - 42 42 42 26 26 26 18 18 18 10 10 10
49381 - 6 6 6 0 0 0 0 0 0 0 0 0
49382 - 0 0 0 0 0 0 0 0 0 0 0 0
49383 - 0 0 0 0 0 0 0 0 0 0 0 0
49384 - 0 0 0 0 0 0 0 0 0 0 0 0
49385 - 0 0 0 0 0 0 0 0 0 0 0 0
49386 - 0 0 0 0 0 0 0 0 0 0 0 0
49387 - 0 0 0 0 0 0 0 0 0 0 0 0
49388 - 0 0 0 0 0 0 0 0 0 0 0 0
49389 - 0 0 0 0 0 0 0 0 0 0 0 0
49390 - 0 0 1 0 0 0 0 0 0 0 0 0
49391 - 0 0 0 0 0 0 0 0 0 0 0 0
49392 - 0 0 0 0 0 0 0 0 0 0 0 0
49393 - 0 0 0 0 0 0 0 0 0 0 0 0
49394 - 0 0 0 0 0 0 0 0 0 0 0 0
49395 - 0 0 0 0 0 0 0 0 0 0 0 0
49396 - 0 0 0 0 0 0 0 0 0 10 10 10
49397 - 22 22 22 42 42 42 66 66 66 86 86 86
49398 - 66 66 66 38 38 38 38 38 38 22 22 22
49399 - 26 26 26 34 34 34 54 54 54 66 66 66
49400 - 86 86 86 70 70 70 46 46 46 26 26 26
49401 - 14 14 14 6 6 6 0 0 0 0 0 0
49402 - 0 0 0 0 0 0 0 0 0 0 0 0
49403 - 0 0 0 0 0 0 0 0 0 0 0 0
49404 - 0 0 0 0 0 0 0 0 0 0 0 0
49405 - 0 0 0 0 0 0 0 0 0 0 0 0
49406 - 0 0 0 0 0 0 0 0 0 0 0 0
49407 - 0 0 0 0 0 0 0 0 0 0 0 0
49408 - 0 0 0 0 0 0 0 0 0 0 0 0
49409 - 0 0 0 0 0 0 0 0 0 0 0 0
49410 - 0 0 1 0 0 1 0 0 1 0 0 0
49411 - 0 0 0 0 0 0 0 0 0 0 0 0
49412 - 0 0 0 0 0 0 0 0 0 0 0 0
49413 - 0 0 0 0 0 0 0 0 0 0 0 0
49414 - 0 0 0 0 0 0 0 0 0 0 0 0
49415 - 0 0 0 0 0 0 0 0 0 0 0 0
49416 - 0 0 0 0 0 0 10 10 10 26 26 26
49417 - 50 50 50 82 82 82 58 58 58 6 6 6
49418 - 2 2 6 2 2 6 2 2 6 2 2 6
49419 - 2 2 6 2 2 6 2 2 6 2 2 6
49420 - 6 6 6 54 54 54 86 86 86 66 66 66
49421 - 38 38 38 18 18 18 6 6 6 0 0 0
49422 - 0 0 0 0 0 0 0 0 0 0 0 0
49423 - 0 0 0 0 0 0 0 0 0 0 0 0
49424 - 0 0 0 0 0 0 0 0 0 0 0 0
49425 - 0 0 0 0 0 0 0 0 0 0 0 0
49426 - 0 0 0 0 0 0 0 0 0 0 0 0
49427 - 0 0 0 0 0 0 0 0 0 0 0 0
49428 - 0 0 0 0 0 0 0 0 0 0 0 0
49429 - 0 0 0 0 0 0 0 0 0 0 0 0
49430 - 0 0 0 0 0 0 0 0 0 0 0 0
49431 - 0 0 0 0 0 0 0 0 0 0 0 0
49432 - 0 0 0 0 0 0 0 0 0 0 0 0
49433 - 0 0 0 0 0 0 0 0 0 0 0 0
49434 - 0 0 0 0 0 0 0 0 0 0 0 0
49435 - 0 0 0 0 0 0 0 0 0 0 0 0
49436 - 0 0 0 6 6 6 22 22 22 50 50 50
49437 - 78 78 78 34 34 34 2 2 6 2 2 6
49438 - 2 2 6 2 2 6 2 2 6 2 2 6
49439 - 2 2 6 2 2 6 2 2 6 2 2 6
49440 - 2 2 6 2 2 6 6 6 6 70 70 70
49441 - 78 78 78 46 46 46 22 22 22 6 6 6
49442 - 0 0 0 0 0 0 0 0 0 0 0 0
49443 - 0 0 0 0 0 0 0 0 0 0 0 0
49444 - 0 0 0 0 0 0 0 0 0 0 0 0
49445 - 0 0 0 0 0 0 0 0 0 0 0 0
49446 - 0 0 0 0 0 0 0 0 0 0 0 0
49447 - 0 0 0 0 0 0 0 0 0 0 0 0
49448 - 0 0 0 0 0 0 0 0 0 0 0 0
49449 - 0 0 0 0 0 0 0 0 0 0 0 0
49450 - 0 0 1 0 0 1 0 0 1 0 0 0
49451 - 0 0 0 0 0 0 0 0 0 0 0 0
49452 - 0 0 0 0 0 0 0 0 0 0 0 0
49453 - 0 0 0 0 0 0 0 0 0 0 0 0
49454 - 0 0 0 0 0 0 0 0 0 0 0 0
49455 - 0 0 0 0 0 0 0 0 0 0 0 0
49456 - 6 6 6 18 18 18 42 42 42 82 82 82
49457 - 26 26 26 2 2 6 2 2 6 2 2 6
49458 - 2 2 6 2 2 6 2 2 6 2 2 6
49459 - 2 2 6 2 2 6 2 2 6 14 14 14
49460 - 46 46 46 34 34 34 6 6 6 2 2 6
49461 - 42 42 42 78 78 78 42 42 42 18 18 18
49462 - 6 6 6 0 0 0 0 0 0 0 0 0
49463 - 0 0 0 0 0 0 0 0 0 0 0 0
49464 - 0 0 0 0 0 0 0 0 0 0 0 0
49465 - 0 0 0 0 0 0 0 0 0 0 0 0
49466 - 0 0 0 0 0 0 0 0 0 0 0 0
49467 - 0 0 0 0 0 0 0 0 0 0 0 0
49468 - 0 0 0 0 0 0 0 0 0 0 0 0
49469 - 0 0 0 0 0 0 0 0 0 0 0 0
49470 - 0 0 1 0 0 0 0 0 1 0 0 0
49471 - 0 0 0 0 0 0 0 0 0 0 0 0
49472 - 0 0 0 0 0 0 0 0 0 0 0 0
49473 - 0 0 0 0 0 0 0 0 0 0 0 0
49474 - 0 0 0 0 0 0 0 0 0 0 0 0
49475 - 0 0 0 0 0 0 0 0 0 0 0 0
49476 - 10 10 10 30 30 30 66 66 66 58 58 58
49477 - 2 2 6 2 2 6 2 2 6 2 2 6
49478 - 2 2 6 2 2 6 2 2 6 2 2 6
49479 - 2 2 6 2 2 6 2 2 6 26 26 26
49480 - 86 86 86 101 101 101 46 46 46 10 10 10
49481 - 2 2 6 58 58 58 70 70 70 34 34 34
49482 - 10 10 10 0 0 0 0 0 0 0 0 0
49483 - 0 0 0 0 0 0 0 0 0 0 0 0
49484 - 0 0 0 0 0 0 0 0 0 0 0 0
49485 - 0 0 0 0 0 0 0 0 0 0 0 0
49486 - 0 0 0 0 0 0 0 0 0 0 0 0
49487 - 0 0 0 0 0 0 0 0 0 0 0 0
49488 - 0 0 0 0 0 0 0 0 0 0 0 0
49489 - 0 0 0 0 0 0 0 0 0 0 0 0
49490 - 0 0 1 0 0 1 0 0 1 0 0 0
49491 - 0 0 0 0 0 0 0 0 0 0 0 0
49492 - 0 0 0 0 0 0 0 0 0 0 0 0
49493 - 0 0 0 0 0 0 0 0 0 0 0 0
49494 - 0 0 0 0 0 0 0 0 0 0 0 0
49495 - 0 0 0 0 0 0 0 0 0 0 0 0
49496 - 14 14 14 42 42 42 86 86 86 10 10 10
49497 - 2 2 6 2 2 6 2 2 6 2 2 6
49498 - 2 2 6 2 2 6 2 2 6 2 2 6
49499 - 2 2 6 2 2 6 2 2 6 30 30 30
49500 - 94 94 94 94 94 94 58 58 58 26 26 26
49501 - 2 2 6 6 6 6 78 78 78 54 54 54
49502 - 22 22 22 6 6 6 0 0 0 0 0 0
49503 - 0 0 0 0 0 0 0 0 0 0 0 0
49504 - 0 0 0 0 0 0 0 0 0 0 0 0
49505 - 0 0 0 0 0 0 0 0 0 0 0 0
49506 - 0 0 0 0 0 0 0 0 0 0 0 0
49507 - 0 0 0 0 0 0 0 0 0 0 0 0
49508 - 0 0 0 0 0 0 0 0 0 0 0 0
49509 - 0 0 0 0 0 0 0 0 0 0 0 0
49510 - 0 0 0 0 0 0 0 0 0 0 0 0
49511 - 0 0 0 0 0 0 0 0 0 0 0 0
49512 - 0 0 0 0 0 0 0 0 0 0 0 0
49513 - 0 0 0 0 0 0 0 0 0 0 0 0
49514 - 0 0 0 0 0 0 0 0 0 0 0 0
49515 - 0 0 0 0 0 0 0 0 0 6 6 6
49516 - 22 22 22 62 62 62 62 62 62 2 2 6
49517 - 2 2 6 2 2 6 2 2 6 2 2 6
49518 - 2 2 6 2 2 6 2 2 6 2 2 6
49519 - 2 2 6 2 2 6 2 2 6 26 26 26
49520 - 54 54 54 38 38 38 18 18 18 10 10 10
49521 - 2 2 6 2 2 6 34 34 34 82 82 82
49522 - 38 38 38 14 14 14 0 0 0 0 0 0
49523 - 0 0 0 0 0 0 0 0 0 0 0 0
49524 - 0 0 0 0 0 0 0 0 0 0 0 0
49525 - 0 0 0 0 0 0 0 0 0 0 0 0
49526 - 0 0 0 0 0 0 0 0 0 0 0 0
49527 - 0 0 0 0 0 0 0 0 0 0 0 0
49528 - 0 0 0 0 0 0 0 0 0 0 0 0
49529 - 0 0 0 0 0 0 0 0 0 0 0 0
49530 - 0 0 0 0 0 1 0 0 1 0 0 0
49531 - 0 0 0 0 0 0 0 0 0 0 0 0
49532 - 0 0 0 0 0 0 0 0 0 0 0 0
49533 - 0 0 0 0 0 0 0 0 0 0 0 0
49534 - 0 0 0 0 0 0 0 0 0 0 0 0
49535 - 0 0 0 0 0 0 0 0 0 6 6 6
49536 - 30 30 30 78 78 78 30 30 30 2 2 6
49537 - 2 2 6 2 2 6 2 2 6 2 2 6
49538 - 2 2 6 2 2 6 2 2 6 2 2 6
49539 - 2 2 6 2 2 6 2 2 6 10 10 10
49540 - 10 10 10 2 2 6 2 2 6 2 2 6
49541 - 2 2 6 2 2 6 2 2 6 78 78 78
49542 - 50 50 50 18 18 18 6 6 6 0 0 0
49543 - 0 0 0 0 0 0 0 0 0 0 0 0
49544 - 0 0 0 0 0 0 0 0 0 0 0 0
49545 - 0 0 0 0 0 0 0 0 0 0 0 0
49546 - 0 0 0 0 0 0 0 0 0 0 0 0
49547 - 0 0 0 0 0 0 0 0 0 0 0 0
49548 - 0 0 0 0 0 0 0 0 0 0 0 0
49549 - 0 0 0 0 0 0 0 0 0 0 0 0
49550 - 0 0 1 0 0 0 0 0 0 0 0 0
49551 - 0 0 0 0 0 0 0 0 0 0 0 0
49552 - 0 0 0 0 0 0 0 0 0 0 0 0
49553 - 0 0 0 0 0 0 0 0 0 0 0 0
49554 - 0 0 0 0 0 0 0 0 0 0 0 0
49555 - 0 0 0 0 0 0 0 0 0 10 10 10
49556 - 38 38 38 86 86 86 14 14 14 2 2 6
49557 - 2 2 6 2 2 6 2 2 6 2 2 6
49558 - 2 2 6 2 2 6 2 2 6 2 2 6
49559 - 2 2 6 2 2 6 2 2 6 2 2 6
49560 - 2 2 6 2 2 6 2 2 6 2 2 6
49561 - 2 2 6 2 2 6 2 2 6 54 54 54
49562 - 66 66 66 26 26 26 6 6 6 0 0 0
49563 - 0 0 0 0 0 0 0 0 0 0 0 0
49564 - 0 0 0 0 0 0 0 0 0 0 0 0
49565 - 0 0 0 0 0 0 0 0 0 0 0 0
49566 - 0 0 0 0 0 0 0 0 0 0 0 0
49567 - 0 0 0 0 0 0 0 0 0 0 0 0
49568 - 0 0 0 0 0 0 0 0 0 0 0 0
49569 - 0 0 0 0 0 0 0 0 0 0 0 0
49570 - 0 0 0 0 0 1 0 0 1 0 0 0
49571 - 0 0 0 0 0 0 0 0 0 0 0 0
49572 - 0 0 0 0 0 0 0 0 0 0 0 0
49573 - 0 0 0 0 0 0 0 0 0 0 0 0
49574 - 0 0 0 0 0 0 0 0 0 0 0 0
49575 - 0 0 0 0 0 0 0 0 0 14 14 14
49576 - 42 42 42 82 82 82 2 2 6 2 2 6
49577 - 2 2 6 6 6 6 10 10 10 2 2 6
49578 - 2 2 6 2 2 6 2 2 6 2 2 6
49579 - 2 2 6 2 2 6 2 2 6 6 6 6
49580 - 14 14 14 10 10 10 2 2 6 2 2 6
49581 - 2 2 6 2 2 6 2 2 6 18 18 18
49582 - 82 82 82 34 34 34 10 10 10 0 0 0
49583 - 0 0 0 0 0 0 0 0 0 0 0 0
49584 - 0 0 0 0 0 0 0 0 0 0 0 0
49585 - 0 0 0 0 0 0 0 0 0 0 0 0
49586 - 0 0 0 0 0 0 0 0 0 0 0 0
49587 - 0 0 0 0 0 0 0 0 0 0 0 0
49588 - 0 0 0 0 0 0 0 0 0 0 0 0
49589 - 0 0 0 0 0 0 0 0 0 0 0 0
49590 - 0 0 1 0 0 0 0 0 0 0 0 0
49591 - 0 0 0 0 0 0 0 0 0 0 0 0
49592 - 0 0 0 0 0 0 0 0 0 0 0 0
49593 - 0 0 0 0 0 0 0 0 0 0 0 0
49594 - 0 0 0 0 0 0 0 0 0 0 0 0
49595 - 0 0 0 0 0 0 0 0 0 14 14 14
49596 - 46 46 46 86 86 86 2 2 6 2 2 6
49597 - 6 6 6 6 6 6 22 22 22 34 34 34
49598 - 6 6 6 2 2 6 2 2 6 2 2 6
49599 - 2 2 6 2 2 6 18 18 18 34 34 34
49600 - 10 10 10 50 50 50 22 22 22 2 2 6
49601 - 2 2 6 2 2 6 2 2 6 10 10 10
49602 - 86 86 86 42 42 42 14 14 14 0 0 0
49603 - 0 0 0 0 0 0 0 0 0 0 0 0
49604 - 0 0 0 0 0 0 0 0 0 0 0 0
49605 - 0 0 0 0 0 0 0 0 0 0 0 0
49606 - 0 0 0 0 0 0 0 0 0 0 0 0
49607 - 0 0 0 0 0 0 0 0 0 0 0 0
49608 - 0 0 0 0 0 0 0 0 0 0 0 0
49609 - 0 0 0 0 0 0 0 0 0 0 0 0
49610 - 0 0 1 0 0 1 0 0 1 0 0 0
49611 - 0 0 0 0 0 0 0 0 0 0 0 0
49612 - 0 0 0 0 0 0 0 0 0 0 0 0
49613 - 0 0 0 0 0 0 0 0 0 0 0 0
49614 - 0 0 0 0 0 0 0 0 0 0 0 0
49615 - 0 0 0 0 0 0 0 0 0 14 14 14
49616 - 46 46 46 86 86 86 2 2 6 2 2 6
49617 - 38 38 38 116 116 116 94 94 94 22 22 22
49618 - 22 22 22 2 2 6 2 2 6 2 2 6
49619 - 14 14 14 86 86 86 138 138 138 162 162 162
49620 -154 154 154 38 38 38 26 26 26 6 6 6
49621 - 2 2 6 2 2 6 2 2 6 2 2 6
49622 - 86 86 86 46 46 46 14 14 14 0 0 0
49623 - 0 0 0 0 0 0 0 0 0 0 0 0
49624 - 0 0 0 0 0 0 0 0 0 0 0 0
49625 - 0 0 0 0 0 0 0 0 0 0 0 0
49626 - 0 0 0 0 0 0 0 0 0 0 0 0
49627 - 0 0 0 0 0 0 0 0 0 0 0 0
49628 - 0 0 0 0 0 0 0 0 0 0 0 0
49629 - 0 0 0 0 0 0 0 0 0 0 0 0
49630 - 0 0 0 0 0 0 0 0 0 0 0 0
49631 - 0 0 0 0 0 0 0 0 0 0 0 0
49632 - 0 0 0 0 0 0 0 0 0 0 0 0
49633 - 0 0 0 0 0 0 0 0 0 0 0 0
49634 - 0 0 0 0 0 0 0 0 0 0 0 0
49635 - 0 0 0 0 0 0 0 0 0 14 14 14
49636 - 46 46 46 86 86 86 2 2 6 14 14 14
49637 -134 134 134 198 198 198 195 195 195 116 116 116
49638 - 10 10 10 2 2 6 2 2 6 6 6 6
49639 -101 98 89 187 187 187 210 210 210 218 218 218
49640 -214 214 214 134 134 134 14 14 14 6 6 6
49641 - 2 2 6 2 2 6 2 2 6 2 2 6
49642 - 86 86 86 50 50 50 18 18 18 6 6 6
49643 - 0 0 0 0 0 0 0 0 0 0 0 0
49644 - 0 0 0 0 0 0 0 0 0 0 0 0
49645 - 0 0 0 0 0 0 0 0 0 0 0 0
49646 - 0 0 0 0 0 0 0 0 0 0 0 0
49647 - 0 0 0 0 0 0 0 0 0 0 0 0
49648 - 0 0 0 0 0 0 0 0 0 0 0 0
49649 - 0 0 0 0 0 0 0 0 1 0 0 0
49650 - 0 0 1 0 0 1 0 0 1 0 0 0
49651 - 0 0 0 0 0 0 0 0 0 0 0 0
49652 - 0 0 0 0 0 0 0 0 0 0 0 0
49653 - 0 0 0 0 0 0 0 0 0 0 0 0
49654 - 0 0 0 0 0 0 0 0 0 0 0 0
49655 - 0 0 0 0 0 0 0 0 0 14 14 14
49656 - 46 46 46 86 86 86 2 2 6 54 54 54
49657 -218 218 218 195 195 195 226 226 226 246 246 246
49658 - 58 58 58 2 2 6 2 2 6 30 30 30
49659 -210 210 210 253 253 253 174 174 174 123 123 123
49660 -221 221 221 234 234 234 74 74 74 2 2 6
49661 - 2 2 6 2 2 6 2 2 6 2 2 6
49662 - 70 70 70 58 58 58 22 22 22 6 6 6
49663 - 0 0 0 0 0 0 0 0 0 0 0 0
49664 - 0 0 0 0 0 0 0 0 0 0 0 0
49665 - 0 0 0 0 0 0 0 0 0 0 0 0
49666 - 0 0 0 0 0 0 0 0 0 0 0 0
49667 - 0 0 0 0 0 0 0 0 0 0 0 0
49668 - 0 0 0 0 0 0 0 0 0 0 0 0
49669 - 0 0 0 0 0 0 0 0 0 0 0 0
49670 - 0 0 0 0 0 0 0 0 0 0 0 0
49671 - 0 0 0 0 0 0 0 0 0 0 0 0
49672 - 0 0 0 0 0 0 0 0 0 0 0 0
49673 - 0 0 0 0 0 0 0 0 0 0 0 0
49674 - 0 0 0 0 0 0 0 0 0 0 0 0
49675 - 0 0 0 0 0 0 0 0 0 14 14 14
49676 - 46 46 46 82 82 82 2 2 6 106 106 106
49677 -170 170 170 26 26 26 86 86 86 226 226 226
49678 -123 123 123 10 10 10 14 14 14 46 46 46
49679 -231 231 231 190 190 190 6 6 6 70 70 70
49680 - 90 90 90 238 238 238 158 158 158 2 2 6
49681 - 2 2 6 2 2 6 2 2 6 2 2 6
49682 - 70 70 70 58 58 58 22 22 22 6 6 6
49683 - 0 0 0 0 0 0 0 0 0 0 0 0
49684 - 0 0 0 0 0 0 0 0 0 0 0 0
49685 - 0 0 0 0 0 0 0 0 0 0 0 0
49686 - 0 0 0 0 0 0 0 0 0 0 0 0
49687 - 0 0 0 0 0 0 0 0 0 0 0 0
49688 - 0 0 0 0 0 0 0 0 0 0 0 0
49689 - 0 0 0 0 0 0 0 0 1 0 0 0
49690 - 0 0 1 0 0 1 0 0 1 0 0 0
49691 - 0 0 0 0 0 0 0 0 0 0 0 0
49692 - 0 0 0 0 0 0 0 0 0 0 0 0
49693 - 0 0 0 0 0 0 0 0 0 0 0 0
49694 - 0 0 0 0 0 0 0 0 0 0 0 0
49695 - 0 0 0 0 0 0 0 0 0 14 14 14
49696 - 42 42 42 86 86 86 6 6 6 116 116 116
49697 -106 106 106 6 6 6 70 70 70 149 149 149
49698 -128 128 128 18 18 18 38 38 38 54 54 54
49699 -221 221 221 106 106 106 2 2 6 14 14 14
49700 - 46 46 46 190 190 190 198 198 198 2 2 6
49701 - 2 2 6 2 2 6 2 2 6 2 2 6
49702 - 74 74 74 62 62 62 22 22 22 6 6 6
49703 - 0 0 0 0 0 0 0 0 0 0 0 0
49704 - 0 0 0 0 0 0 0 0 0 0 0 0
49705 - 0 0 0 0 0 0 0 0 0 0 0 0
49706 - 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
49708 - 0 0 0 0 0 0 0 0 0 0 0 0
49709 - 0 0 0 0 0 0 0 0 1 0 0 0
49710 - 0 0 1 0 0 0 0 0 1 0 0 0
49711 - 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
49713 - 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
49715 - 0 0 0 0 0 0 0 0 0 14 14 14
49716 - 42 42 42 94 94 94 14 14 14 101 101 101
49717 -128 128 128 2 2 6 18 18 18 116 116 116
49718 -118 98 46 121 92 8 121 92 8 98 78 10
49719 -162 162 162 106 106 106 2 2 6 2 2 6
49720 - 2 2 6 195 195 195 195 195 195 6 6 6
49721 - 2 2 6 2 2 6 2 2 6 2 2 6
49722 - 74 74 74 62 62 62 22 22 22 6 6 6
49723 - 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
49725 - 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
49727 - 0 0 0 0 0 0 0 0 0 0 0 0
49728 - 0 0 0 0 0 0 0 0 0 0 0 0
49729 - 0 0 0 0 0 0 0 0 1 0 0 1
49730 - 0 0 1 0 0 0 0 0 1 0 0 0
49731 - 0 0 0 0 0 0 0 0 0 0 0 0
49732 - 0 0 0 0 0 0 0 0 0 0 0 0
49733 - 0 0 0 0 0 0 0 0 0 0 0 0
49734 - 0 0 0 0 0 0 0 0 0 0 0 0
49735 - 0 0 0 0 0 0 0 0 0 10 10 10
49736 - 38 38 38 90 90 90 14 14 14 58 58 58
49737 -210 210 210 26 26 26 54 38 6 154 114 10
49738 -226 170 11 236 186 11 225 175 15 184 144 12
49739 -215 174 15 175 146 61 37 26 9 2 2 6
49740 - 70 70 70 246 246 246 138 138 138 2 2 6
49741 - 2 2 6 2 2 6 2 2 6 2 2 6
49742 - 70 70 70 66 66 66 26 26 26 6 6 6
49743 - 0 0 0 0 0 0 0 0 0 0 0 0
49744 - 0 0 0 0 0 0 0 0 0 0 0 0
49745 - 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
49747 - 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
49749 - 0 0 0 0 0 0 0 0 0 0 0 0
49750 - 0 0 0 0 0 0 0 0 0 0 0 0
49751 - 0 0 0 0 0 0 0 0 0 0 0 0
49752 - 0 0 0 0 0 0 0 0 0 0 0 0
49753 - 0 0 0 0 0 0 0 0 0 0 0 0
49754 - 0 0 0 0 0 0 0 0 0 0 0 0
49755 - 0 0 0 0 0 0 0 0 0 10 10 10
49756 - 38 38 38 86 86 86 14 14 14 10 10 10
49757 -195 195 195 188 164 115 192 133 9 225 175 15
49758 -239 182 13 234 190 10 232 195 16 232 200 30
49759 -245 207 45 241 208 19 232 195 16 184 144 12
49760 -218 194 134 211 206 186 42 42 42 2 2 6
49761 - 2 2 6 2 2 6 2 2 6 2 2 6
49762 - 50 50 50 74 74 74 30 30 30 6 6 6
49763 - 0 0 0 0 0 0 0 0 0 0 0 0
49764 - 0 0 0 0 0 0 0 0 0 0 0 0
49765 - 0 0 0 0 0 0 0 0 0 0 0 0
49766 - 0 0 0 0 0 0 0 0 0 0 0 0
49767 - 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
49769 - 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
49771 - 0 0 0 0 0 0 0 0 0 0 0 0
49772 - 0 0 0 0 0 0 0 0 0 0 0 0
49773 - 0 0 0 0 0 0 0 0 0 0 0 0
49774 - 0 0 0 0 0 0 0 0 0 0 0 0
49775 - 0 0 0 0 0 0 0 0 0 10 10 10
49776 - 34 34 34 86 86 86 14 14 14 2 2 6
49777 -121 87 25 192 133 9 219 162 10 239 182 13
49778 -236 186 11 232 195 16 241 208 19 244 214 54
49779 -246 218 60 246 218 38 246 215 20 241 208 19
49780 -241 208 19 226 184 13 121 87 25 2 2 6
49781 - 2 2 6 2 2 6 2 2 6 2 2 6
49782 - 50 50 50 82 82 82 34 34 34 10 10 10
49783 - 0 0 0 0 0 0 0 0 0 0 0 0
49784 - 0 0 0 0 0 0 0 0 0 0 0 0
49785 - 0 0 0 0 0 0 0 0 0 0 0 0
49786 - 0 0 0 0 0 0 0 0 0 0 0 0
49787 - 0 0 0 0 0 0 0 0 0 0 0 0
49788 - 0 0 0 0 0 0 0 0 0 0 0 0
49789 - 0 0 0 0 0 0 0 0 0 0 0 0
49790 - 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
49792 - 0 0 0 0 0 0 0 0 0 0 0 0
49793 - 0 0 0 0 0 0 0 0 0 0 0 0
49794 - 0 0 0 0 0 0 0 0 0 0 0 0
49795 - 0 0 0 0 0 0 0 0 0 10 10 10
49796 - 34 34 34 82 82 82 30 30 30 61 42 6
49797 -180 123 7 206 145 10 230 174 11 239 182 13
49798 -234 190 10 238 202 15 241 208 19 246 218 74
49799 -246 218 38 246 215 20 246 215 20 246 215 20
49800 -226 184 13 215 174 15 184 144 12 6 6 6
49801 - 2 2 6 2 2 6 2 2 6 2 2 6
49802 - 26 26 26 94 94 94 42 42 42 14 14 14
49803 - 0 0 0 0 0 0 0 0 0 0 0 0
49804 - 0 0 0 0 0 0 0 0 0 0 0 0
49805 - 0 0 0 0 0 0 0 0 0 0 0 0
49806 - 0 0 0 0 0 0 0 0 0 0 0 0
49807 - 0 0 0 0 0 0 0 0 0 0 0 0
49808 - 0 0 0 0 0 0 0 0 0 0 0 0
49809 - 0 0 0 0 0 0 0 0 0 0 0 0
49810 - 0 0 0 0 0 0 0 0 0 0 0 0
49811 - 0 0 0 0 0 0 0 0 0 0 0 0
49812 - 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
49814 - 0 0 0 0 0 0 0 0 0 0 0 0
49815 - 0 0 0 0 0 0 0 0 0 10 10 10
49816 - 30 30 30 78 78 78 50 50 50 104 69 6
49817 -192 133 9 216 158 10 236 178 12 236 186 11
49818 -232 195 16 241 208 19 244 214 54 245 215 43
49819 -246 215 20 246 215 20 241 208 19 198 155 10
49820 -200 144 11 216 158 10 156 118 10 2 2 6
49821 - 2 2 6 2 2 6 2 2 6 2 2 6
49822 - 6 6 6 90 90 90 54 54 54 18 18 18
49823 - 6 6 6 0 0 0 0 0 0 0 0 0
49824 - 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
49826 - 0 0 0 0 0 0 0 0 0 0 0 0
49827 - 0 0 0 0 0 0 0 0 0 0 0 0
49828 - 0 0 0 0 0 0 0 0 0 0 0 0
49829 - 0 0 0 0 0 0 0 0 0 0 0 0
49830 - 0 0 0 0 0 0 0 0 0 0 0 0
49831 - 0 0 0 0 0 0 0 0 0 0 0 0
49832 - 0 0 0 0 0 0 0 0 0 0 0 0
49833 - 0 0 0 0 0 0 0 0 0 0 0 0
49834 - 0 0 0 0 0 0 0 0 0 0 0 0
49835 - 0 0 0 0 0 0 0 0 0 10 10 10
49836 - 30 30 30 78 78 78 46 46 46 22 22 22
49837 -137 92 6 210 162 10 239 182 13 238 190 10
49838 -238 202 15 241 208 19 246 215 20 246 215 20
49839 -241 208 19 203 166 17 185 133 11 210 150 10
49840 -216 158 10 210 150 10 102 78 10 2 2 6
49841 - 6 6 6 54 54 54 14 14 14 2 2 6
49842 - 2 2 6 62 62 62 74 74 74 30 30 30
49843 - 10 10 10 0 0 0 0 0 0 0 0 0
49844 - 0 0 0 0 0 0 0 0 0 0 0 0
49845 - 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
49847 - 0 0 0 0 0 0 0 0 0 0 0 0
49848 - 0 0 0 0 0 0 0 0 0 0 0 0
49849 - 0 0 0 0 0 0 0 0 0 0 0 0
49850 - 0 0 0 0 0 0 0 0 0 0 0 0
49851 - 0 0 0 0 0 0 0 0 0 0 0 0
49852 - 0 0 0 0 0 0 0 0 0 0 0 0
49853 - 0 0 0 0 0 0 0 0 0 0 0 0
49854 - 0 0 0 0 0 0 0 0 0 0 0 0
49855 - 0 0 0 0 0 0 0 0 0 10 10 10
49856 - 34 34 34 78 78 78 50 50 50 6 6 6
49857 - 94 70 30 139 102 15 190 146 13 226 184 13
49858 -232 200 30 232 195 16 215 174 15 190 146 13
49859 -168 122 10 192 133 9 210 150 10 213 154 11
49860 -202 150 34 182 157 106 101 98 89 2 2 6
49861 - 2 2 6 78 78 78 116 116 116 58 58 58
49862 - 2 2 6 22 22 22 90 90 90 46 46 46
49863 - 18 18 18 6 6 6 0 0 0 0 0 0
49864 - 0 0 0 0 0 0 0 0 0 0 0 0
49865 - 0 0 0 0 0 0 0 0 0 0 0 0
49866 - 0 0 0 0 0 0 0 0 0 0 0 0
49867 - 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
49869 - 0 0 0 0 0 0 0 0 0 0 0 0
49870 - 0 0 0 0 0 0 0 0 0 0 0 0
49871 - 0 0 0 0 0 0 0 0 0 0 0 0
49872 - 0 0 0 0 0 0 0 0 0 0 0 0
49873 - 0 0 0 0 0 0 0 0 0 0 0 0
49874 - 0 0 0 0 0 0 0 0 0 0 0 0
49875 - 0 0 0 0 0 0 0 0 0 10 10 10
49876 - 38 38 38 86 86 86 50 50 50 6 6 6
49877 -128 128 128 174 154 114 156 107 11 168 122 10
49878 -198 155 10 184 144 12 197 138 11 200 144 11
49879 -206 145 10 206 145 10 197 138 11 188 164 115
49880 -195 195 195 198 198 198 174 174 174 14 14 14
49881 - 2 2 6 22 22 22 116 116 116 116 116 116
49882 - 22 22 22 2 2 6 74 74 74 70 70 70
49883 - 30 30 30 10 10 10 0 0 0 0 0 0
49884 - 0 0 0 0 0 0 0 0 0 0 0 0
49885 - 0 0 0 0 0 0 0 0 0 0 0 0
49886 - 0 0 0 0 0 0 0 0 0 0 0 0
49887 - 0 0 0 0 0 0 0 0 0 0 0 0
49888 - 0 0 0 0 0 0 0 0 0 0 0 0
49889 - 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
49891 - 0 0 0 0 0 0 0 0 0 0 0 0
49892 - 0 0 0 0 0 0 0 0 0 0 0 0
49893 - 0 0 0 0 0 0 0 0 0 0 0 0
49894 - 0 0 0 0 0 0 0 0 0 0 0 0
49895 - 0 0 0 0 0 0 6 6 6 18 18 18
49896 - 50 50 50 101 101 101 26 26 26 10 10 10
49897 -138 138 138 190 190 190 174 154 114 156 107 11
49898 -197 138 11 200 144 11 197 138 11 192 133 9
49899 -180 123 7 190 142 34 190 178 144 187 187 187
49900 -202 202 202 221 221 221 214 214 214 66 66 66
49901 - 2 2 6 2 2 6 50 50 50 62 62 62
49902 - 6 6 6 2 2 6 10 10 10 90 90 90
49903 - 50 50 50 18 18 18 6 6 6 0 0 0
49904 - 0 0 0 0 0 0 0 0 0 0 0 0
49905 - 0 0 0 0 0 0 0 0 0 0 0 0
49906 - 0 0 0 0 0 0 0 0 0 0 0 0
49907 - 0 0 0 0 0 0 0 0 0 0 0 0
49908 - 0 0 0 0 0 0 0 0 0 0 0 0
49909 - 0 0 0 0 0 0 0 0 0 0 0 0
49910 - 0 0 0 0 0 0 0 0 0 0 0 0
49911 - 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
49913 - 0 0 0 0 0 0 0 0 0 0 0 0
49914 - 0 0 0 0 0 0 0 0 0 0 0 0
49915 - 0 0 0 0 0 0 10 10 10 34 34 34
49916 - 74 74 74 74 74 74 2 2 6 6 6 6
49917 -144 144 144 198 198 198 190 190 190 178 166 146
49918 -154 121 60 156 107 11 156 107 11 168 124 44
49919 -174 154 114 187 187 187 190 190 190 210 210 210
49920 -246 246 246 253 253 253 253 253 253 182 182 182
49921 - 6 6 6 2 2 6 2 2 6 2 2 6
49922 - 2 2 6 2 2 6 2 2 6 62 62 62
49923 - 74 74 74 34 34 34 14 14 14 0 0 0
49924 - 0 0 0 0 0 0 0 0 0 0 0 0
49925 - 0 0 0 0 0 0 0 0 0 0 0 0
49926 - 0 0 0 0 0 0 0 0 0 0 0 0
49927 - 0 0 0 0 0 0 0 0 0 0 0 0
49928 - 0 0 0 0 0 0 0 0 0 0 0 0
49929 - 0 0 0 0 0 0 0 0 0 0 0 0
49930 - 0 0 0 0 0 0 0 0 0 0 0 0
49931 - 0 0 0 0 0 0 0 0 0 0 0 0
49932 - 0 0 0 0 0 0 0 0 0 0 0 0
49933 - 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
49935 - 0 0 0 10 10 10 22 22 22 54 54 54
49936 - 94 94 94 18 18 18 2 2 6 46 46 46
49937 -234 234 234 221 221 221 190 190 190 190 190 190
49938 -190 190 190 187 187 187 187 187 187 190 190 190
49939 -190 190 190 195 195 195 214 214 214 242 242 242
49940 -253 253 253 253 253 253 253 253 253 253 253 253
49941 - 82 82 82 2 2 6 2 2 6 2 2 6
49942 - 2 2 6 2 2 6 2 2 6 14 14 14
49943 - 86 86 86 54 54 54 22 22 22 6 6 6
49944 - 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
49946 - 0 0 0 0 0 0 0 0 0 0 0 0
49947 - 0 0 0 0 0 0 0 0 0 0 0 0
49948 - 0 0 0 0 0 0 0 0 0 0 0 0
49949 - 0 0 0 0 0 0 0 0 0 0 0 0
49950 - 0 0 0 0 0 0 0 0 0 0 0 0
49951 - 0 0 0 0 0 0 0 0 0 0 0 0
49952 - 0 0 0 0 0 0 0 0 0 0 0 0
49953 - 0 0 0 0 0 0 0 0 0 0 0 0
49954 - 0 0 0 0 0 0 0 0 0 0 0 0
49955 - 6 6 6 18 18 18 46 46 46 90 90 90
49956 - 46 46 46 18 18 18 6 6 6 182 182 182
49957 -253 253 253 246 246 246 206 206 206 190 190 190
49958 -190 190 190 190 190 190 190 190 190 190 190 190
49959 -206 206 206 231 231 231 250 250 250 253 253 253
49960 -253 253 253 253 253 253 253 253 253 253 253 253
49961 -202 202 202 14 14 14 2 2 6 2 2 6
49962 - 2 2 6 2 2 6 2 2 6 2 2 6
49963 - 42 42 42 86 86 86 42 42 42 18 18 18
49964 - 6 6 6 0 0 0 0 0 0 0 0 0
49965 - 0 0 0 0 0 0 0 0 0 0 0 0
49966 - 0 0 0 0 0 0 0 0 0 0 0 0
49967 - 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
49969 - 0 0 0 0 0 0 0 0 0 0 0 0
49970 - 0 0 0 0 0 0 0 0 0 0 0 0
49971 - 0 0 0 0 0 0 0 0 0 0 0 0
49972 - 0 0 0 0 0 0 0 0 0 0 0 0
49973 - 0 0 0 0 0 0 0 0 0 0 0 0
49974 - 0 0 0 0 0 0 0 0 0 6 6 6
49975 - 14 14 14 38 38 38 74 74 74 66 66 66
49976 - 2 2 6 6 6 6 90 90 90 250 250 250
49977 -253 253 253 253 253 253 238 238 238 198 198 198
49978 -190 190 190 190 190 190 195 195 195 221 221 221
49979 -246 246 246 253 253 253 253 253 253 253 253 253
49980 -253 253 253 253 253 253 253 253 253 253 253 253
49981 -253 253 253 82 82 82 2 2 6 2 2 6
49982 - 2 2 6 2 2 6 2 2 6 2 2 6
49983 - 2 2 6 78 78 78 70 70 70 34 34 34
49984 - 14 14 14 6 6 6 0 0 0 0 0 0
49985 - 0 0 0 0 0 0 0 0 0 0 0 0
49986 - 0 0 0 0 0 0 0 0 0 0 0 0
49987 - 0 0 0 0 0 0 0 0 0 0 0 0
49988 - 0 0 0 0 0 0 0 0 0 0 0 0
49989 - 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
49991 - 0 0 0 0 0 0 0 0 0 0 0 0
49992 - 0 0 0 0 0 0 0 0 0 0 0 0
49993 - 0 0 0 0 0 0 0 0 0 0 0 0
49994 - 0 0 0 0 0 0 0 0 0 14 14 14
49995 - 34 34 34 66 66 66 78 78 78 6 6 6
49996 - 2 2 6 18 18 18 218 218 218 253 253 253
49997 -253 253 253 253 253 253 253 253 253 246 246 246
49998 -226 226 226 231 231 231 246 246 246 253 253 253
49999 -253 253 253 253 253 253 253 253 253 253 253 253
50000 -253 253 253 253 253 253 253 253 253 253 253 253
50001 -253 253 253 178 178 178 2 2 6 2 2 6
50002 - 2 2 6 2 2 6 2 2 6 2 2 6
50003 - 2 2 6 18 18 18 90 90 90 62 62 62
50004 - 30 30 30 10 10 10 0 0 0 0 0 0
50005 - 0 0 0 0 0 0 0 0 0 0 0 0
50006 - 0 0 0 0 0 0 0 0 0 0 0 0
50007 - 0 0 0 0 0 0 0 0 0 0 0 0
50008 - 0 0 0 0 0 0 0 0 0 0 0 0
50009 - 0 0 0 0 0 0 0 0 0 0 0 0
50010 - 0 0 0 0 0 0 0 0 0 0 0 0
50011 - 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
50013 - 0 0 0 0 0 0 0 0 0 0 0 0
50014 - 0 0 0 0 0 0 10 10 10 26 26 26
50015 - 58 58 58 90 90 90 18 18 18 2 2 6
50016 - 2 2 6 110 110 110 253 253 253 253 253 253
50017 -253 253 253 253 253 253 253 253 253 253 253 253
50018 -250 250 250 253 253 253 253 253 253 253 253 253
50019 -253 253 253 253 253 253 253 253 253 253 253 253
50020 -253 253 253 253 253 253 253 253 253 253 253 253
50021 -253 253 253 231 231 231 18 18 18 2 2 6
50022 - 2 2 6 2 2 6 2 2 6 2 2 6
50023 - 2 2 6 2 2 6 18 18 18 94 94 94
50024 - 54 54 54 26 26 26 10 10 10 0 0 0
50025 - 0 0 0 0 0 0 0 0 0 0 0 0
50026 - 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
50028 - 0 0 0 0 0 0 0 0 0 0 0 0
50029 - 0 0 0 0 0 0 0 0 0 0 0 0
50030 - 0 0 0 0 0 0 0 0 0 0 0 0
50031 - 0 0 0 0 0 0 0 0 0 0 0 0
50032 - 0 0 0 0 0 0 0 0 0 0 0 0
50033 - 0 0 0 0 0 0 0 0 0 0 0 0
50034 - 0 0 0 6 6 6 22 22 22 50 50 50
50035 - 90 90 90 26 26 26 2 2 6 2 2 6
50036 - 14 14 14 195 195 195 250 250 250 253 253 253
50037 -253 253 253 253 253 253 253 253 253 253 253 253
50038 -253 253 253 253 253 253 253 253 253 253 253 253
50039 -253 253 253 253 253 253 253 253 253 253 253 253
50040 -253 253 253 253 253 253 253 253 253 253 253 253
50041 -250 250 250 242 242 242 54 54 54 2 2 6
50042 - 2 2 6 2 2 6 2 2 6 2 2 6
50043 - 2 2 6 2 2 6 2 2 6 38 38 38
50044 - 86 86 86 50 50 50 22 22 22 6 6 6
50045 - 0 0 0 0 0 0 0 0 0 0 0 0
50046 - 0 0 0 0 0 0 0 0 0 0 0 0
50047 - 0 0 0 0 0 0 0 0 0 0 0 0
50048 - 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
50050 - 0 0 0 0 0 0 0 0 0 0 0 0
50051 - 0 0 0 0 0 0 0 0 0 0 0 0
50052 - 0 0 0 0 0 0 0 0 0 0 0 0
50053 - 0 0 0 0 0 0 0 0 0 0 0 0
50054 - 6 6 6 14 14 14 38 38 38 82 82 82
50055 - 34 34 34 2 2 6 2 2 6 2 2 6
50056 - 42 42 42 195 195 195 246 246 246 253 253 253
50057 -253 253 253 253 253 253 253 253 253 250 250 250
50058 -242 242 242 242 242 242 250 250 250 253 253 253
50059 -253 253 253 253 253 253 253 253 253 253 253 253
50060 -253 253 253 250 250 250 246 246 246 238 238 238
50061 -226 226 226 231 231 231 101 101 101 6 6 6
50062 - 2 2 6 2 2 6 2 2 6 2 2 6
50063 - 2 2 6 2 2 6 2 2 6 2 2 6
50064 - 38 38 38 82 82 82 42 42 42 14 14 14
50065 - 6 6 6 0 0 0 0 0 0 0 0 0
50066 - 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
50068 - 0 0 0 0 0 0 0 0 0 0 0 0
50069 - 0 0 0 0 0 0 0 0 0 0 0 0
50070 - 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
50072 - 0 0 0 0 0 0 0 0 0 0 0 0
50073 - 0 0 0 0 0 0 0 0 0 0 0 0
50074 - 10 10 10 26 26 26 62 62 62 66 66 66
50075 - 2 2 6 2 2 6 2 2 6 6 6 6
50076 - 70 70 70 170 170 170 206 206 206 234 234 234
50077 -246 246 246 250 250 250 250 250 250 238 238 238
50078 -226 226 226 231 231 231 238 238 238 250 250 250
50079 -250 250 250 250 250 250 246 246 246 231 231 231
50080 -214 214 214 206 206 206 202 202 202 202 202 202
50081 -198 198 198 202 202 202 182 182 182 18 18 18
50082 - 2 2 6 2 2 6 2 2 6 2 2 6
50083 - 2 2 6 2 2 6 2 2 6 2 2 6
50084 - 2 2 6 62 62 62 66 66 66 30 30 30
50085 - 10 10 10 0 0 0 0 0 0 0 0 0
50086 - 0 0 0 0 0 0 0 0 0 0 0 0
50087 - 0 0 0 0 0 0 0 0 0 0 0 0
50088 - 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
50090 - 0 0 0 0 0 0 0 0 0 0 0 0
50091 - 0 0 0 0 0 0 0 0 0 0 0 0
50092 - 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
50094 - 14 14 14 42 42 42 82 82 82 18 18 18
50095 - 2 2 6 2 2 6 2 2 6 10 10 10
50096 - 94 94 94 182 182 182 218 218 218 242 242 242
50097 -250 250 250 253 253 253 253 253 253 250 250 250
50098 -234 234 234 253 253 253 253 253 253 253 253 253
50099 -253 253 253 253 253 253 253 253 253 246 246 246
50100 -238 238 238 226 226 226 210 210 210 202 202 202
50101 -195 195 195 195 195 195 210 210 210 158 158 158
50102 - 6 6 6 14 14 14 50 50 50 14 14 14
50103 - 2 2 6 2 2 6 2 2 6 2 2 6
50104 - 2 2 6 6 6 6 86 86 86 46 46 46
50105 - 18 18 18 6 6 6 0 0 0 0 0 0
50106 - 0 0 0 0 0 0 0 0 0 0 0 0
50107 - 0 0 0 0 0 0 0 0 0 0 0 0
50108 - 0 0 0 0 0 0 0 0 0 0 0 0
50109 - 0 0 0 0 0 0 0 0 0 0 0 0
50110 - 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
50112 - 0 0 0 0 0 0 0 0 0 0 0 0
50113 - 0 0 0 0 0 0 0 0 0 6 6 6
50114 - 22 22 22 54 54 54 70 70 70 2 2 6
50115 - 2 2 6 10 10 10 2 2 6 22 22 22
50116 -166 166 166 231 231 231 250 250 250 253 253 253
50117 -253 253 253 253 253 253 253 253 253 250 250 250
50118 -242 242 242 253 253 253 253 253 253 253 253 253
50119 -253 253 253 253 253 253 253 253 253 253 253 253
50120 -253 253 253 253 253 253 253 253 253 246 246 246
50121 -231 231 231 206 206 206 198 198 198 226 226 226
50122 - 94 94 94 2 2 6 6 6 6 38 38 38
50123 - 30 30 30 2 2 6 2 2 6 2 2 6
50124 - 2 2 6 2 2 6 62 62 62 66 66 66
50125 - 26 26 26 10 10 10 0 0 0 0 0 0
50126 - 0 0 0 0 0 0 0 0 0 0 0 0
50127 - 0 0 0 0 0 0 0 0 0 0 0 0
50128 - 0 0 0 0 0 0 0 0 0 0 0 0
50129 - 0 0 0 0 0 0 0 0 0 0 0 0
50130 - 0 0 0 0 0 0 0 0 0 0 0 0
50131 - 0 0 0 0 0 0 0 0 0 0 0 0
50132 - 0 0 0 0 0 0 0 0 0 0 0 0
50133 - 0 0 0 0 0 0 0 0 0 10 10 10
50134 - 30 30 30 74 74 74 50 50 50 2 2 6
50135 - 26 26 26 26 26 26 2 2 6 106 106 106
50136 -238 238 238 253 253 253 253 253 253 253 253 253
50137 -253 253 253 253 253 253 253 253 253 253 253 253
50138 -253 253 253 253 253 253 253 253 253 253 253 253
50139 -253 253 253 253 253 253 253 253 253 253 253 253
50140 -253 253 253 253 253 253 253 253 253 253 253 253
50141 -253 253 253 246 246 246 218 218 218 202 202 202
50142 -210 210 210 14 14 14 2 2 6 2 2 6
50143 - 30 30 30 22 22 22 2 2 6 2 2 6
50144 - 2 2 6 2 2 6 18 18 18 86 86 86
50145 - 42 42 42 14 14 14 0 0 0 0 0 0
50146 - 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
50148 - 0 0 0 0 0 0 0 0 0 0 0 0
50149 - 0 0 0 0 0 0 0 0 0 0 0 0
50150 - 0 0 0 0 0 0 0 0 0 0 0 0
50151 - 0 0 0 0 0 0 0 0 0 0 0 0
50152 - 0 0 0 0 0 0 0 0 0 0 0 0
50153 - 0 0 0 0 0 0 0 0 0 14 14 14
50154 - 42 42 42 90 90 90 22 22 22 2 2 6
50155 - 42 42 42 2 2 6 18 18 18 218 218 218
50156 -253 253 253 253 253 253 253 253 253 253 253 253
50157 -253 253 253 253 253 253 253 253 253 253 253 253
50158 -253 253 253 253 253 253 253 253 253 253 253 253
50159 -253 253 253 253 253 253 253 253 253 253 253 253
50160 -253 253 253 253 253 253 253 253 253 253 253 253
50161 -253 253 253 253 253 253 250 250 250 221 221 221
50162 -218 218 218 101 101 101 2 2 6 14 14 14
50163 - 18 18 18 38 38 38 10 10 10 2 2 6
50164 - 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
50166 - 0 0 0 0 0 0 0 0 0 0 0 0
50167 - 0 0 0 0 0 0 0 0 0 0 0 0
50168 - 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
50170 - 0 0 0 0 0 0 0 0 0 0 0 0
50171 - 0 0 0 0 0 0 0 0 0 0 0 0
50172 - 0 0 0 0 0 0 0 0 0 0 0 0
50173 - 0 0 0 0 0 0 6 6 6 18 18 18
50174 - 54 54 54 82 82 82 2 2 6 26 26 26
50175 - 22 22 22 2 2 6 123 123 123 253 253 253
50176 -253 253 253 253 253 253 253 253 253 253 253 253
50177 -253 253 253 253 253 253 253 253 253 253 253 253
50178 -253 253 253 253 253 253 253 253 253 253 253 253
50179 -253 253 253 253 253 253 253 253 253 253 253 253
50180 -253 253 253 253 253 253 253 253 253 253 253 253
50181 -253 253 253 253 253 253 253 253 253 250 250 250
50182 -238 238 238 198 198 198 6 6 6 38 38 38
50183 - 58 58 58 26 26 26 38 38 38 2 2 6
50184 - 2 2 6 2 2 6 2 2 6 46 46 46
50185 - 78 78 78 30 30 30 10 10 10 0 0 0
50186 - 0 0 0 0 0 0 0 0 0 0 0 0
50187 - 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
50189 - 0 0 0 0 0 0 0 0 0 0 0 0
50190 - 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
50192 - 0 0 0 0 0 0 0 0 0 0 0 0
50193 - 0 0 0 0 0 0 10 10 10 30 30 30
50194 - 74 74 74 58 58 58 2 2 6 42 42 42
50195 - 2 2 6 22 22 22 231 231 231 253 253 253
50196 -253 253 253 253 253 253 253 253 253 253 253 253
50197 -253 253 253 253 253 253 253 253 253 250 250 250
50198 -253 253 253 253 253 253 253 253 253 253 253 253
50199 -253 253 253 253 253 253 253 253 253 253 253 253
50200 -253 253 253 253 253 253 253 253 253 253 253 253
50201 -253 253 253 253 253 253 253 253 253 253 253 253
50202 -253 253 253 246 246 246 46 46 46 38 38 38
50203 - 42 42 42 14 14 14 38 38 38 14 14 14
50204 - 2 2 6 2 2 6 2 2 6 6 6 6
50205 - 86 86 86 46 46 46 14 14 14 0 0 0
50206 - 0 0 0 0 0 0 0 0 0 0 0 0
50207 - 0 0 0 0 0 0 0 0 0 0 0 0
50208 - 0 0 0 0 0 0 0 0 0 0 0 0
50209 - 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
50211 - 0 0 0 0 0 0 0 0 0 0 0 0
50212 - 0 0 0 0 0 0 0 0 0 0 0 0
50213 - 0 0 0 6 6 6 14 14 14 42 42 42
50214 - 90 90 90 18 18 18 18 18 18 26 26 26
50215 - 2 2 6 116 116 116 253 253 253 253 253 253
50216 -253 253 253 253 253 253 253 253 253 253 253 253
50217 -253 253 253 253 253 253 250 250 250 238 238 238
50218 -253 253 253 253 253 253 253 253 253 253 253 253
50219 -253 253 253 253 253 253 253 253 253 253 253 253
50220 -253 253 253 253 253 253 253 253 253 253 253 253
50221 -253 253 253 253 253 253 253 253 253 253 253 253
50222 -253 253 253 253 253 253 94 94 94 6 6 6
50223 - 2 2 6 2 2 6 10 10 10 34 34 34
50224 - 2 2 6 2 2 6 2 2 6 2 2 6
50225 - 74 74 74 58 58 58 22 22 22 6 6 6
50226 - 0 0 0 0 0 0 0 0 0 0 0 0
50227 - 0 0 0 0 0 0 0 0 0 0 0 0
50228 - 0 0 0 0 0 0 0 0 0 0 0 0
50229 - 0 0 0 0 0 0 0 0 0 0 0 0
50230 - 0 0 0 0 0 0 0 0 0 0 0 0
50231 - 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
50233 - 0 0 0 10 10 10 26 26 26 66 66 66
50234 - 82 82 82 2 2 6 38 38 38 6 6 6
50235 - 14 14 14 210 210 210 253 253 253 253 253 253
50236 -253 253 253 253 253 253 253 253 253 253 253 253
50237 -253 253 253 253 253 253 246 246 246 242 242 242
50238 -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
50240 -253 253 253 253 253 253 253 253 253 253 253 253
50241 -253 253 253 253 253 253 253 253 253 253 253 253
50242 -253 253 253 253 253 253 144 144 144 2 2 6
50243 - 2 2 6 2 2 6 2 2 6 46 46 46
50244 - 2 2 6 2 2 6 2 2 6 2 2 6
50245 - 42 42 42 74 74 74 30 30 30 10 10 10
50246 - 0 0 0 0 0 0 0 0 0 0 0 0
50247 - 0 0 0 0 0 0 0 0 0 0 0 0
50248 - 0 0 0 0 0 0 0 0 0 0 0 0
50249 - 0 0 0 0 0 0 0 0 0 0 0 0
50250 - 0 0 0 0 0 0 0 0 0 0 0 0
50251 - 0 0 0 0 0 0 0 0 0 0 0 0
50252 - 0 0 0 0 0 0 0 0 0 0 0 0
50253 - 6 6 6 14 14 14 42 42 42 90 90 90
50254 - 26 26 26 6 6 6 42 42 42 2 2 6
50255 - 74 74 74 250 250 250 253 253 253 253 253 253
50256 -253 253 253 253 253 253 253 253 253 253 253 253
50257 -253 253 253 253 253 253 242 242 242 242 242 242
50258 -253 253 253 253 253 253 253 253 253 253 253 253
50259 -253 253 253 253 253 253 253 253 253 253 253 253
50260 -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
50262 -253 253 253 253 253 253 182 182 182 2 2 6
50263 - 2 2 6 2 2 6 2 2 6 46 46 46
50264 - 2 2 6 2 2 6 2 2 6 2 2 6
50265 - 10 10 10 86 86 86 38 38 38 10 10 10
50266 - 0 0 0 0 0 0 0 0 0 0 0 0
50267 - 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
50269 - 0 0 0 0 0 0 0 0 0 0 0 0
50270 - 0 0 0 0 0 0 0 0 0 0 0 0
50271 - 0 0 0 0 0 0 0 0 0 0 0 0
50272 - 0 0 0 0 0 0 0 0 0 0 0 0
50273 - 10 10 10 26 26 26 66 66 66 82 82 82
50274 - 2 2 6 22 22 22 18 18 18 2 2 6
50275 -149 149 149 253 253 253 253 253 253 253 253 253
50276 -253 253 253 253 253 253 253 253 253 253 253 253
50277 -253 253 253 253 253 253 234 234 234 242 242 242
50278 -253 253 253 253 253 253 253 253 253 253 253 253
50279 -253 253 253 253 253 253 253 253 253 253 253 253
50280 -253 253 253 253 253 253 253 253 253 253 253 253
50281 -253 253 253 253 253 253 253 253 253 253 253 253
50282 -253 253 253 253 253 253 206 206 206 2 2 6
50283 - 2 2 6 2 2 6 2 2 6 38 38 38
50284 - 2 2 6 2 2 6 2 2 6 2 2 6
50285 - 6 6 6 86 86 86 46 46 46 14 14 14
50286 - 0 0 0 0 0 0 0 0 0 0 0 0
50287 - 0 0 0 0 0 0 0 0 0 0 0 0
50288 - 0 0 0 0 0 0 0 0 0 0 0 0
50289 - 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
50291 - 0 0 0 0 0 0 0 0 0 0 0 0
50292 - 0 0 0 0 0 0 0 0 0 6 6 6
50293 - 18 18 18 46 46 46 86 86 86 18 18 18
50294 - 2 2 6 34 34 34 10 10 10 6 6 6
50295 -210 210 210 253 253 253 253 253 253 253 253 253
50296 -253 253 253 253 253 253 253 253 253 253 253 253
50297 -253 253 253 253 253 253 234 234 234 242 242 242
50298 -253 253 253 253 253 253 253 253 253 253 253 253
50299 -253 253 253 253 253 253 253 253 253 253 253 253
50300 -253 253 253 253 253 253 253 253 253 253 253 253
50301 -253 253 253 253 253 253 253 253 253 253 253 253
50302 -253 253 253 253 253 253 221 221 221 6 6 6
50303 - 2 2 6 2 2 6 6 6 6 30 30 30
50304 - 2 2 6 2 2 6 2 2 6 2 2 6
50305 - 2 2 6 82 82 82 54 54 54 18 18 18
50306 - 6 6 6 0 0 0 0 0 0 0 0 0
50307 - 0 0 0 0 0 0 0 0 0 0 0 0
50308 - 0 0 0 0 0 0 0 0 0 0 0 0
50309 - 0 0 0 0 0 0 0 0 0 0 0 0
50310 - 0 0 0 0 0 0 0 0 0 0 0 0
50311 - 0 0 0 0 0 0 0 0 0 0 0 0
50312 - 0 0 0 0 0 0 0 0 0 10 10 10
50313 - 26 26 26 66 66 66 62 62 62 2 2 6
50314 - 2 2 6 38 38 38 10 10 10 26 26 26
50315 -238 238 238 253 253 253 253 253 253 253 253 253
50316 -253 253 253 253 253 253 253 253 253 253 253 253
50317 -253 253 253 253 253 253 231 231 231 238 238 238
50318 -253 253 253 253 253 253 253 253 253 253 253 253
50319 -253 253 253 253 253 253 253 253 253 253 253 253
50320 -253 253 253 253 253 253 253 253 253 253 253 253
50321 -253 253 253 253 253 253 253 253 253 253 253 253
50322 -253 253 253 253 253 253 231 231 231 6 6 6
50323 - 2 2 6 2 2 6 10 10 10 30 30 30
50324 - 2 2 6 2 2 6 2 2 6 2 2 6
50325 - 2 2 6 66 66 66 58 58 58 22 22 22
50326 - 6 6 6 0 0 0 0 0 0 0 0 0
50327 - 0 0 0 0 0 0 0 0 0 0 0 0
50328 - 0 0 0 0 0 0 0 0 0 0 0 0
50329 - 0 0 0 0 0 0 0 0 0 0 0 0
50330 - 0 0 0 0 0 0 0 0 0 0 0 0
50331 - 0 0 0 0 0 0 0 0 0 0 0 0
50332 - 0 0 0 0 0 0 0 0 0 10 10 10
50333 - 38 38 38 78 78 78 6 6 6 2 2 6
50334 - 2 2 6 46 46 46 14 14 14 42 42 42
50335 -246 246 246 253 253 253 253 253 253 253 253 253
50336 -253 253 253 253 253 253 253 253 253 253 253 253
50337 -253 253 253 253 253 253 231 231 231 242 242 242
50338 -253 253 253 253 253 253 253 253 253 253 253 253
50339 -253 253 253 253 253 253 253 253 253 253 253 253
50340 -253 253 253 253 253 253 253 253 253 253 253 253
50341 -253 253 253 253 253 253 253 253 253 253 253 253
50342 -253 253 253 253 253 253 234 234 234 10 10 10
50343 - 2 2 6 2 2 6 22 22 22 14 14 14
50344 - 2 2 6 2 2 6 2 2 6 2 2 6
50345 - 2 2 6 66 66 66 62 62 62 22 22 22
50346 - 6 6 6 0 0 0 0 0 0 0 0 0
50347 - 0 0 0 0 0 0 0 0 0 0 0 0
50348 - 0 0 0 0 0 0 0 0 0 0 0 0
50349 - 0 0 0 0 0 0 0 0 0 0 0 0
50350 - 0 0 0 0 0 0 0 0 0 0 0 0
50351 - 0 0 0 0 0 0 0 0 0 0 0 0
50352 - 0 0 0 0 0 0 6 6 6 18 18 18
50353 - 50 50 50 74 74 74 2 2 6 2 2 6
50354 - 14 14 14 70 70 70 34 34 34 62 62 62
50355 -250 250 250 253 253 253 253 253 253 253 253 253
50356 -253 253 253 253 253 253 253 253 253 253 253 253
50357 -253 253 253 253 253 253 231 231 231 246 246 246
50358 -253 253 253 253 253 253 253 253 253 253 253 253
50359 -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
50361 -253 253 253 253 253 253 253 253 253 253 253 253
50362 -253 253 253 253 253 253 234 234 234 14 14 14
50363 - 2 2 6 2 2 6 30 30 30 2 2 6
50364 - 2 2 6 2 2 6 2 2 6 2 2 6
50365 - 2 2 6 66 66 66 62 62 62 22 22 22
50366 - 6 6 6 0 0 0 0 0 0 0 0 0
50367 - 0 0 0 0 0 0 0 0 0 0 0 0
50368 - 0 0 0 0 0 0 0 0 0 0 0 0
50369 - 0 0 0 0 0 0 0 0 0 0 0 0
50370 - 0 0 0 0 0 0 0 0 0 0 0 0
50371 - 0 0 0 0 0 0 0 0 0 0 0 0
50372 - 0 0 0 0 0 0 6 6 6 18 18 18
50373 - 54 54 54 62 62 62 2 2 6 2 2 6
50374 - 2 2 6 30 30 30 46 46 46 70 70 70
50375 -250 250 250 253 253 253 253 253 253 253 253 253
50376 -253 253 253 253 253 253 253 253 253 253 253 253
50377 -253 253 253 253 253 253 231 231 231 246 246 246
50378 -253 253 253 253 253 253 253 253 253 253 253 253
50379 -253 253 253 253 253 253 253 253 253 253 253 253
50380 -253 253 253 253 253 253 253 253 253 253 253 253
50381 -253 253 253 253 253 253 253 253 253 253 253 253
50382 -253 253 253 253 253 253 226 226 226 10 10 10
50383 - 2 2 6 6 6 6 30 30 30 2 2 6
50384 - 2 2 6 2 2 6 2 2 6 2 2 6
50385 - 2 2 6 66 66 66 58 58 58 22 22 22
50386 - 6 6 6 0 0 0 0 0 0 0 0 0
50387 - 0 0 0 0 0 0 0 0 0 0 0 0
50388 - 0 0 0 0 0 0 0 0 0 0 0 0
50389 - 0 0 0 0 0 0 0 0 0 0 0 0
50390 - 0 0 0 0 0 0 0 0 0 0 0 0
50391 - 0 0 0 0 0 0 0 0 0 0 0 0
50392 - 0 0 0 0 0 0 6 6 6 22 22 22
50393 - 58 58 58 62 62 62 2 2 6 2 2 6
50394 - 2 2 6 2 2 6 30 30 30 78 78 78
50395 -250 250 250 253 253 253 253 253 253 253 253 253
50396 -253 253 253 253 253 253 253 253 253 253 253 253
50397 -253 253 253 253 253 253 231 231 231 246 246 246
50398 -253 253 253 253 253 253 253 253 253 253 253 253
50399 -253 253 253 253 253 253 253 253 253 253 253 253
50400 -253 253 253 253 253 253 253 253 253 253 253 253
50401 -253 253 253 253 253 253 253 253 253 253 253 253
50402 -253 253 253 253 253 253 206 206 206 2 2 6
50403 - 22 22 22 34 34 34 18 14 6 22 22 22
50404 - 26 26 26 18 18 18 6 6 6 2 2 6
50405 - 2 2 6 82 82 82 54 54 54 18 18 18
50406 - 6 6 6 0 0 0 0 0 0 0 0 0
50407 - 0 0 0 0 0 0 0 0 0 0 0 0
50408 - 0 0 0 0 0 0 0 0 0 0 0 0
50409 - 0 0 0 0 0 0 0 0 0 0 0 0
50410 - 0 0 0 0 0 0 0 0 0 0 0 0
50411 - 0 0 0 0 0 0 0 0 0 0 0 0
50412 - 0 0 0 0 0 0 6 6 6 26 26 26
50413 - 62 62 62 106 106 106 74 54 14 185 133 11
50414 -210 162 10 121 92 8 6 6 6 62 62 62
50415 -238 238 238 253 253 253 253 253 253 253 253 253
50416 -253 253 253 253 253 253 253 253 253 253 253 253
50417 -253 253 253 253 253 253 231 231 231 246 246 246
50418 -253 253 253 253 253 253 253 253 253 253 253 253
50419 -253 253 253 253 253 253 253 253 253 253 253 253
50420 -253 253 253 253 253 253 253 253 253 253 253 253
50421 -253 253 253 253 253 253 253 253 253 253 253 253
50422 -253 253 253 253 253 253 158 158 158 18 18 18
50423 - 14 14 14 2 2 6 2 2 6 2 2 6
50424 - 6 6 6 18 18 18 66 66 66 38 38 38
50425 - 6 6 6 94 94 94 50 50 50 18 18 18
50426 - 6 6 6 0 0 0 0 0 0 0 0 0
50427 - 0 0 0 0 0 0 0 0 0 0 0 0
50428 - 0 0 0 0 0 0 0 0 0 0 0 0
50429 - 0 0 0 0 0 0 0 0 0 0 0 0
50430 - 0 0 0 0 0 0 0 0 0 0 0 0
50431 - 0 0 0 0 0 0 0 0 0 6 6 6
50432 - 10 10 10 10 10 10 18 18 18 38 38 38
50433 - 78 78 78 142 134 106 216 158 10 242 186 14
50434 -246 190 14 246 190 14 156 118 10 10 10 10
50435 - 90 90 90 238 238 238 253 253 253 253 253 253
50436 -253 253 253 253 253 253 253 253 253 253 253 253
50437 -253 253 253 253 253 253 231 231 231 250 250 250
50438 -253 253 253 253 253 253 253 253 253 253 253 253
50439 -253 253 253 253 253 253 253 253 253 253 253 253
50440 -253 253 253 253 253 253 253 253 253 253 253 253
50441 -253 253 253 253 253 253 253 253 253 246 230 190
50442 -238 204 91 238 204 91 181 142 44 37 26 9
50443 - 2 2 6 2 2 6 2 2 6 2 2 6
50444 - 2 2 6 2 2 6 38 38 38 46 46 46
50445 - 26 26 26 106 106 106 54 54 54 18 18 18
50446 - 6 6 6 0 0 0 0 0 0 0 0 0
50447 - 0 0 0 0 0 0 0 0 0 0 0 0
50448 - 0 0 0 0 0 0 0 0 0 0 0 0
50449 - 0 0 0 0 0 0 0 0 0 0 0 0
50450 - 0 0 0 0 0 0 0 0 0 0 0 0
50451 - 0 0 0 6 6 6 14 14 14 22 22 22
50452 - 30 30 30 38 38 38 50 50 50 70 70 70
50453 -106 106 106 190 142 34 226 170 11 242 186 14
50454 -246 190 14 246 190 14 246 190 14 154 114 10
50455 - 6 6 6 74 74 74 226 226 226 253 253 253
50456 -253 253 253 253 253 253 253 253 253 253 253 253
50457 -253 253 253 253 253 253 231 231 231 250 250 250
50458 -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
50460 -253 253 253 253 253 253 253 253 253 253 253 253
50461 -253 253 253 253 253 253 253 253 253 228 184 62
50462 -241 196 14 241 208 19 232 195 16 38 30 10
50463 - 2 2 6 2 2 6 2 2 6 2 2 6
50464 - 2 2 6 6 6 6 30 30 30 26 26 26
50465 -203 166 17 154 142 90 66 66 66 26 26 26
50466 - 6 6 6 0 0 0 0 0 0 0 0 0
50467 - 0 0 0 0 0 0 0 0 0 0 0 0
50468 - 0 0 0 0 0 0 0 0 0 0 0 0
50469 - 0 0 0 0 0 0 0 0 0 0 0 0
50470 - 0 0 0 0 0 0 0 0 0 0 0 0
50471 - 6 6 6 18 18 18 38 38 38 58 58 58
50472 - 78 78 78 86 86 86 101 101 101 123 123 123
50473 -175 146 61 210 150 10 234 174 13 246 186 14
50474 -246 190 14 246 190 14 246 190 14 238 190 10
50475 -102 78 10 2 2 6 46 46 46 198 198 198
50476 -253 253 253 253 253 253 253 253 253 253 253 253
50477 -253 253 253 253 253 253 234 234 234 242 242 242
50478 -253 253 253 253 253 253 253 253 253 253 253 253
50479 -253 253 253 253 253 253 253 253 253 253 253 253
50480 -253 253 253 253 253 253 253 253 253 253 253 253
50481 -253 253 253 253 253 253 253 253 253 224 178 62
50482 -242 186 14 241 196 14 210 166 10 22 18 6
50483 - 2 2 6 2 2 6 2 2 6 2 2 6
50484 - 2 2 6 2 2 6 6 6 6 121 92 8
50485 -238 202 15 232 195 16 82 82 82 34 34 34
50486 - 10 10 10 0 0 0 0 0 0 0 0 0
50487 - 0 0 0 0 0 0 0 0 0 0 0 0
50488 - 0 0 0 0 0 0 0 0 0 0 0 0
50489 - 0 0 0 0 0 0 0 0 0 0 0 0
50490 - 0 0 0 0 0 0 0 0 0 0 0 0
50491 - 14 14 14 38 38 38 70 70 70 154 122 46
50492 -190 142 34 200 144 11 197 138 11 197 138 11
50493 -213 154 11 226 170 11 242 186 14 246 190 14
50494 -246 190 14 246 190 14 246 190 14 246 190 14
50495 -225 175 15 46 32 6 2 2 6 22 22 22
50496 -158 158 158 250 250 250 253 253 253 253 253 253
50497 -253 253 253 253 253 253 253 253 253 253 253 253
50498 -253 253 253 253 253 253 253 253 253 253 253 253
50499 -253 253 253 253 253 253 253 253 253 253 253 253
50500 -253 253 253 253 253 253 253 253 253 253 253 253
50501 -253 253 253 250 250 250 242 242 242 224 178 62
50502 -239 182 13 236 186 11 213 154 11 46 32 6
50503 - 2 2 6 2 2 6 2 2 6 2 2 6
50504 - 2 2 6 2 2 6 61 42 6 225 175 15
50505 -238 190 10 236 186 11 112 100 78 42 42 42
50506 - 14 14 14 0 0 0 0 0 0 0 0 0
50507 - 0 0 0 0 0 0 0 0 0 0 0 0
50508 - 0 0 0 0 0 0 0 0 0 0 0 0
50509 - 0 0 0 0 0 0 0 0 0 0 0 0
50510 - 0 0 0 0 0 0 0 0 0 6 6 6
50511 - 22 22 22 54 54 54 154 122 46 213 154 11
50512 -226 170 11 230 174 11 226 170 11 226 170 11
50513 -236 178 12 242 186 14 246 190 14 246 190 14
50514 -246 190 14 246 190 14 246 190 14 246 190 14
50515 -241 196 14 184 144 12 10 10 10 2 2 6
50516 - 6 6 6 116 116 116 242 242 242 253 253 253
50517 -253 253 253 253 253 253 253 253 253 253 253 253
50518 -253 253 253 253 253 253 253 253 253 253 253 253
50519 -253 253 253 253 253 253 253 253 253 253 253 253
50520 -253 253 253 253 253 253 253 253 253 253 253 253
50521 -253 253 253 231 231 231 198 198 198 214 170 54
50522 -236 178 12 236 178 12 210 150 10 137 92 6
50523 - 18 14 6 2 2 6 2 2 6 2 2 6
50524 - 6 6 6 70 47 6 200 144 11 236 178 12
50525 -239 182 13 239 182 13 124 112 88 58 58 58
50526 - 22 22 22 6 6 6 0 0 0 0 0 0
50527 - 0 0 0 0 0 0 0 0 0 0 0 0
50528 - 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
50530 - 0 0 0 0 0 0 0 0 0 10 10 10
50531 - 30 30 30 70 70 70 180 133 36 226 170 11
50532 -239 182 13 242 186 14 242 186 14 246 186 14
50533 -246 190 14 246 190 14 246 190 14 246 190 14
50534 -246 190 14 246 190 14 246 190 14 246 190 14
50535 -246 190 14 232 195 16 98 70 6 2 2 6
50536 - 2 2 6 2 2 6 66 66 66 221 221 221
50537 -253 253 253 253 253 253 253 253 253 253 253 253
50538 -253 253 253 253 253 253 253 253 253 253 253 253
50539 -253 253 253 253 253 253 253 253 253 253 253 253
50540 -253 253 253 253 253 253 253 253 253 253 253 253
50541 -253 253 253 206 206 206 198 198 198 214 166 58
50542 -230 174 11 230 174 11 216 158 10 192 133 9
50543 -163 110 8 116 81 8 102 78 10 116 81 8
50544 -167 114 7 197 138 11 226 170 11 239 182 13
50545 -242 186 14 242 186 14 162 146 94 78 78 78
50546 - 34 34 34 14 14 14 6 6 6 0 0 0
50547 - 0 0 0 0 0 0 0 0 0 0 0 0
50548 - 0 0 0 0 0 0 0 0 0 0 0 0
50549 - 0 0 0 0 0 0 0 0 0 0 0 0
50550 - 0 0 0 0 0 0 0 0 0 6 6 6
50551 - 30 30 30 78 78 78 190 142 34 226 170 11
50552 -239 182 13 246 190 14 246 190 14 246 190 14
50553 -246 190 14 246 190 14 246 190 14 246 190 14
50554 -246 190 14 246 190 14 246 190 14 246 190 14
50555 -246 190 14 241 196 14 203 166 17 22 18 6
50556 - 2 2 6 2 2 6 2 2 6 38 38 38
50557 -218 218 218 253 253 253 253 253 253 253 253 253
50558 -253 253 253 253 253 253 253 253 253 253 253 253
50559 -253 253 253 253 253 253 253 253 253 253 253 253
50560 -253 253 253 253 253 253 253 253 253 253 253 253
50561 -250 250 250 206 206 206 198 198 198 202 162 69
50562 -226 170 11 236 178 12 224 166 10 210 150 10
50563 -200 144 11 197 138 11 192 133 9 197 138 11
50564 -210 150 10 226 170 11 242 186 14 246 190 14
50565 -246 190 14 246 186 14 225 175 15 124 112 88
50566 - 62 62 62 30 30 30 14 14 14 6 6 6
50567 - 0 0 0 0 0 0 0 0 0 0 0 0
50568 - 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
50570 - 0 0 0 0 0 0 0 0 0 10 10 10
50571 - 30 30 30 78 78 78 174 135 50 224 166 10
50572 -239 182 13 246 190 14 246 190 14 246 190 14
50573 -246 190 14 246 190 14 246 190 14 246 190 14
50574 -246 190 14 246 190 14 246 190 14 246 190 14
50575 -246 190 14 246 190 14 241 196 14 139 102 15
50576 - 2 2 6 2 2 6 2 2 6 2 2 6
50577 - 78 78 78 250 250 250 253 253 253 253 253 253
50578 -253 253 253 253 253 253 253 253 253 253 253 253
50579 -253 253 253 253 253 253 253 253 253 253 253 253
50580 -253 253 253 253 253 253 253 253 253 253 253 253
50581 -250 250 250 214 214 214 198 198 198 190 150 46
50582 -219 162 10 236 178 12 234 174 13 224 166 10
50583 -216 158 10 213 154 11 213 154 11 216 158 10
50584 -226 170 11 239 182 13 246 190 14 246 190 14
50585 -246 190 14 246 190 14 242 186 14 206 162 42
50586 -101 101 101 58 58 58 30 30 30 14 14 14
50587 - 6 6 6 0 0 0 0 0 0 0 0 0
50588 - 0 0 0 0 0 0 0 0 0 0 0 0
50589 - 0 0 0 0 0 0 0 0 0 0 0 0
50590 - 0 0 0 0 0 0 0 0 0 10 10 10
50591 - 30 30 30 74 74 74 174 135 50 216 158 10
50592 -236 178 12 246 190 14 246 190 14 246 190 14
50593 -246 190 14 246 190 14 246 190 14 246 190 14
50594 -246 190 14 246 190 14 246 190 14 246 190 14
50595 -246 190 14 246 190 14 241 196 14 226 184 13
50596 - 61 42 6 2 2 6 2 2 6 2 2 6
50597 - 22 22 22 238 238 238 253 253 253 253 253 253
50598 -253 253 253 253 253 253 253 253 253 253 253 253
50599 -253 253 253 253 253 253 253 253 253 253 253 253
50600 -253 253 253 253 253 253 253 253 253 253 253 253
50601 -253 253 253 226 226 226 187 187 187 180 133 36
50602 -216 158 10 236 178 12 239 182 13 236 178 12
50603 -230 174 11 226 170 11 226 170 11 230 174 11
50604 -236 178 12 242 186 14 246 190 14 246 190 14
50605 -246 190 14 246 190 14 246 186 14 239 182 13
50606 -206 162 42 106 106 106 66 66 66 34 34 34
50607 - 14 14 14 6 6 6 0 0 0 0 0 0
50608 - 0 0 0 0 0 0 0 0 0 0 0 0
50609 - 0 0 0 0 0 0 0 0 0 0 0 0
50610 - 0 0 0 0 0 0 0 0 0 6 6 6
50611 - 26 26 26 70 70 70 163 133 67 213 154 11
50612 -236 178 12 246 190 14 246 190 14 246 190 14
50613 -246 190 14 246 190 14 246 190 14 246 190 14
50614 -246 190 14 246 190 14 246 190 14 246 190 14
50615 -246 190 14 246 190 14 246 190 14 241 196 14
50616 -190 146 13 18 14 6 2 2 6 2 2 6
50617 - 46 46 46 246 246 246 253 253 253 253 253 253
50618 -253 253 253 253 253 253 253 253 253 253 253 253
50619 -253 253 253 253 253 253 253 253 253 253 253 253
50620 -253 253 253 253 253 253 253 253 253 253 253 253
50621 -253 253 253 221 221 221 86 86 86 156 107 11
50622 -216 158 10 236 178 12 242 186 14 246 186 14
50623 -242 186 14 239 182 13 239 182 13 242 186 14
50624 -242 186 14 246 186 14 246 190 14 246 190 14
50625 -246 190 14 246 190 14 246 190 14 246 190 14
50626 -242 186 14 225 175 15 142 122 72 66 66 66
50627 - 30 30 30 10 10 10 0 0 0 0 0 0
50628 - 0 0 0 0 0 0 0 0 0 0 0 0
50629 - 0 0 0 0 0 0 0 0 0 0 0 0
50630 - 0 0 0 0 0 0 0 0 0 6 6 6
50631 - 26 26 26 70 70 70 163 133 67 210 150 10
50632 -236 178 12 246 190 14 246 190 14 246 190 14
50633 -246 190 14 246 190 14 246 190 14 246 190 14
50634 -246 190 14 246 190 14 246 190 14 246 190 14
50635 -246 190 14 246 190 14 246 190 14 246 190 14
50636 -232 195 16 121 92 8 34 34 34 106 106 106
50637 -221 221 221 253 253 253 253 253 253 253 253 253
50638 -253 253 253 253 253 253 253 253 253 253 253 253
50639 -253 253 253 253 253 253 253 253 253 253 253 253
50640 -253 253 253 253 253 253 253 253 253 253 253 253
50641 -242 242 242 82 82 82 18 14 6 163 110 8
50642 -216 158 10 236 178 12 242 186 14 246 190 14
50643 -246 190 14 246 190 14 246 190 14 246 190 14
50644 -246 190 14 246 190 14 246 190 14 246 190 14
50645 -246 190 14 246 190 14 246 190 14 246 190 14
50646 -246 190 14 246 190 14 242 186 14 163 133 67
50647 - 46 46 46 18 18 18 6 6 6 0 0 0
50648 - 0 0 0 0 0 0 0 0 0 0 0 0
50649 - 0 0 0 0 0 0 0 0 0 0 0 0
50650 - 0 0 0 0 0 0 0 0 0 10 10 10
50651 - 30 30 30 78 78 78 163 133 67 210 150 10
50652 -236 178 12 246 186 14 246 190 14 246 190 14
50653 -246 190 14 246 190 14 246 190 14 246 190 14
50654 -246 190 14 246 190 14 246 190 14 246 190 14
50655 -246 190 14 246 190 14 246 190 14 246 190 14
50656 -241 196 14 215 174 15 190 178 144 253 253 253
50657 -253 253 253 253 253 253 253 253 253 253 253 253
50658 -253 253 253 253 253 253 253 253 253 253 253 253
50659 -253 253 253 253 253 253 253 253 253 253 253 253
50660 -253 253 253 253 253 253 253 253 253 218 218 218
50661 - 58 58 58 2 2 6 22 18 6 167 114 7
50662 -216 158 10 236 178 12 246 186 14 246 190 14
50663 -246 190 14 246 190 14 246 190 14 246 190 14
50664 -246 190 14 246 190 14 246 190 14 246 190 14
50665 -246 190 14 246 190 14 246 190 14 246 190 14
50666 -246 190 14 246 186 14 242 186 14 190 150 46
50667 - 54 54 54 22 22 22 6 6 6 0 0 0
50668 - 0 0 0 0 0 0 0 0 0 0 0 0
50669 - 0 0 0 0 0 0 0 0 0 0 0 0
50670 - 0 0 0 0 0 0 0 0 0 14 14 14
50671 - 38 38 38 86 86 86 180 133 36 213 154 11
50672 -236 178 12 246 186 14 246 190 14 246 190 14
50673 -246 190 14 246 190 14 246 190 14 246 190 14
50674 -246 190 14 246 190 14 246 190 14 246 190 14
50675 -246 190 14 246 190 14 246 190 14 246 190 14
50676 -246 190 14 232 195 16 190 146 13 214 214 214
50677 -253 253 253 253 253 253 253 253 253 253 253 253
50678 -253 253 253 253 253 253 253 253 253 253 253 253
50679 -253 253 253 253 253 253 253 253 253 253 253 253
50680 -253 253 253 250 250 250 170 170 170 26 26 26
50681 - 2 2 6 2 2 6 37 26 9 163 110 8
50682 -219 162 10 239 182 13 246 186 14 246 190 14
50683 -246 190 14 246 190 14 246 190 14 246 190 14
50684 -246 190 14 246 190 14 246 190 14 246 190 14
50685 -246 190 14 246 190 14 246 190 14 246 190 14
50686 -246 186 14 236 178 12 224 166 10 142 122 72
50687 - 46 46 46 18 18 18 6 6 6 0 0 0
50688 - 0 0 0 0 0 0 0 0 0 0 0 0
50689 - 0 0 0 0 0 0 0 0 0 0 0 0
50690 - 0 0 0 0 0 0 6 6 6 18 18 18
50691 - 50 50 50 109 106 95 192 133 9 224 166 10
50692 -242 186 14 246 190 14 246 190 14 246 190 14
50693 -246 190 14 246 190 14 246 190 14 246 190 14
50694 -246 190 14 246 190 14 246 190 14 246 190 14
50695 -246 190 14 246 190 14 246 190 14 246 190 14
50696 -242 186 14 226 184 13 210 162 10 142 110 46
50697 -226 226 226 253 253 253 253 253 253 253 253 253
50698 -253 253 253 253 253 253 253 253 253 253 253 253
50699 -253 253 253 253 253 253 253 253 253 253 253 253
50700 -198 198 198 66 66 66 2 2 6 2 2 6
50701 - 2 2 6 2 2 6 50 34 6 156 107 11
50702 -219 162 10 239 182 13 246 186 14 246 190 14
50703 -246 190 14 246 190 14 246 190 14 246 190 14
50704 -246 190 14 246 190 14 246 190 14 246 190 14
50705 -246 190 14 246 190 14 246 190 14 242 186 14
50706 -234 174 13 213 154 11 154 122 46 66 66 66
50707 - 30 30 30 10 10 10 0 0 0 0 0 0
50708 - 0 0 0 0 0 0 0 0 0 0 0 0
50709 - 0 0 0 0 0 0 0 0 0 0 0 0
50710 - 0 0 0 0 0 0 6 6 6 22 22 22
50711 - 58 58 58 154 121 60 206 145 10 234 174 13
50712 -242 186 14 246 186 14 246 190 14 246 190 14
50713 -246 190 14 246 190 14 246 190 14 246 190 14
50714 -246 190 14 246 190 14 246 190 14 246 190 14
50715 -246 190 14 246 190 14 246 190 14 246 190 14
50716 -246 186 14 236 178 12 210 162 10 163 110 8
50717 - 61 42 6 138 138 138 218 218 218 250 250 250
50718 -253 253 253 253 253 253 253 253 253 250 250 250
50719 -242 242 242 210 210 210 144 144 144 66 66 66
50720 - 6 6 6 2 2 6 2 2 6 2 2 6
50721 - 2 2 6 2 2 6 61 42 6 163 110 8
50722 -216 158 10 236 178 12 246 190 14 246 190 14
50723 -246 190 14 246 190 14 246 190 14 246 190 14
50724 -246 190 14 246 190 14 246 190 14 246 190 14
50725 -246 190 14 239 182 13 230 174 11 216 158 10
50726 -190 142 34 124 112 88 70 70 70 38 38 38
50727 - 18 18 18 6 6 6 0 0 0 0 0 0
50728 - 0 0 0 0 0 0 0 0 0 0 0 0
50729 - 0 0 0 0 0 0 0 0 0 0 0 0
50730 - 0 0 0 0 0 0 6 6 6 22 22 22
50731 - 62 62 62 168 124 44 206 145 10 224 166 10
50732 -236 178 12 239 182 13 242 186 14 242 186 14
50733 -246 186 14 246 190 14 246 190 14 246 190 14
50734 -246 190 14 246 190 14 246 190 14 246 190 14
50735 -246 190 14 246 190 14 246 190 14 246 190 14
50736 -246 190 14 236 178 12 216 158 10 175 118 6
50737 - 80 54 7 2 2 6 6 6 6 30 30 30
50738 - 54 54 54 62 62 62 50 50 50 38 38 38
50739 - 14 14 14 2 2 6 2 2 6 2 2 6
50740 - 2 2 6 2 2 6 2 2 6 2 2 6
50741 - 2 2 6 6 6 6 80 54 7 167 114 7
50742 -213 154 11 236 178 12 246 190 14 246 190 14
50743 -246 190 14 246 190 14 246 190 14 246 190 14
50744 -246 190 14 242 186 14 239 182 13 239 182 13
50745 -230 174 11 210 150 10 174 135 50 124 112 88
50746 - 82 82 82 54 54 54 34 34 34 18 18 18
50747 - 6 6 6 0 0 0 0 0 0 0 0 0
50748 - 0 0 0 0 0 0 0 0 0 0 0 0
50749 - 0 0 0 0 0 0 0 0 0 0 0 0
50750 - 0 0 0 0 0 0 6 6 6 18 18 18
50751 - 50 50 50 158 118 36 192 133 9 200 144 11
50752 -216 158 10 219 162 10 224 166 10 226 170 11
50753 -230 174 11 236 178 12 239 182 13 239 182 13
50754 -242 186 14 246 186 14 246 190 14 246 190 14
50755 -246 190 14 246 190 14 246 190 14 246 190 14
50756 -246 186 14 230 174 11 210 150 10 163 110 8
50757 -104 69 6 10 10 10 2 2 6 2 2 6
50758 - 2 2 6 2 2 6 2 2 6 2 2 6
50759 - 2 2 6 2 2 6 2 2 6 2 2 6
50760 - 2 2 6 2 2 6 2 2 6 2 2 6
50761 - 2 2 6 6 6 6 91 60 6 167 114 7
50762 -206 145 10 230 174 11 242 186 14 246 190 14
50763 -246 190 14 246 190 14 246 186 14 242 186 14
50764 -239 182 13 230 174 11 224 166 10 213 154 11
50765 -180 133 36 124 112 88 86 86 86 58 58 58
50766 - 38 38 38 22 22 22 10 10 10 6 6 6
50767 - 0 0 0 0 0 0 0 0 0 0 0 0
50768 - 0 0 0 0 0 0 0 0 0 0 0 0
50769 - 0 0 0 0 0 0 0 0 0 0 0 0
50770 - 0 0 0 0 0 0 0 0 0 14 14 14
50771 - 34 34 34 70 70 70 138 110 50 158 118 36
50772 -167 114 7 180 123 7 192 133 9 197 138 11
50773 -200 144 11 206 145 10 213 154 11 219 162 10
50774 -224 166 10 230 174 11 239 182 13 242 186 14
50775 -246 186 14 246 186 14 246 186 14 246 186 14
50776 -239 182 13 216 158 10 185 133 11 152 99 6
50777 -104 69 6 18 14 6 2 2 6 2 2 6
50778 - 2 2 6 2 2 6 2 2 6 2 2 6
50779 - 2 2 6 2 2 6 2 2 6 2 2 6
50780 - 2 2 6 2 2 6 2 2 6 2 2 6
50781 - 2 2 6 6 6 6 80 54 7 152 99 6
50782 -192 133 9 219 162 10 236 178 12 239 182 13
50783 -246 186 14 242 186 14 239 182 13 236 178 12
50784 -224 166 10 206 145 10 192 133 9 154 121 60
50785 - 94 94 94 62 62 62 42 42 42 22 22 22
50786 - 14 14 14 6 6 6 0 0 0 0 0 0
50787 - 0 0 0 0 0 0 0 0 0 0 0 0
50788 - 0 0 0 0 0 0 0 0 0 0 0 0
50789 - 0 0 0 0 0 0 0 0 0 0 0 0
50790 - 0 0 0 0 0 0 0 0 0 6 6 6
50791 - 18 18 18 34 34 34 58 58 58 78 78 78
50792 -101 98 89 124 112 88 142 110 46 156 107 11
50793 -163 110 8 167 114 7 175 118 6 180 123 7
50794 -185 133 11 197 138 11 210 150 10 219 162 10
50795 -226 170 11 236 178 12 236 178 12 234 174 13
50796 -219 162 10 197 138 11 163 110 8 130 83 6
50797 - 91 60 6 10 10 10 2 2 6 2 2 6
50798 - 18 18 18 38 38 38 38 38 38 38 38 38
50799 - 38 38 38 38 38 38 38 38 38 38 38 38
50800 - 38 38 38 38 38 38 26 26 26 2 2 6
50801 - 2 2 6 6 6 6 70 47 6 137 92 6
50802 -175 118 6 200 144 11 219 162 10 230 174 11
50803 -234 174 13 230 174 11 219 162 10 210 150 10
50804 -192 133 9 163 110 8 124 112 88 82 82 82
50805 - 50 50 50 30 30 30 14 14 14 6 6 6
50806 - 0 0 0 0 0 0 0 0 0 0 0 0
50807 - 0 0 0 0 0 0 0 0 0 0 0 0
50808 - 0 0 0 0 0 0 0 0 0 0 0 0
50809 - 0 0 0 0 0 0 0 0 0 0 0 0
50810 - 0 0 0 0 0 0 0 0 0 0 0 0
50811 - 6 6 6 14 14 14 22 22 22 34 34 34
50812 - 42 42 42 58 58 58 74 74 74 86 86 86
50813 -101 98 89 122 102 70 130 98 46 121 87 25
50814 -137 92 6 152 99 6 163 110 8 180 123 7
50815 -185 133 11 197 138 11 206 145 10 200 144 11
50816 -180 123 7 156 107 11 130 83 6 104 69 6
50817 - 50 34 6 54 54 54 110 110 110 101 98 89
50818 - 86 86 86 82 82 82 78 78 78 78 78 78
50819 - 78 78 78 78 78 78 78 78 78 78 78 78
50820 - 78 78 78 82 82 82 86 86 86 94 94 94
50821 -106 106 106 101 101 101 86 66 34 124 80 6
50822 -156 107 11 180 123 7 192 133 9 200 144 11
50823 -206 145 10 200 144 11 192 133 9 175 118 6
50824 -139 102 15 109 106 95 70 70 70 42 42 42
50825 - 22 22 22 10 10 10 0 0 0 0 0 0
50826 - 0 0 0 0 0 0 0 0 0 0 0 0
50827 - 0 0 0 0 0 0 0 0 0 0 0 0
50828 - 0 0 0 0 0 0 0 0 0 0 0 0
50829 - 0 0 0 0 0 0 0 0 0 0 0 0
50830 - 0 0 0 0 0 0 0 0 0 0 0 0
50831 - 0 0 0 0 0 0 6 6 6 10 10 10
50832 - 14 14 14 22 22 22 30 30 30 38 38 38
50833 - 50 50 50 62 62 62 74 74 74 90 90 90
50834 -101 98 89 112 100 78 121 87 25 124 80 6
50835 -137 92 6 152 99 6 152 99 6 152 99 6
50836 -138 86 6 124 80 6 98 70 6 86 66 30
50837 -101 98 89 82 82 82 58 58 58 46 46 46
50838 - 38 38 38 34 34 34 34 34 34 34 34 34
50839 - 34 34 34 34 34 34 34 34 34 34 34 34
50840 - 34 34 34 34 34 34 38 38 38 42 42 42
50841 - 54 54 54 82 82 82 94 86 76 91 60 6
50842 -134 86 6 156 107 11 167 114 7 175 118 6
50843 -175 118 6 167 114 7 152 99 6 121 87 25
50844 -101 98 89 62 62 62 34 34 34 18 18 18
50845 - 6 6 6 0 0 0 0 0 0 0 0 0
50846 - 0 0 0 0 0 0 0 0 0 0 0 0
50847 - 0 0 0 0 0 0 0 0 0 0 0 0
50848 - 0 0 0 0 0 0 0 0 0 0 0 0
50849 - 0 0 0 0 0 0 0 0 0 0 0 0
50850 - 0 0 0 0 0 0 0 0 0 0 0 0
50851 - 0 0 0 0 0 0 0 0 0 0 0 0
50852 - 0 0 0 6 6 6 6 6 6 10 10 10
50853 - 18 18 18 22 22 22 30 30 30 42 42 42
50854 - 50 50 50 66 66 66 86 86 86 101 98 89
50855 -106 86 58 98 70 6 104 69 6 104 69 6
50856 -104 69 6 91 60 6 82 62 34 90 90 90
50857 - 62 62 62 38 38 38 22 22 22 14 14 14
50858 - 10 10 10 10 10 10 10 10 10 10 10 10
50859 - 10 10 10 10 10 10 6 6 6 10 10 10
50860 - 10 10 10 10 10 10 10 10 10 14 14 14
50861 - 22 22 22 42 42 42 70 70 70 89 81 66
50862 - 80 54 7 104 69 6 124 80 6 137 92 6
50863 -134 86 6 116 81 8 100 82 52 86 86 86
50864 - 58 58 58 30 30 30 14 14 14 6 6 6
50865 - 0 0 0 0 0 0 0 0 0 0 0 0
50866 - 0 0 0 0 0 0 0 0 0 0 0 0
50867 - 0 0 0 0 0 0 0 0 0 0 0 0
50868 - 0 0 0 0 0 0 0 0 0 0 0 0
50869 - 0 0 0 0 0 0 0 0 0 0 0 0
50870 - 0 0 0 0 0 0 0 0 0 0 0 0
50871 - 0 0 0 0 0 0 0 0 0 0 0 0
50872 - 0 0 0 0 0 0 0 0 0 0 0 0
50873 - 0 0 0 6 6 6 10 10 10 14 14 14
50874 - 18 18 18 26 26 26 38 38 38 54 54 54
50875 - 70 70 70 86 86 86 94 86 76 89 81 66
50876 - 89 81 66 86 86 86 74 74 74 50 50 50
50877 - 30 30 30 14 14 14 6 6 6 0 0 0
50878 - 0 0 0 0 0 0 0 0 0 0 0 0
50879 - 0 0 0 0 0 0 0 0 0 0 0 0
50880 - 0 0 0 0 0 0 0 0 0 0 0 0
50881 - 6 6 6 18 18 18 34 34 34 58 58 58
50882 - 82 82 82 89 81 66 89 81 66 89 81 66
50883 - 94 86 66 94 86 76 74 74 74 50 50 50
50884 - 26 26 26 14 14 14 6 6 6 0 0 0
50885 - 0 0 0 0 0 0 0 0 0 0 0 0
50886 - 0 0 0 0 0 0 0 0 0 0 0 0
50887 - 0 0 0 0 0 0 0 0 0 0 0 0
50888 - 0 0 0 0 0 0 0 0 0 0 0 0
50889 - 0 0 0 0 0 0 0 0 0 0 0 0
50890 - 0 0 0 0 0 0 0 0 0 0 0 0
50891 - 0 0 0 0 0 0 0 0 0 0 0 0
50892 - 0 0 0 0 0 0 0 0 0 0 0 0
50893 - 0 0 0 0 0 0 0 0 0 0 0 0
50894 - 6 6 6 6 6 6 14 14 14 18 18 18
50895 - 30 30 30 38 38 38 46 46 46 54 54 54
50896 - 50 50 50 42 42 42 30 30 30 18 18 18
50897 - 10 10 10 0 0 0 0 0 0 0 0 0
50898 - 0 0 0 0 0 0 0 0 0 0 0 0
50899 - 0 0 0 0 0 0 0 0 0 0 0 0
50900 - 0 0 0 0 0 0 0 0 0 0 0 0
50901 - 0 0 0 6 6 6 14 14 14 26 26 26
50902 - 38 38 38 50 50 50 58 58 58 58 58 58
50903 - 54 54 54 42 42 42 30 30 30 18 18 18
50904 - 10 10 10 0 0 0 0 0 0 0 0 0
50905 - 0 0 0 0 0 0 0 0 0 0 0 0
50906 - 0 0 0 0 0 0 0 0 0 0 0 0
50907 - 0 0 0 0 0 0 0 0 0 0 0 0
50908 - 0 0 0 0 0 0 0 0 0 0 0 0
50909 - 0 0 0 0 0 0 0 0 0 0 0 0
50910 - 0 0 0 0 0 0 0 0 0 0 0 0
50911 - 0 0 0 0 0 0 0 0 0 0 0 0
50912 - 0 0 0 0 0 0 0 0 0 0 0 0
50913 - 0 0 0 0 0 0 0 0 0 0 0 0
50914 - 0 0 0 0 0 0 0 0 0 6 6 6
50915 - 6 6 6 10 10 10 14 14 14 18 18 18
50916 - 18 18 18 14 14 14 10 10 10 6 6 6
50917 - 0 0 0 0 0 0 0 0 0 0 0 0
50918 - 0 0 0 0 0 0 0 0 0 0 0 0
50919 - 0 0 0 0 0 0 0 0 0 0 0 0
50920 - 0 0 0 0 0 0 0 0 0 0 0 0
50921 - 0 0 0 0 0 0 0 0 0 6 6 6
50922 - 14 14 14 18 18 18 22 22 22 22 22 22
50923 - 18 18 18 14 14 14 10 10 10 6 6 6
50924 - 0 0 0 0 0 0 0 0 0 0 0 0
50925 - 0 0 0 0 0 0 0 0 0 0 0 0
50926 - 0 0 0 0 0 0 0 0 0 0 0 0
50927 - 0 0 0 0 0 0 0 0 0 0 0 0
50928 - 0 0 0 0 0 0 0 0 0 0 0 0
50929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50942 +4 4 4 4 4 4
50943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50954 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50956 +4 4 4 4 4 4
50957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50968 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50970 +4 4 4 4 4 4
50971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50984 +4 4 4 4 4 4
50985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50992 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50998 +4 4 4 4 4 4
50999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51003 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
51006 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51012 +4 4 4 4 4 4
51013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51017 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51018 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51020 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51022 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51023 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51024 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
51025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51026 +4 4 4 4 4 4
51027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51031 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51032 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51033 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51036 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51037 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51038 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51039 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51040 +4 4 4 4 4 4
51041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51045 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51046 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51047 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51049 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51050 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51051 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51052 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51053 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51054 +4 4 4 4 4 4
51055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51058 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51059 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51060 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51061 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
51062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51063 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51064 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51065 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51066 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51067 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51068 +4 4 4 4 4 4
51069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51072 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51073 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51074 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51075 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51076 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51077 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51078 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51079 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51080 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51081 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51082 +4 4 4 4 4 4
51083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51086 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51087 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51088 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51089 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51090 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51091 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51092 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51093 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51094 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51095 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51096 +4 4 4 4 4 4
51097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51099 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
51100 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51101 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51102 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51103 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51104 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51105 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51106 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51107 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51108 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51109 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
51110 +4 4 4 4 4 4
51111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51113 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
51114 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51115 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51116 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51117 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51118 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51119 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51120 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51121 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51122 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51123 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51124 +4 4 4 4 4 4
51125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51127 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51128 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51129 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51130 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51131 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51132 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51133 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51134 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51135 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51136 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51137 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51138 +4 4 4 4 4 4
51139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51141 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51142 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51143 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51144 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51145 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51146 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51147 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51148 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51149 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51150 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51151 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51152 +4 4 4 4 4 4
51153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51154 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
51155 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51156 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51157 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51158 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51159 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51160 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51161 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51162 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51163 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51164 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51165 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51166 +4 4 4 4 4 4
51167 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51168 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51169 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51170 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51171 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51172 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51173 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51174 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51175 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51176 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51177 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51178 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51179 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51180 +0 0 0 4 4 4
51181 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51182 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51183 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51184 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51185 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51186 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51187 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51188 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51189 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51190 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51191 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51192 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51193 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51194 +2 0 0 0 0 0
51195 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51196 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51197 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51198 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51199 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51200 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51201 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51202 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51203 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51204 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51205 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51206 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51207 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51208 +37 38 37 0 0 0
51209 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51210 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51211 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51212 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51213 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51214 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51215 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51216 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51217 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51218 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51219 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51220 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51221 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51222 +85 115 134 4 0 0
51223 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51224 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51225 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51226 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51227 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51228 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51229 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51230 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51231 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51232 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51233 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51234 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51235 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51236 +60 73 81 4 0 0
51237 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51238 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51239 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51240 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51241 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51242 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51243 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51244 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51245 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51246 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51247 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51248 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51249 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51250 +16 19 21 4 0 0
51251 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51252 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51253 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51254 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51255 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51256 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51257 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51258 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51259 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51260 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51261 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51262 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51263 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51264 +4 0 0 4 3 3
51265 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51266 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51267 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51269 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51270 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51271 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51272 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51273 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
51274 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
51275 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
51276 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
51277 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
51278 +3 2 2 4 4 4
51279 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
51280 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
51281 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
51282 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51283 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
51284 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
51285 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51286 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
51287 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
51288 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
51289 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
51290 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
51291 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
51292 +4 4 4 4 4 4
51293 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
51294 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
51295 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
51296 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
51297 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
51298 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
51299 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
51300 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
51301 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
51302 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
51303 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
51304 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
51305 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
51306 +4 4 4 4 4 4
51307 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
51308 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
51309 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
51310 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
51311 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
51312 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51313 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
51314 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
51315 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
51316 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
51317 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
51318 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
51319 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
51320 +5 5 5 5 5 5
51321 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
51322 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
51323 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
51324 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
51325 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
51326 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51327 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
51328 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
51329 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
51330 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
51331 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
51332 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
51333 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51334 +5 5 5 4 4 4
51335 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
51336 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
51337 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
51338 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
51339 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51340 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
51341 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
51342 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
51343 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
51344 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
51345 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
51346 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51348 +4 4 4 4 4 4
51349 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
51350 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
51351 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
51352 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
51353 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
51354 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51355 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51356 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
51357 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
51358 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
51359 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
51360 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
51361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51362 +4 4 4 4 4 4
51363 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
51364 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
51365 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
51366 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51367 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51368 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51369 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51370 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51371 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51372 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51373 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
51374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51376 +4 4 4 4 4 4
51377 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51378 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
51379 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
51380 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
51381 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51382 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51383 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51384 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
51385 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
51386 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
51387 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
51388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51390 +4 4 4 4 4 4
51391 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
51392 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51393 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51394 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51395 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51396 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51397 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51398 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51399 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51400 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51401 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51404 +4 4 4 4 4 4
51405 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51406 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51407 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51408 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51409 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51410 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51411 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51412 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51413 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51414 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51415 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51418 +4 4 4 4 4 4
51419 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51420 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51421 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51422 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51423 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51424 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51425 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51426 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51427 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51428 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51429 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51432 +4 4 4 4 4 4
51433 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51434 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51435 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
51436 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51437 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
51438 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
51439 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
51440 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
51441 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
51442 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
51443 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51446 +4 4 4 4 4 4
51447 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51448 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51449 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51450 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51451 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51452 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51453 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51454 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51455 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51456 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51457 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51460 +4 4 4 4 4 4
51461 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51462 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51463 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51464 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51465 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51466 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51467 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51468 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51469 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51470 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51471 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51474 +4 4 4 4 4 4
51475 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51476 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51477 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51478 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51479 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51480 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51481 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51482 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51483 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51484 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51485 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51488 +4 4 4 4 4 4
51489 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51490 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51491 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51492 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51493 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51494 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51495 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51496 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51497 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51498 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51499 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51502 +4 4 4 4 4 4
51503 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51504 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51505 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51506 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51507 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51508 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51509 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51510 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51511 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51512 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51513 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51516 +4 4 4 4 4 4
51517 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51518 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51519 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51520 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51521 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51522 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51523 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51524 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51525 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51526 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51527 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51530 +4 4 4 4 4 4
51531 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51532 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51533 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51534 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51535 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51536 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51537 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51538 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51539 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51540 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51541 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51544 +4 4 4 4 4 4
51545 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51546 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51547 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51548 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51549 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51550 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51551 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51552 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51553 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51554 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51555 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51558 +4 4 4 4 4 4
51559 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51560 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51561 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51562 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51563 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51564 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51565 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51566 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51567 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51568 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51569 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51572 +4 4 4 4 4 4
51573 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51574 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51575 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51576 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51577 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51578 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51579 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51580 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51581 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51582 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51583 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51586 +4 4 4 4 4 4
51587 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51588 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51589 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51590 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51591 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51592 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51593 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51594 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51595 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51596 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51597 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51600 +4 4 4 4 4 4
51601 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51602 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51603 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51604 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51605 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51606 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51607 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51608 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51609 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51610 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51611 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51614 +4 4 4 4 4 4
51615 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51616 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51617 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51618 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51619 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51620 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51621 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51622 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51623 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51624 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51625 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51628 +4 4 4 4 4 4
51629 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51630 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51631 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51632 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51633 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51634 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51635 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51636 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51637 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51638 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51639 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51642 +4 4 4 4 4 4
51643 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51644 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51645 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51646 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51647 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51648 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51649 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51650 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51651 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51652 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51653 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51656 +4 4 4 4 4 4
51657 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51658 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51659 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51660 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51661 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51662 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51663 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51664 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51665 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51666 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51667 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51670 +4 4 4 4 4 4
51671 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51672 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51673 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51674 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51675 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51676 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51677 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51678 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51679 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51680 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51681 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51684 +4 4 4 4 4 4
51685 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51686 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51687 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51688 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51689 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51690 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51691 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51692 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51693 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51694 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51695 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51698 +4 4 4 4 4 4
51699 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51700 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51701 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51702 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51703 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51704 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51705 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51706 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51707 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51708 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51709 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51712 +4 4 4 4 4 4
51713 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51714 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51715 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51716 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51717 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51718 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51719 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51720 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51721 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51722 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51723 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51726 +4 4 4 4 4 4
51727 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51728 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51729 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51730 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51731 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51732 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51733 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51734 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51735 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51736 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51737 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51740 +4 4 4 4 4 4
51741 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51742 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51743 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51744 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51745 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51746 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51747 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51748 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51749 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51750 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51754 +4 4 4 4 4 4
51755 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51756 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51757 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51758 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51759 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51760 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51761 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51762 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51763 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51764 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51768 +4 4 4 4 4 4
51769 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51770 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51771 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51772 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51773 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51774 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51775 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51776 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51777 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51778 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51782 +4 4 4 4 4 4
51783 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51784 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51785 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51786 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51787 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51788 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51789 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51790 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51791 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51792 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51796 +4 4 4 4 4 4
51797 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51798 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51799 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51800 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51801 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51802 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51803 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51804 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51805 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51810 +4 4 4 4 4 4
51811 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51812 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51813 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51814 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51815 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51816 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51817 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51818 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51819 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51824 +4 4 4 4 4 4
51825 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51826 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51827 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51828 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51829 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51830 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51831 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51832 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51833 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51838 +4 4 4 4 4 4
51839 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51840 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51841 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51842 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51843 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51844 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51845 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51846 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51852 +4 4 4 4 4 4
51853 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51854 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51855 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51856 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51857 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51858 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51859 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51860 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51866 +4 4 4 4 4 4
51867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51868 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51869 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51870 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51871 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51872 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51873 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51874 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51880 +4 4 4 4 4 4
51881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51882 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51883 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51884 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51885 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51886 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51887 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51888 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51894 +4 4 4 4 4 4
51895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51896 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51897 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51898 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51899 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51900 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51901 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51902 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51908 +4 4 4 4 4 4
51909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51911 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51912 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51913 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51914 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51915 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51916 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51922 +4 4 4 4 4 4
51923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51926 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51927 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51928 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51929 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51936 +4 4 4 4 4 4
51937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51938 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51939 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51940 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51941 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51942 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51943 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51950 +4 4 4 4 4 4
51951 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51952 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51953 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51954 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51955 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51956 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51957 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51964 +4 4 4 4 4 4
51965 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51966 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51967 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51968 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51969 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51970 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51971 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51978 +4 4 4 4 4 4
51979 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51981 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51982 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51983 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51984 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51985 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51992 +4 4 4 4 4 4
51993 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51995 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51996 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51997 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51998 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51999 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52006 +4 4 4 4 4 4
52007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52009 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52010 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52011 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52012 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52013 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52020 +4 4 4 4 4 4
52021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52022 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52023 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52024 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52025 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52026 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52034 +4 4 4 4 4 4
52035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52036 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52037 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52039 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52040 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52048 +4 4 4 4 4 4
52049 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52050 index fe92eed..106e085 100644
52051 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52052 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52053 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52054 struct mb862xxfb_par *par = info->par;
52055
52056 if (info->var.bits_per_pixel == 32) {
52057 - info->fbops->fb_fillrect = cfb_fillrect;
52058 - info->fbops->fb_copyarea = cfb_copyarea;
52059 - info->fbops->fb_imageblit = cfb_imageblit;
52060 + pax_open_kernel();
52061 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52062 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52063 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52064 + pax_close_kernel();
52065 } else {
52066 outreg(disp, GC_L0EM, 3);
52067 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52068 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52069 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52070 + pax_open_kernel();
52071 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52072 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52073 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52074 + pax_close_kernel();
52075 }
52076 outreg(draw, GDC_REG_DRAW_BASE, 0);
52077 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52078 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52079 index ff22871..b129bed 100644
52080 --- a/drivers/video/nvidia/nvidia.c
52081 +++ b/drivers/video/nvidia/nvidia.c
52082 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52083 info->fix.line_length = (info->var.xres_virtual *
52084 info->var.bits_per_pixel) >> 3;
52085 if (info->var.accel_flags) {
52086 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52087 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52088 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52089 - info->fbops->fb_sync = nvidiafb_sync;
52090 + pax_open_kernel();
52091 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52092 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52093 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52094 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52095 + pax_close_kernel();
52096 info->pixmap.scan_align = 4;
52097 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52098 info->flags |= FBINFO_READS_FAST;
52099 NVResetGraphics(info);
52100 } else {
52101 - info->fbops->fb_imageblit = cfb_imageblit;
52102 - info->fbops->fb_fillrect = cfb_fillrect;
52103 - info->fbops->fb_copyarea = cfb_copyarea;
52104 - info->fbops->fb_sync = NULL;
52105 + pax_open_kernel();
52106 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52107 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52108 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52109 + *(void **)&info->fbops->fb_sync = NULL;
52110 + pax_close_kernel();
52111 info->pixmap.scan_align = 1;
52112 info->flags |= FBINFO_HWACCEL_DISABLED;
52113 info->flags &= ~FBINFO_READS_FAST;
52114 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52115 info->pixmap.size = 8 * 1024;
52116 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52117
52118 - if (!hwcur)
52119 - info->fbops->fb_cursor = NULL;
52120 + if (!hwcur) {
52121 + pax_open_kernel();
52122 + *(void **)&info->fbops->fb_cursor = NULL;
52123 + pax_close_kernel();
52124 + }
52125
52126 info->var.accel_flags = (!noaccel);
52127
52128 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52129 index 05c2dc3..ea1f391 100644
52130 --- a/drivers/video/s1d13xxxfb.c
52131 +++ b/drivers/video/s1d13xxxfb.c
52132 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52133
52134 switch(prod_id) {
52135 case S1D13506_PROD_ID: /* activate acceleration */
52136 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52137 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52138 + pax_open_kernel();
52139 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52140 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52141 + pax_close_kernel();
52142 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52143 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52144 break;
52145 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52146 index e188ada..aac63c8 100644
52147 --- a/drivers/video/smscufx.c
52148 +++ b/drivers/video/smscufx.c
52149 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52150 fb_deferred_io_cleanup(info);
52151 kfree(info->fbdefio);
52152 info->fbdefio = NULL;
52153 - info->fbops->fb_mmap = ufx_ops_mmap;
52154 + pax_open_kernel();
52155 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52156 + pax_close_kernel();
52157 }
52158
52159 pr_debug("released /dev/fb%d user=%d count=%d",
52160 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52161 index d2e5bc3..4cb05d1 100644
52162 --- a/drivers/video/udlfb.c
52163 +++ b/drivers/video/udlfb.c
52164 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52165 dlfb_urb_completion(urb);
52166
52167 error:
52168 - atomic_add(bytes_sent, &dev->bytes_sent);
52169 - atomic_add(bytes_identical, &dev->bytes_identical);
52170 - atomic_add(width*height*2, &dev->bytes_rendered);
52171 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52172 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52173 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52174 end_cycles = get_cycles();
52175 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52176 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52177 >> 10)), /* Kcycles */
52178 &dev->cpu_kcycles_used);
52179
52180 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52181 dlfb_urb_completion(urb);
52182
52183 error:
52184 - atomic_add(bytes_sent, &dev->bytes_sent);
52185 - atomic_add(bytes_identical, &dev->bytes_identical);
52186 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52187 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52188 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52189 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52190 end_cycles = get_cycles();
52191 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52192 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52193 >> 10)), /* Kcycles */
52194 &dev->cpu_kcycles_used);
52195 }
52196 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52197 fb_deferred_io_cleanup(info);
52198 kfree(info->fbdefio);
52199 info->fbdefio = NULL;
52200 - info->fbops->fb_mmap = dlfb_ops_mmap;
52201 + pax_open_kernel();
52202 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52203 + pax_close_kernel();
52204 }
52205
52206 pr_warn("released /dev/fb%d user=%d count=%d\n",
52207 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52208 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52209 struct dlfb_data *dev = fb_info->par;
52210 return snprintf(buf, PAGE_SIZE, "%u\n",
52211 - atomic_read(&dev->bytes_rendered));
52212 + atomic_read_unchecked(&dev->bytes_rendered));
52213 }
52214
52215 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52216 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52217 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52218 struct dlfb_data *dev = fb_info->par;
52219 return snprintf(buf, PAGE_SIZE, "%u\n",
52220 - atomic_read(&dev->bytes_identical));
52221 + atomic_read_unchecked(&dev->bytes_identical));
52222 }
52223
52224 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52225 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52226 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52227 struct dlfb_data *dev = fb_info->par;
52228 return snprintf(buf, PAGE_SIZE, "%u\n",
52229 - atomic_read(&dev->bytes_sent));
52230 + atomic_read_unchecked(&dev->bytes_sent));
52231 }
52232
52233 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52234 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52235 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52236 struct dlfb_data *dev = fb_info->par;
52237 return snprintf(buf, PAGE_SIZE, "%u\n",
52238 - atomic_read(&dev->cpu_kcycles_used));
52239 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52240 }
52241
52242 static ssize_t edid_show(
52243 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52244 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52245 struct dlfb_data *dev = fb_info->par;
52246
52247 - atomic_set(&dev->bytes_rendered, 0);
52248 - atomic_set(&dev->bytes_identical, 0);
52249 - atomic_set(&dev->bytes_sent, 0);
52250 - atomic_set(&dev->cpu_kcycles_used, 0);
52251 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52252 + atomic_set_unchecked(&dev->bytes_identical, 0);
52253 + atomic_set_unchecked(&dev->bytes_sent, 0);
52254 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52255
52256 return count;
52257 }
52258 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
52259 index 7aec6f3..e3b2d55 100644
52260 --- a/drivers/video/uvesafb.c
52261 +++ b/drivers/video/uvesafb.c
52262 @@ -19,6 +19,7 @@
52263 #include <linux/io.h>
52264 #include <linux/mutex.h>
52265 #include <linux/slab.h>
52266 +#include <linux/moduleloader.h>
52267 #include <video/edid.h>
52268 #include <video/uvesafb.h>
52269 #ifdef CONFIG_X86
52270 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
52271 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
52272 par->pmi_setpal = par->ypan = 0;
52273 } else {
52274 +
52275 +#ifdef CONFIG_PAX_KERNEXEC
52276 +#ifdef CONFIG_MODULES
52277 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
52278 +#endif
52279 + if (!par->pmi_code) {
52280 + par->pmi_setpal = par->ypan = 0;
52281 + return 0;
52282 + }
52283 +#endif
52284 +
52285 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
52286 + task->t.regs.edi);
52287 +
52288 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52289 + pax_open_kernel();
52290 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
52291 + pax_close_kernel();
52292 +
52293 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
52294 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
52295 +#else
52296 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
52297 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
52298 +#endif
52299 +
52300 printk(KERN_INFO "uvesafb: protected mode interface info at "
52301 "%04x:%04x\n",
52302 (u16)task->t.regs.es, (u16)task->t.regs.edi);
52303 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
52304 par->ypan = ypan;
52305
52306 if (par->pmi_setpal || par->ypan) {
52307 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
52308 if (__supported_pte_mask & _PAGE_NX) {
52309 par->pmi_setpal = par->ypan = 0;
52310 printk(KERN_WARNING "uvesafb: NX protection is active, "
52311 "better not use the PMI.\n");
52312 - } else {
52313 + } else
52314 +#endif
52315 uvesafb_vbe_getpmi(task, par);
52316 - }
52317 }
52318 #else
52319 /* The protected mode interface is not available on non-x86. */
52320 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52321 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
52322
52323 /* Disable blanking if the user requested so. */
52324 - if (!blank)
52325 - info->fbops->fb_blank = NULL;
52326 + if (!blank) {
52327 + pax_open_kernel();
52328 + *(void **)&info->fbops->fb_blank = NULL;
52329 + pax_close_kernel();
52330 + }
52331
52332 /*
52333 * Find out how much IO memory is required for the mode with
52334 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52335 info->flags = FBINFO_FLAG_DEFAULT |
52336 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
52337
52338 - if (!par->ypan)
52339 - info->fbops->fb_pan_display = NULL;
52340 + if (!par->ypan) {
52341 + pax_open_kernel();
52342 + *(void **)&info->fbops->fb_pan_display = NULL;
52343 + pax_close_kernel();
52344 + }
52345 }
52346
52347 static void uvesafb_init_mtrr(struct fb_info *info)
52348 @@ -1796,6 +1826,11 @@ out:
52349 if (par->vbe_modes)
52350 kfree(par->vbe_modes);
52351
52352 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52353 + if (par->pmi_code)
52354 + module_free_exec(NULL, par->pmi_code);
52355 +#endif
52356 +
52357 framebuffer_release(info);
52358 return err;
52359 }
52360 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
52361 kfree(par->vbe_state_orig);
52362 if (par->vbe_state_saved)
52363 kfree(par->vbe_state_saved);
52364 +
52365 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52366 + if (par->pmi_code)
52367 + module_free_exec(NULL, par->pmi_code);
52368 +#endif
52369 +
52370 }
52371
52372 framebuffer_release(info);
52373 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
52374 index bd83233..7d8a5aa 100644
52375 --- a/drivers/video/vesafb.c
52376 +++ b/drivers/video/vesafb.c
52377 @@ -9,6 +9,7 @@
52378 */
52379
52380 #include <linux/module.h>
52381 +#include <linux/moduleloader.h>
52382 #include <linux/kernel.h>
52383 #include <linux/errno.h>
52384 #include <linux/string.h>
52385 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
52386 static int vram_total; /* Set total amount of memory */
52387 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52388 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52389 -static void (*pmi_start)(void) __read_mostly;
52390 -static void (*pmi_pal) (void) __read_mostly;
52391 +static void (*pmi_start)(void) __read_only;
52392 +static void (*pmi_pal) (void) __read_only;
52393 static int depth __read_mostly;
52394 static int vga_compat __read_mostly;
52395 /* --------------------------------------------------------------------- */
52396 @@ -234,6 +235,7 @@ static int vesafb_probe(struct platform_device *dev)
52397 unsigned int size_remap;
52398 unsigned int size_total;
52399 char *option = NULL;
52400 + void *pmi_code = NULL;
52401
52402 /* ignore error return of fb_get_options */
52403 fb_get_options("vesafb", &option);
52404 @@ -280,10 +282,6 @@ static int vesafb_probe(struct platform_device *dev)
52405 size_remap = size_total;
52406 vesafb_fix.smem_len = size_remap;
52407
52408 -#ifndef __i386__
52409 - screen_info.vesapm_seg = 0;
52410 -#endif
52411 -
52412 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52413 printk(KERN_WARNING
52414 "vesafb: cannot reserve video memory at 0x%lx\n",
52415 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
52416 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52417 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52418
52419 +#ifdef __i386__
52420 +
52421 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52422 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52423 + if (!pmi_code)
52424 +#elif !defined(CONFIG_PAX_KERNEXEC)
52425 + if (0)
52426 +#endif
52427 +
52428 +#endif
52429 + screen_info.vesapm_seg = 0;
52430 +
52431 if (screen_info.vesapm_seg) {
52432 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52433 - screen_info.vesapm_seg,screen_info.vesapm_off);
52434 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52435 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52436 }
52437
52438 if (screen_info.vesapm_seg < 0xc000)
52439 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
52440
52441 if (ypan || pmi_setpal) {
52442 unsigned short *pmi_base;
52443 +
52444 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
52445 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
52446 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52447 +
52448 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52449 + pax_open_kernel();
52450 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52451 +#else
52452 + pmi_code = pmi_base;
52453 +#endif
52454 +
52455 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52456 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52457 +
52458 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52459 + pmi_start = ktva_ktla(pmi_start);
52460 + pmi_pal = ktva_ktla(pmi_pal);
52461 + pax_close_kernel();
52462 +#endif
52463 +
52464 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52465 if (pmi_base[3]) {
52466 printk(KERN_INFO "vesafb: pmi: ports = ");
52467 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
52468 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52469 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52470
52471 - if (!ypan)
52472 - info->fbops->fb_pan_display = NULL;
52473 + if (!ypan) {
52474 + pax_open_kernel();
52475 + *(void **)&info->fbops->fb_pan_display = NULL;
52476 + pax_close_kernel();
52477 + }
52478
52479 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52480 err = -ENOMEM;
52481 @@ -493,6 +522,11 @@ static int vesafb_probe(struct platform_device *dev)
52482 info->node, info->fix.id);
52483 return 0;
52484 err:
52485 +
52486 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52487 + module_free_exec(NULL, pmi_code);
52488 +#endif
52489 +
52490 if (info->screen_base)
52491 iounmap(info->screen_base);
52492 framebuffer_release(info);
52493 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52494 index 88714ae..16c2e11 100644
52495 --- a/drivers/video/via/via_clock.h
52496 +++ b/drivers/video/via/via_clock.h
52497 @@ -56,7 +56,7 @@ struct via_clock {
52498
52499 void (*set_engine_pll_state)(u8 state);
52500 void (*set_engine_pll)(struct via_pll_config config);
52501 -};
52502 +} __no_const;
52503
52504
52505 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52506 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52507 index fef20db..d28b1ab 100644
52508 --- a/drivers/xen/xenfs/xenstored.c
52509 +++ b/drivers/xen/xenfs/xenstored.c
52510 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52511 static int xsd_kva_open(struct inode *inode, struct file *file)
52512 {
52513 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52514 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52515 + NULL);
52516 +#else
52517 xen_store_interface);
52518 +#endif
52519 +
52520 if (!file->private_data)
52521 return -ENOMEM;
52522 return 0;
52523 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52524 index 9ff073f..05cef23 100644
52525 --- a/fs/9p/vfs_addr.c
52526 +++ b/fs/9p/vfs_addr.c
52527 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52528
52529 retval = v9fs_file_write_internal(inode,
52530 v9inode->writeback_fid,
52531 - (__force const char __user *)buffer,
52532 + (const char __force_user *)buffer,
52533 len, &offset, 0);
52534 if (retval > 0)
52535 retval = 0;
52536 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52537 index 94de6d1..8d81256 100644
52538 --- a/fs/9p/vfs_inode.c
52539 +++ b/fs/9p/vfs_inode.c
52540 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52541 void
52542 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52543 {
52544 - char *s = nd_get_link(nd);
52545 + const char *s = nd_get_link(nd);
52546
52547 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52548 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52549 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52550 index 370b24c..ff0be7b 100644
52551 --- a/fs/Kconfig.binfmt
52552 +++ b/fs/Kconfig.binfmt
52553 @@ -103,7 +103,7 @@ config HAVE_AOUT
52554
52555 config BINFMT_AOUT
52556 tristate "Kernel support for a.out and ECOFF binaries"
52557 - depends on HAVE_AOUT
52558 + depends on HAVE_AOUT && BROKEN
52559 ---help---
52560 A.out (Assembler.OUTput) is a set of formats for libraries and
52561 executables used in the earliest versions of UNIX. Linux used
52562 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52563 index 789bc25..fafaeea 100644
52564 --- a/fs/afs/inode.c
52565 +++ b/fs/afs/inode.c
52566 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52567 struct afs_vnode *vnode;
52568 struct super_block *sb;
52569 struct inode *inode;
52570 - static atomic_t afs_autocell_ino;
52571 + static atomic_unchecked_t afs_autocell_ino;
52572
52573 _enter("{%x:%u},%*.*s,",
52574 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52575 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52576 data.fid.unique = 0;
52577 data.fid.vnode = 0;
52578
52579 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52580 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52581 afs_iget5_autocell_test, afs_iget5_set,
52582 &data);
52583 if (!inode) {
52584 diff --git a/fs/aio.c b/fs/aio.c
52585 index 067e3d3..634a850 100644
52586 --- a/fs/aio.c
52587 +++ b/fs/aio.c
52588 @@ -280,7 +280,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52589 size += sizeof(struct io_event) * nr_events;
52590
52591 nr_pages = PFN_UP(size);
52592 - if (nr_pages < 0)
52593 + if (nr_pages <= 0)
52594 return -EINVAL;
52595
52596 file = anon_inode_getfile_private("[aio]", &aio_ring_fops, ctx, O_RDWR);
52597 diff --git a/fs/attr.c b/fs/attr.c
52598 index 1449adb..a2038c2 100644
52599 --- a/fs/attr.c
52600 +++ b/fs/attr.c
52601 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52602 unsigned long limit;
52603
52604 limit = rlimit(RLIMIT_FSIZE);
52605 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52606 if (limit != RLIM_INFINITY && offset > limit)
52607 goto out_sig;
52608 if (offset > inode->i_sb->s_maxbytes)
52609 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52610 index 689e40d..515cac5 100644
52611 --- a/fs/autofs4/waitq.c
52612 +++ b/fs/autofs4/waitq.c
52613 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52614 {
52615 unsigned long sigpipe, flags;
52616 mm_segment_t fs;
52617 - const char *data = (const char *)addr;
52618 + const char __user *data = (const char __force_user *)addr;
52619 ssize_t wr = 0;
52620
52621 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52622 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52623 return 1;
52624 }
52625
52626 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52627 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52628 +#endif
52629 +
52630 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52631 enum autofs_notify notify)
52632 {
52633 @@ -373,7 +377,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52634
52635 /* If this is a direct mount request create a dummy name */
52636 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52637 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52638 + /* this name does get written to userland via autofs4_write() */
52639 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52640 +#else
52641 qstr.len = sprintf(name, "%p", dentry);
52642 +#endif
52643 else {
52644 qstr.len = autofs4_getpath(sbi, dentry, &name);
52645 if (!qstr.len) {
52646 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52647 index 2722387..56059b5 100644
52648 --- a/fs/befs/endian.h
52649 +++ b/fs/befs/endian.h
52650 @@ -11,7 +11,7 @@
52651
52652 #include <asm/byteorder.h>
52653
52654 -static inline u64
52655 +static inline u64 __intentional_overflow(-1)
52656 fs64_to_cpu(const struct super_block *sb, fs64 n)
52657 {
52658 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52659 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52660 return (__force fs64)cpu_to_be64(n);
52661 }
52662
52663 -static inline u32
52664 +static inline u32 __intentional_overflow(-1)
52665 fs32_to_cpu(const struct super_block *sb, fs32 n)
52666 {
52667 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52668 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
52669 return (__force fs32)cpu_to_be32(n);
52670 }
52671
52672 -static inline u16
52673 +static inline u16 __intentional_overflow(-1)
52674 fs16_to_cpu(const struct super_block *sb, fs16 n)
52675 {
52676 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52677 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52678 index e9c75e2..1baece1 100644
52679 --- a/fs/befs/linuxvfs.c
52680 +++ b/fs/befs/linuxvfs.c
52681 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52682 {
52683 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52684 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52685 - char *link = nd_get_link(nd);
52686 + const char *link = nd_get_link(nd);
52687 if (!IS_ERR(link))
52688 kfree(link);
52689 }
52690 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52691 index 89dec7f..361b0d75 100644
52692 --- a/fs/binfmt_aout.c
52693 +++ b/fs/binfmt_aout.c
52694 @@ -16,6 +16,7 @@
52695 #include <linux/string.h>
52696 #include <linux/fs.h>
52697 #include <linux/file.h>
52698 +#include <linux/security.h>
52699 #include <linux/stat.h>
52700 #include <linux/fcntl.h>
52701 #include <linux/ptrace.h>
52702 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52703 #endif
52704 # define START_STACK(u) ((void __user *)u.start_stack)
52705
52706 + memset(&dump, 0, sizeof(dump));
52707 +
52708 fs = get_fs();
52709 set_fs(KERNEL_DS);
52710 has_dumped = 1;
52711 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52712
52713 /* If the size of the dump file exceeds the rlimit, then see what would happen
52714 if we wrote the stack, but not the data area. */
52715 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52716 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52717 dump.u_dsize = 0;
52718
52719 /* Make sure we have enough room to write the stack and data areas. */
52720 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52721 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52722 dump.u_ssize = 0;
52723
52724 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52725 rlim = rlimit(RLIMIT_DATA);
52726 if (rlim >= RLIM_INFINITY)
52727 rlim = ~0;
52728 +
52729 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52730 if (ex.a_data + ex.a_bss > rlim)
52731 return -ENOMEM;
52732
52733 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52734
52735 install_exec_creds(bprm);
52736
52737 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52738 + current->mm->pax_flags = 0UL;
52739 +#endif
52740 +
52741 +#ifdef CONFIG_PAX_PAGEEXEC
52742 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52743 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52744 +
52745 +#ifdef CONFIG_PAX_EMUTRAMP
52746 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52747 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52748 +#endif
52749 +
52750 +#ifdef CONFIG_PAX_MPROTECT
52751 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52752 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52753 +#endif
52754 +
52755 + }
52756 +#endif
52757 +
52758 if (N_MAGIC(ex) == OMAGIC) {
52759 unsigned long text_addr, map_size;
52760 loff_t pos;
52761 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52762 }
52763
52764 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52765 - PROT_READ | PROT_WRITE | PROT_EXEC,
52766 + PROT_READ | PROT_WRITE,
52767 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52768 fd_offset + ex.a_text);
52769 if (error != N_DATADDR(ex)) {
52770 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52771 index 4c94a79..f428019 100644
52772 --- a/fs/binfmt_elf.c
52773 +++ b/fs/binfmt_elf.c
52774 @@ -34,6 +34,7 @@
52775 #include <linux/utsname.h>
52776 #include <linux/coredump.h>
52777 #include <linux/sched.h>
52778 +#include <linux/xattr.h>
52779 #include <asm/uaccess.h>
52780 #include <asm/param.h>
52781 #include <asm/page.h>
52782 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52783 #define elf_core_dump NULL
52784 #endif
52785
52786 +#ifdef CONFIG_PAX_MPROTECT
52787 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52788 +#endif
52789 +
52790 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52791 +static void elf_handle_mmap(struct file *file);
52792 +#endif
52793 +
52794 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52795 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52796 #else
52797 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52798 .load_binary = load_elf_binary,
52799 .load_shlib = load_elf_library,
52800 .core_dump = elf_core_dump,
52801 +
52802 +#ifdef CONFIG_PAX_MPROTECT
52803 + .handle_mprotect= elf_handle_mprotect,
52804 +#endif
52805 +
52806 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52807 + .handle_mmap = elf_handle_mmap,
52808 +#endif
52809 +
52810 .min_coredump = ELF_EXEC_PAGESIZE,
52811 };
52812
52813 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52814
52815 static int set_brk(unsigned long start, unsigned long end)
52816 {
52817 + unsigned long e = end;
52818 +
52819 start = ELF_PAGEALIGN(start);
52820 end = ELF_PAGEALIGN(end);
52821 if (end > start) {
52822 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52823 if (BAD_ADDR(addr))
52824 return addr;
52825 }
52826 - current->mm->start_brk = current->mm->brk = end;
52827 + current->mm->start_brk = current->mm->brk = e;
52828 return 0;
52829 }
52830
52831 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52832 elf_addr_t __user *u_rand_bytes;
52833 const char *k_platform = ELF_PLATFORM;
52834 const char *k_base_platform = ELF_BASE_PLATFORM;
52835 - unsigned char k_rand_bytes[16];
52836 + u32 k_rand_bytes[4];
52837 int items;
52838 elf_addr_t *elf_info;
52839 int ei_index = 0;
52840 const struct cred *cred = current_cred();
52841 struct vm_area_struct *vma;
52842 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52843
52844 /*
52845 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52846 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52847 * Generate 16 random bytes for userspace PRNG seeding.
52848 */
52849 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52850 - u_rand_bytes = (elf_addr_t __user *)
52851 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52852 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52853 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52854 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52855 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52856 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52857 + u_rand_bytes = (elf_addr_t __user *) p;
52858 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52859 return -EFAULT;
52860
52861 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52862 return -EFAULT;
52863 current->mm->env_end = p;
52864
52865 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52866 +
52867 /* Put the elf_info on the stack in the right place. */
52868 sp = (elf_addr_t __user *)envp + 1;
52869 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52870 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52871 return -EFAULT;
52872 return 0;
52873 }
52874 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52875 an ELF header */
52876
52877 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52878 - struct file *interpreter, unsigned long *interp_map_addr,
52879 - unsigned long no_base)
52880 + struct file *interpreter, unsigned long no_base)
52881 {
52882 struct elf_phdr *elf_phdata;
52883 struct elf_phdr *eppnt;
52884 - unsigned long load_addr = 0;
52885 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52886 int load_addr_set = 0;
52887 unsigned long last_bss = 0, elf_bss = 0;
52888 - unsigned long error = ~0UL;
52889 + unsigned long error = -EINVAL;
52890 unsigned long total_size;
52891 int retval, i, size;
52892
52893 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52894 goto out_close;
52895 }
52896
52897 +#ifdef CONFIG_PAX_SEGMEXEC
52898 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52899 + pax_task_size = SEGMEXEC_TASK_SIZE;
52900 +#endif
52901 +
52902 eppnt = elf_phdata;
52903 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52904 if (eppnt->p_type == PT_LOAD) {
52905 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52906 map_addr = elf_map(interpreter, load_addr + vaddr,
52907 eppnt, elf_prot, elf_type, total_size);
52908 total_size = 0;
52909 - if (!*interp_map_addr)
52910 - *interp_map_addr = map_addr;
52911 error = map_addr;
52912 if (BAD_ADDR(map_addr))
52913 goto out_close;
52914 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52915 k = load_addr + eppnt->p_vaddr;
52916 if (BAD_ADDR(k) ||
52917 eppnt->p_filesz > eppnt->p_memsz ||
52918 - eppnt->p_memsz > TASK_SIZE ||
52919 - TASK_SIZE - eppnt->p_memsz < k) {
52920 + eppnt->p_memsz > pax_task_size ||
52921 + pax_task_size - eppnt->p_memsz < k) {
52922 error = -ENOMEM;
52923 goto out_close;
52924 }
52925 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52926 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52927
52928 /* Map the last of the bss segment */
52929 - error = vm_brk(elf_bss, last_bss - elf_bss);
52930 - if (BAD_ADDR(error))
52931 - goto out_close;
52932 + if (last_bss > elf_bss) {
52933 + error = vm_brk(elf_bss, last_bss - elf_bss);
52934 + if (BAD_ADDR(error))
52935 + goto out_close;
52936 + }
52937 }
52938
52939 error = load_addr;
52940 @@ -538,6 +569,315 @@ out:
52941 return error;
52942 }
52943
52944 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52945 +#ifdef CONFIG_PAX_SOFTMODE
52946 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52947 +{
52948 + unsigned long pax_flags = 0UL;
52949 +
52950 +#ifdef CONFIG_PAX_PAGEEXEC
52951 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52952 + pax_flags |= MF_PAX_PAGEEXEC;
52953 +#endif
52954 +
52955 +#ifdef CONFIG_PAX_SEGMEXEC
52956 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52957 + pax_flags |= MF_PAX_SEGMEXEC;
52958 +#endif
52959 +
52960 +#ifdef CONFIG_PAX_EMUTRAMP
52961 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52962 + pax_flags |= MF_PAX_EMUTRAMP;
52963 +#endif
52964 +
52965 +#ifdef CONFIG_PAX_MPROTECT
52966 + if (elf_phdata->p_flags & PF_MPROTECT)
52967 + pax_flags |= MF_PAX_MPROTECT;
52968 +#endif
52969 +
52970 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52971 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52972 + pax_flags |= MF_PAX_RANDMMAP;
52973 +#endif
52974 +
52975 + return pax_flags;
52976 +}
52977 +#endif
52978 +
52979 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52980 +{
52981 + unsigned long pax_flags = 0UL;
52982 +
52983 +#ifdef CONFIG_PAX_PAGEEXEC
52984 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52985 + pax_flags |= MF_PAX_PAGEEXEC;
52986 +#endif
52987 +
52988 +#ifdef CONFIG_PAX_SEGMEXEC
52989 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52990 + pax_flags |= MF_PAX_SEGMEXEC;
52991 +#endif
52992 +
52993 +#ifdef CONFIG_PAX_EMUTRAMP
52994 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52995 + pax_flags |= MF_PAX_EMUTRAMP;
52996 +#endif
52997 +
52998 +#ifdef CONFIG_PAX_MPROTECT
52999 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53000 + pax_flags |= MF_PAX_MPROTECT;
53001 +#endif
53002 +
53003 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53004 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53005 + pax_flags |= MF_PAX_RANDMMAP;
53006 +#endif
53007 +
53008 + return pax_flags;
53009 +}
53010 +#endif
53011 +
53012 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53013 +#ifdef CONFIG_PAX_SOFTMODE
53014 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53015 +{
53016 + unsigned long pax_flags = 0UL;
53017 +
53018 +#ifdef CONFIG_PAX_PAGEEXEC
53019 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53020 + pax_flags |= MF_PAX_PAGEEXEC;
53021 +#endif
53022 +
53023 +#ifdef CONFIG_PAX_SEGMEXEC
53024 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53025 + pax_flags |= MF_PAX_SEGMEXEC;
53026 +#endif
53027 +
53028 +#ifdef CONFIG_PAX_EMUTRAMP
53029 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53030 + pax_flags |= MF_PAX_EMUTRAMP;
53031 +#endif
53032 +
53033 +#ifdef CONFIG_PAX_MPROTECT
53034 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53035 + pax_flags |= MF_PAX_MPROTECT;
53036 +#endif
53037 +
53038 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53039 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53040 + pax_flags |= MF_PAX_RANDMMAP;
53041 +#endif
53042 +
53043 + return pax_flags;
53044 +}
53045 +#endif
53046 +
53047 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53048 +{
53049 + unsigned long pax_flags = 0UL;
53050 +
53051 +#ifdef CONFIG_PAX_PAGEEXEC
53052 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53053 + pax_flags |= MF_PAX_PAGEEXEC;
53054 +#endif
53055 +
53056 +#ifdef CONFIG_PAX_SEGMEXEC
53057 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53058 + pax_flags |= MF_PAX_SEGMEXEC;
53059 +#endif
53060 +
53061 +#ifdef CONFIG_PAX_EMUTRAMP
53062 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53063 + pax_flags |= MF_PAX_EMUTRAMP;
53064 +#endif
53065 +
53066 +#ifdef CONFIG_PAX_MPROTECT
53067 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53068 + pax_flags |= MF_PAX_MPROTECT;
53069 +#endif
53070 +
53071 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53072 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53073 + pax_flags |= MF_PAX_RANDMMAP;
53074 +#endif
53075 +
53076 + return pax_flags;
53077 +}
53078 +#endif
53079 +
53080 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53081 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53082 +{
53083 + unsigned long pax_flags = 0UL;
53084 +
53085 +#ifdef CONFIG_PAX_EI_PAX
53086 +
53087 +#ifdef CONFIG_PAX_PAGEEXEC
53088 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53089 + pax_flags |= MF_PAX_PAGEEXEC;
53090 +#endif
53091 +
53092 +#ifdef CONFIG_PAX_SEGMEXEC
53093 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53094 + pax_flags |= MF_PAX_SEGMEXEC;
53095 +#endif
53096 +
53097 +#ifdef CONFIG_PAX_EMUTRAMP
53098 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53099 + pax_flags |= MF_PAX_EMUTRAMP;
53100 +#endif
53101 +
53102 +#ifdef CONFIG_PAX_MPROTECT
53103 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53104 + pax_flags |= MF_PAX_MPROTECT;
53105 +#endif
53106 +
53107 +#ifdef CONFIG_PAX_ASLR
53108 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53109 + pax_flags |= MF_PAX_RANDMMAP;
53110 +#endif
53111 +
53112 +#else
53113 +
53114 +#ifdef CONFIG_PAX_PAGEEXEC
53115 + pax_flags |= MF_PAX_PAGEEXEC;
53116 +#endif
53117 +
53118 +#ifdef CONFIG_PAX_SEGMEXEC
53119 + pax_flags |= MF_PAX_SEGMEXEC;
53120 +#endif
53121 +
53122 +#ifdef CONFIG_PAX_MPROTECT
53123 + pax_flags |= MF_PAX_MPROTECT;
53124 +#endif
53125 +
53126 +#ifdef CONFIG_PAX_RANDMMAP
53127 + if (randomize_va_space)
53128 + pax_flags |= MF_PAX_RANDMMAP;
53129 +#endif
53130 +
53131 +#endif
53132 +
53133 + return pax_flags;
53134 +}
53135 +
53136 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53137 +{
53138 +
53139 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53140 + unsigned long i;
53141 +
53142 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53143 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53144 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53145 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53146 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53147 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53148 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53149 + return ~0UL;
53150 +
53151 +#ifdef CONFIG_PAX_SOFTMODE
53152 + if (pax_softmode)
53153 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53154 + else
53155 +#endif
53156 +
53157 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53158 + break;
53159 + }
53160 +#endif
53161 +
53162 + return ~0UL;
53163 +}
53164 +
53165 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53166 +{
53167 +
53168 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53169 + ssize_t xattr_size, i;
53170 + unsigned char xattr_value[sizeof("pemrs") - 1];
53171 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53172 +
53173 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53174 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
53175 + return ~0UL;
53176 +
53177 + for (i = 0; i < xattr_size; i++)
53178 + switch (xattr_value[i]) {
53179 + default:
53180 + return ~0UL;
53181 +
53182 +#define parse_flag(option1, option2, flag) \
53183 + case option1: \
53184 + if (pax_flags_hardmode & MF_PAX_##flag) \
53185 + return ~0UL; \
53186 + pax_flags_hardmode |= MF_PAX_##flag; \
53187 + break; \
53188 + case option2: \
53189 + if (pax_flags_softmode & MF_PAX_##flag) \
53190 + return ~0UL; \
53191 + pax_flags_softmode |= MF_PAX_##flag; \
53192 + break;
53193 +
53194 + parse_flag('p', 'P', PAGEEXEC);
53195 + parse_flag('e', 'E', EMUTRAMP);
53196 + parse_flag('m', 'M', MPROTECT);
53197 + parse_flag('r', 'R', RANDMMAP);
53198 + parse_flag('s', 'S', SEGMEXEC);
53199 +
53200 +#undef parse_flag
53201 + }
53202 +
53203 + if (pax_flags_hardmode & pax_flags_softmode)
53204 + return ~0UL;
53205 +
53206 +#ifdef CONFIG_PAX_SOFTMODE
53207 + if (pax_softmode)
53208 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53209 + else
53210 +#endif
53211 +
53212 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53213 +#else
53214 + return ~0UL;
53215 +#endif
53216 +
53217 +}
53218 +
53219 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53220 +{
53221 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53222 +
53223 + pax_flags = pax_parse_ei_pax(elf_ex);
53224 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53225 + xattr_pax_flags = pax_parse_xattr_pax(file);
53226 +
53227 + if (pt_pax_flags == ~0UL)
53228 + pt_pax_flags = xattr_pax_flags;
53229 + else if (xattr_pax_flags == ~0UL)
53230 + xattr_pax_flags = pt_pax_flags;
53231 + if (pt_pax_flags != xattr_pax_flags)
53232 + return -EINVAL;
53233 + if (pt_pax_flags != ~0UL)
53234 + pax_flags = pt_pax_flags;
53235 +
53236 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53237 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53238 + if ((__supported_pte_mask & _PAGE_NX))
53239 + pax_flags &= ~MF_PAX_SEGMEXEC;
53240 + else
53241 + pax_flags &= ~MF_PAX_PAGEEXEC;
53242 + }
53243 +#endif
53244 +
53245 + if (0 > pax_check_flags(&pax_flags))
53246 + return -EINVAL;
53247 +
53248 + current->mm->pax_flags = pax_flags;
53249 + return 0;
53250 +}
53251 +#endif
53252 +
53253 /*
53254 * These are the functions used to load ELF style executables and shared
53255 * libraries. There is no binary dependent code anywhere else.
53256 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
53257 {
53258 unsigned int random_variable = 0;
53259
53260 +#ifdef CONFIG_PAX_RANDUSTACK
53261 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
53262 + return stack_top - current->mm->delta_stack;
53263 +#endif
53264 +
53265 if ((current->flags & PF_RANDOMIZE) &&
53266 !(current->personality & ADDR_NO_RANDOMIZE)) {
53267 random_variable = get_random_int() & STACK_RND_MASK;
53268 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
53269 unsigned long load_addr = 0, load_bias = 0;
53270 int load_addr_set = 0;
53271 char * elf_interpreter = NULL;
53272 - unsigned long error;
53273 + unsigned long error = 0;
53274 struct elf_phdr *elf_ppnt, *elf_phdata;
53275 unsigned long elf_bss, elf_brk;
53276 int retval, i;
53277 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
53278 unsigned long start_code, end_code, start_data, end_data;
53279 unsigned long reloc_func_desc __maybe_unused = 0;
53280 int executable_stack = EXSTACK_DEFAULT;
53281 - unsigned long def_flags = 0;
53282 struct pt_regs *regs = current_pt_regs();
53283 struct {
53284 struct elfhdr elf_ex;
53285 struct elfhdr interp_elf_ex;
53286 } *loc;
53287 + unsigned long pax_task_size = TASK_SIZE;
53288
53289 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
53290 if (!loc) {
53291 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
53292 goto out_free_dentry;
53293
53294 /* OK, This is the point of no return */
53295 - current->mm->def_flags = def_flags;
53296 +
53297 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53298 + current->mm->pax_flags = 0UL;
53299 +#endif
53300 +
53301 +#ifdef CONFIG_PAX_DLRESOLVE
53302 + current->mm->call_dl_resolve = 0UL;
53303 +#endif
53304 +
53305 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
53306 + current->mm->call_syscall = 0UL;
53307 +#endif
53308 +
53309 +#ifdef CONFIG_PAX_ASLR
53310 + current->mm->delta_mmap = 0UL;
53311 + current->mm->delta_stack = 0UL;
53312 +#endif
53313 +
53314 + current->mm->def_flags = 0;
53315 +
53316 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53317 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
53318 + send_sig(SIGKILL, current, 0);
53319 + goto out_free_dentry;
53320 + }
53321 +#endif
53322 +
53323 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
53324 + pax_set_initial_flags(bprm);
53325 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
53326 + if (pax_set_initial_flags_func)
53327 + (pax_set_initial_flags_func)(bprm);
53328 +#endif
53329 +
53330 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
53331 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
53332 + current->mm->context.user_cs_limit = PAGE_SIZE;
53333 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
53334 + }
53335 +#endif
53336 +
53337 +#ifdef CONFIG_PAX_SEGMEXEC
53338 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
53339 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
53340 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
53341 + pax_task_size = SEGMEXEC_TASK_SIZE;
53342 + current->mm->def_flags |= VM_NOHUGEPAGE;
53343 + }
53344 +#endif
53345 +
53346 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
53347 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53348 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
53349 + put_cpu();
53350 + }
53351 +#endif
53352
53353 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53354 may depend on the personality. */
53355 SET_PERSONALITY(loc->elf_ex);
53356 +
53357 +#ifdef CONFIG_PAX_ASLR
53358 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53359 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
53360 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
53361 + }
53362 +#endif
53363 +
53364 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53365 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53366 + executable_stack = EXSTACK_DISABLE_X;
53367 + current->personality &= ~READ_IMPLIES_EXEC;
53368 + } else
53369 +#endif
53370 +
53371 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53372 current->personality |= READ_IMPLIES_EXEC;
53373
53374 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53375 #else
53376 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53377 #endif
53378 +
53379 +#ifdef CONFIG_PAX_RANDMMAP
53380 + /* PaX: randomize base address at the default exe base if requested */
53381 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53382 +#ifdef CONFIG_SPARC64
53383 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53384 +#else
53385 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53386 +#endif
53387 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53388 + elf_flags |= MAP_FIXED;
53389 + }
53390 +#endif
53391 +
53392 }
53393
53394 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53395 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53396 * allowed task size. Note that p_filesz must always be
53397 * <= p_memsz so it is only necessary to check p_memsz.
53398 */
53399 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53400 - elf_ppnt->p_memsz > TASK_SIZE ||
53401 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53402 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53403 + elf_ppnt->p_memsz > pax_task_size ||
53404 + pax_task_size - elf_ppnt->p_memsz < k) {
53405 /* set_brk can never work. Avoid overflows. */
53406 send_sig(SIGKILL, current, 0);
53407 retval = -EINVAL;
53408 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53409 goto out_free_dentry;
53410 }
53411 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53412 - send_sig(SIGSEGV, current, 0);
53413 - retval = -EFAULT; /* Nobody gets to see this, but.. */
53414 - goto out_free_dentry;
53415 + /*
53416 + * This bss-zeroing can fail if the ELF
53417 + * file specifies odd protections. So
53418 + * we don't check the return value
53419 + */
53420 }
53421
53422 +#ifdef CONFIG_PAX_RANDMMAP
53423 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53424 + unsigned long start, size, flags;
53425 + vm_flags_t vm_flags;
53426 +
53427 + start = ELF_PAGEALIGN(elf_brk);
53428 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53429 + flags = MAP_FIXED | MAP_PRIVATE;
53430 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53431 +
53432 + down_write(&current->mm->mmap_sem);
53433 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53434 + retval = -ENOMEM;
53435 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53436 +// if (current->personality & ADDR_NO_RANDOMIZE)
53437 +// vm_flags |= VM_READ | VM_MAYREAD;
53438 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53439 + retval = IS_ERR_VALUE(start) ? start : 0;
53440 + }
53441 + up_write(&current->mm->mmap_sem);
53442 + if (retval == 0)
53443 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53444 + if (retval < 0) {
53445 + send_sig(SIGKILL, current, 0);
53446 + goto out_free_dentry;
53447 + }
53448 + }
53449 +#endif
53450 +
53451 if (elf_interpreter) {
53452 - unsigned long interp_map_addr = 0;
53453 -
53454 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53455 interpreter,
53456 - &interp_map_addr,
53457 load_bias);
53458 if (!IS_ERR((void *)elf_entry)) {
53459 /*
53460 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53461 * Decide what to dump of a segment, part, all or none.
53462 */
53463 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53464 - unsigned long mm_flags)
53465 + unsigned long mm_flags, long signr)
53466 {
53467 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53468
53469 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53470 if (vma->vm_file == NULL)
53471 return 0;
53472
53473 - if (FILTER(MAPPED_PRIVATE))
53474 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53475 goto whole;
53476
53477 /*
53478 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53479 {
53480 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53481 int i = 0;
53482 - do
53483 + do {
53484 i += 2;
53485 - while (auxv[i - 2] != AT_NULL);
53486 + } while (auxv[i - 2] != AT_NULL);
53487 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53488 }
53489
53490 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53491 {
53492 mm_segment_t old_fs = get_fs();
53493 set_fs(KERNEL_DS);
53494 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53495 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53496 set_fs(old_fs);
53497 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53498 }
53499 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53500 }
53501
53502 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53503 - unsigned long mm_flags)
53504 + struct coredump_params *cprm)
53505 {
53506 struct vm_area_struct *vma;
53507 size_t size = 0;
53508
53509 for (vma = first_vma(current, gate_vma); vma != NULL;
53510 vma = next_vma(vma, gate_vma))
53511 - size += vma_dump_size(vma, mm_flags);
53512 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53513 return size;
53514 }
53515
53516 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53517
53518 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53519
53520 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53521 + offset += elf_core_vma_data_size(gate_vma, cprm);
53522 offset += elf_core_extra_data_size();
53523 e_shoff = offset;
53524
53525 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53526 offset = dataoff;
53527
53528 size += sizeof(*elf);
53529 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53530 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53531 goto end_coredump;
53532
53533 size += sizeof(*phdr4note);
53534 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53535 if (size > cprm->limit
53536 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53537 goto end_coredump;
53538 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53539 phdr.p_offset = offset;
53540 phdr.p_vaddr = vma->vm_start;
53541 phdr.p_paddr = 0;
53542 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53543 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53544 phdr.p_memsz = vma->vm_end - vma->vm_start;
53545 offset += phdr.p_filesz;
53546 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53547 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53548 phdr.p_align = ELF_EXEC_PAGESIZE;
53549
53550 size += sizeof(phdr);
53551 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53552 if (size > cprm->limit
53553 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53554 goto end_coredump;
53555 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53556 unsigned long addr;
53557 unsigned long end;
53558
53559 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53560 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53561
53562 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53563 struct page *page;
53564 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53565 page = get_dump_page(addr);
53566 if (page) {
53567 void *kaddr = kmap(page);
53568 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53569 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53570 !dump_write(cprm->file, kaddr,
53571 PAGE_SIZE);
53572 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53573
53574 if (e_phnum == PN_XNUM) {
53575 size += sizeof(*shdr4extnum);
53576 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53577 if (size > cprm->limit
53578 || !dump_write(cprm->file, shdr4extnum,
53579 sizeof(*shdr4extnum)))
53580 @@ -2235,6 +2697,167 @@ out:
53581
53582 #endif /* CONFIG_ELF_CORE */
53583
53584 +#ifdef CONFIG_PAX_MPROTECT
53585 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53586 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53587 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53588 + *
53589 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53590 + * basis because we want to allow the common case and not the special ones.
53591 + */
53592 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53593 +{
53594 + struct elfhdr elf_h;
53595 + struct elf_phdr elf_p;
53596 + unsigned long i;
53597 + unsigned long oldflags;
53598 + bool is_textrel_rw, is_textrel_rx, is_relro;
53599 +
53600 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53601 + return;
53602 +
53603 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53604 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53605 +
53606 +#ifdef CONFIG_PAX_ELFRELOCS
53607 + /* possible TEXTREL */
53608 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53609 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53610 +#else
53611 + is_textrel_rw = false;
53612 + is_textrel_rx = false;
53613 +#endif
53614 +
53615 + /* possible RELRO */
53616 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53617 +
53618 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53619 + return;
53620 +
53621 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53622 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53623 +
53624 +#ifdef CONFIG_PAX_ETEXECRELOCS
53625 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53626 +#else
53627 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53628 +#endif
53629 +
53630 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53631 + !elf_check_arch(&elf_h) ||
53632 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53633 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53634 + return;
53635 +
53636 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53637 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53638 + return;
53639 + switch (elf_p.p_type) {
53640 + case PT_DYNAMIC:
53641 + if (!is_textrel_rw && !is_textrel_rx)
53642 + continue;
53643 + i = 0UL;
53644 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53645 + elf_dyn dyn;
53646 +
53647 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53648 + break;
53649 + if (dyn.d_tag == DT_NULL)
53650 + break;
53651 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53652 + gr_log_textrel(vma);
53653 + if (is_textrel_rw)
53654 + vma->vm_flags |= VM_MAYWRITE;
53655 + else
53656 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53657 + vma->vm_flags &= ~VM_MAYWRITE;
53658 + break;
53659 + }
53660 + i++;
53661 + }
53662 + is_textrel_rw = false;
53663 + is_textrel_rx = false;
53664 + continue;
53665 +
53666 + case PT_GNU_RELRO:
53667 + if (!is_relro)
53668 + continue;
53669 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53670 + vma->vm_flags &= ~VM_MAYWRITE;
53671 + is_relro = false;
53672 + continue;
53673 +
53674 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53675 + case PT_PAX_FLAGS: {
53676 + const char *msg_mprotect = "", *msg_emutramp = "";
53677 + char *buffer_lib, *buffer_exe;
53678 +
53679 + if (elf_p.p_flags & PF_NOMPROTECT)
53680 + msg_mprotect = "MPROTECT disabled";
53681 +
53682 +#ifdef CONFIG_PAX_EMUTRAMP
53683 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53684 + msg_emutramp = "EMUTRAMP enabled";
53685 +#endif
53686 +
53687 + if (!msg_mprotect[0] && !msg_emutramp[0])
53688 + continue;
53689 +
53690 + if (!printk_ratelimit())
53691 + continue;
53692 +
53693 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53694 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53695 + if (buffer_lib && buffer_exe) {
53696 + char *path_lib, *path_exe;
53697 +
53698 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53699 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53700 +
53701 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53702 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53703 +
53704 + }
53705 + free_page((unsigned long)buffer_exe);
53706 + free_page((unsigned long)buffer_lib);
53707 + continue;
53708 + }
53709 +#endif
53710 +
53711 + }
53712 + }
53713 +}
53714 +#endif
53715 +
53716 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53717 +
53718 +extern int grsec_enable_log_rwxmaps;
53719 +
53720 +static void elf_handle_mmap(struct file *file)
53721 +{
53722 + struct elfhdr elf_h;
53723 + struct elf_phdr elf_p;
53724 + unsigned long i;
53725 +
53726 + if (!grsec_enable_log_rwxmaps)
53727 + return;
53728 +
53729 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53730 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53731 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53732 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53733 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53734 + return;
53735 +
53736 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53737 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53738 + return;
53739 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53740 + gr_log_ptgnustack(file);
53741 + }
53742 +}
53743 +#endif
53744 +
53745 static int __init init_elf_binfmt(void)
53746 {
53747 register_binfmt(&elf_format);
53748 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53749 index d50bbe5..af3b649 100644
53750 --- a/fs/binfmt_flat.c
53751 +++ b/fs/binfmt_flat.c
53752 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53753 realdatastart = (unsigned long) -ENOMEM;
53754 printk("Unable to allocate RAM for process data, errno %d\n",
53755 (int)-realdatastart);
53756 + down_write(&current->mm->mmap_sem);
53757 vm_munmap(textpos, text_len);
53758 + up_write(&current->mm->mmap_sem);
53759 ret = realdatastart;
53760 goto err;
53761 }
53762 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53763 }
53764 if (IS_ERR_VALUE(result)) {
53765 printk("Unable to read data+bss, errno %d\n", (int)-result);
53766 + down_write(&current->mm->mmap_sem);
53767 vm_munmap(textpos, text_len);
53768 vm_munmap(realdatastart, len);
53769 + up_write(&current->mm->mmap_sem);
53770 ret = result;
53771 goto err;
53772 }
53773 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53774 }
53775 if (IS_ERR_VALUE(result)) {
53776 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53777 + down_write(&current->mm->mmap_sem);
53778 vm_munmap(textpos, text_len + data_len + extra +
53779 MAX_SHARED_LIBS * sizeof(unsigned long));
53780 + up_write(&current->mm->mmap_sem);
53781 ret = result;
53782 goto err;
53783 }
53784 diff --git a/fs/bio.c b/fs/bio.c
53785 index ea5035d..a2932eb 100644
53786 --- a/fs/bio.c
53787 +++ b/fs/bio.c
53788 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53789 /*
53790 * Overflow, abort
53791 */
53792 - if (end < start)
53793 + if (end < start || end - start > INT_MAX - nr_pages)
53794 return ERR_PTR(-EINVAL);
53795
53796 nr_pages += end - start;
53797 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53798 /*
53799 * Overflow, abort
53800 */
53801 - if (end < start)
53802 + if (end < start || end - start > INT_MAX - nr_pages)
53803 return ERR_PTR(-EINVAL);
53804
53805 nr_pages += end - start;
53806 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53807 const int read = bio_data_dir(bio) == READ;
53808 struct bio_map_data *bmd = bio->bi_private;
53809 int i;
53810 - char *p = bmd->sgvecs[0].iov_base;
53811 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53812
53813 bio_for_each_segment_all(bvec, bio, i) {
53814 char *addr = page_address(bvec->bv_page);
53815 diff --git a/fs/block_dev.c b/fs/block_dev.c
53816 index 1e86823..8e34695 100644
53817 --- a/fs/block_dev.c
53818 +++ b/fs/block_dev.c
53819 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53820 else if (bdev->bd_contains == bdev)
53821 return true; /* is a whole device which isn't held */
53822
53823 - else if (whole->bd_holder == bd_may_claim)
53824 + else if (whole->bd_holder == (void *)bd_may_claim)
53825 return true; /* is a partition of a device that is being partitioned */
53826 else if (whole->bd_holder != NULL)
53827 return false; /* is a partition of a held device */
53828 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53829 index 61b5bcd..7eeede8 100644
53830 --- a/fs/btrfs/ctree.c
53831 +++ b/fs/btrfs/ctree.c
53832 @@ -1028,9 +1028,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53833 free_extent_buffer(buf);
53834 add_root_to_dirty_list(root);
53835 } else {
53836 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53837 - parent_start = parent->start;
53838 - else
53839 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53840 + if (parent)
53841 + parent_start = parent->start;
53842 + else
53843 + parent_start = 0;
53844 + } else
53845 parent_start = 0;
53846
53847 WARN_ON(trans->transid != btrfs_header_generation(parent));
53848 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53849 index cbd9523..5cca781 100644
53850 --- a/fs/btrfs/delayed-inode.c
53851 +++ b/fs/btrfs/delayed-inode.c
53852 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53853
53854 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53855 {
53856 - int seq = atomic_inc_return(&delayed_root->items_seq);
53857 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53858 if ((atomic_dec_return(&delayed_root->items) <
53859 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53860 waitqueue_active(&delayed_root->wait))
53861 @@ -1378,7 +1378,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53862 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53863 int seq, int count)
53864 {
53865 - int val = atomic_read(&delayed_root->items_seq);
53866 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53867
53868 if (val < seq || val >= seq + count)
53869 return 1;
53870 @@ -1395,7 +1395,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53871 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53872 return;
53873
53874 - seq = atomic_read(&delayed_root->items_seq);
53875 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53876
53877 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53878 int ret;
53879 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53880 index a4b38f9..f86a509 100644
53881 --- a/fs/btrfs/delayed-inode.h
53882 +++ b/fs/btrfs/delayed-inode.h
53883 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53884 */
53885 struct list_head prepare_list;
53886 atomic_t items; /* for delayed items */
53887 - atomic_t items_seq; /* for delayed items */
53888 + atomic_unchecked_t items_seq; /* for delayed items */
53889 int nodes; /* for delayed nodes */
53890 wait_queue_head_t wait;
53891 };
53892 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53893 struct btrfs_delayed_root *delayed_root)
53894 {
53895 atomic_set(&delayed_root->items, 0);
53896 - atomic_set(&delayed_root->items_seq, 0);
53897 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53898 delayed_root->nodes = 0;
53899 spin_lock_init(&delayed_root->lock);
53900 init_waitqueue_head(&delayed_root->wait);
53901 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53902 index 9d46f60..a8f09eb 100644
53903 --- a/fs/btrfs/ioctl.c
53904 +++ b/fs/btrfs/ioctl.c
53905 @@ -3464,9 +3464,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53906 for (i = 0; i < num_types; i++) {
53907 struct btrfs_space_info *tmp;
53908
53909 + /* Don't copy in more than we allocated */
53910 if (!slot_count)
53911 break;
53912
53913 + slot_count--;
53914 +
53915 info = NULL;
53916 rcu_read_lock();
53917 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53918 @@ -3488,10 +3491,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53919 memcpy(dest, &space, sizeof(space));
53920 dest++;
53921 space_args.total_spaces++;
53922 - slot_count--;
53923 }
53924 - if (!slot_count)
53925 - break;
53926 }
53927 up_read(&info->groups_sem);
53928 }
53929 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53930 index e913328..a34fb36 100644
53931 --- a/fs/btrfs/super.c
53932 +++ b/fs/btrfs/super.c
53933 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53934 function, line, errstr);
53935 return;
53936 }
53937 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53938 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53939 /* Wake up anybody who may be waiting on this transaction */
53940 wake_up(&root->fs_info->transaction_wait);
53941 wake_up(&root->fs_info->transaction_blocked_wait);
53942 diff --git a/fs/buffer.c b/fs/buffer.c
53943 index 6024877..7bd000a 100644
53944 --- a/fs/buffer.c
53945 +++ b/fs/buffer.c
53946 @@ -3426,7 +3426,7 @@ void __init buffer_init(void)
53947 bh_cachep = kmem_cache_create("buffer_head",
53948 sizeof(struct buffer_head), 0,
53949 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53950 - SLAB_MEM_SPREAD),
53951 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53952 NULL);
53953
53954 /*
53955 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53956 index 622f469..e8d2d55 100644
53957 --- a/fs/cachefiles/bind.c
53958 +++ b/fs/cachefiles/bind.c
53959 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53960 args);
53961
53962 /* start by checking things over */
53963 - ASSERT(cache->fstop_percent >= 0 &&
53964 - cache->fstop_percent < cache->fcull_percent &&
53965 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53966 cache->fcull_percent < cache->frun_percent &&
53967 cache->frun_percent < 100);
53968
53969 - ASSERT(cache->bstop_percent >= 0 &&
53970 - cache->bstop_percent < cache->bcull_percent &&
53971 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53972 cache->bcull_percent < cache->brun_percent &&
53973 cache->brun_percent < 100);
53974
53975 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53976 index 0a1467b..6a53245 100644
53977 --- a/fs/cachefiles/daemon.c
53978 +++ b/fs/cachefiles/daemon.c
53979 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53980 if (n > buflen)
53981 return -EMSGSIZE;
53982
53983 - if (copy_to_user(_buffer, buffer, n) != 0)
53984 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53985 return -EFAULT;
53986
53987 return n;
53988 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53989 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53990 return -EIO;
53991
53992 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53993 + if (datalen > PAGE_SIZE - 1)
53994 return -EOPNOTSUPP;
53995
53996 /* drag the command string into the kernel so we can parse it */
53997 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53998 if (args[0] != '%' || args[1] != '\0')
53999 return -EINVAL;
54000
54001 - if (fstop < 0 || fstop >= cache->fcull_percent)
54002 + if (fstop >= cache->fcull_percent)
54003 return cachefiles_daemon_range_error(cache, args);
54004
54005 cache->fstop_percent = fstop;
54006 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54007 if (args[0] != '%' || args[1] != '\0')
54008 return -EINVAL;
54009
54010 - if (bstop < 0 || bstop >= cache->bcull_percent)
54011 + if (bstop >= cache->bcull_percent)
54012 return cachefiles_daemon_range_error(cache, args);
54013
54014 cache->bstop_percent = bstop;
54015 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54016 index 5349473..d6c0b93 100644
54017 --- a/fs/cachefiles/internal.h
54018 +++ b/fs/cachefiles/internal.h
54019 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54020 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54021 struct rb_root active_nodes; /* active nodes (can't be culled) */
54022 rwlock_t active_lock; /* lock for active_nodes */
54023 - atomic_t gravecounter; /* graveyard uniquifier */
54024 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54025 unsigned frun_percent; /* when to stop culling (% files) */
54026 unsigned fcull_percent; /* when to start culling (% files) */
54027 unsigned fstop_percent; /* when to stop allocating (% files) */
54028 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54029 * proc.c
54030 */
54031 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54032 -extern atomic_t cachefiles_lookup_histogram[HZ];
54033 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54034 -extern atomic_t cachefiles_create_histogram[HZ];
54035 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54036 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54037 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54038
54039 extern int __init cachefiles_proc_init(void);
54040 extern void cachefiles_proc_cleanup(void);
54041 static inline
54042 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54043 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54044 {
54045 unsigned long jif = jiffies - start_jif;
54046 if (jif >= HZ)
54047 jif = HZ - 1;
54048 - atomic_inc(&histogram[jif]);
54049 + atomic_inc_unchecked(&histogram[jif]);
54050 }
54051
54052 #else
54053 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54054 index f4a08d7..5aa4599 100644
54055 --- a/fs/cachefiles/namei.c
54056 +++ b/fs/cachefiles/namei.c
54057 @@ -317,7 +317,7 @@ try_again:
54058 /* first step is to make up a grave dentry in the graveyard */
54059 sprintf(nbuffer, "%08x%08x",
54060 (uint32_t) get_seconds(),
54061 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54062 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54063
54064 /* do the multiway lock magic */
54065 trap = lock_rename(cache->graveyard, dir);
54066 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54067 index eccd339..4c1d995 100644
54068 --- a/fs/cachefiles/proc.c
54069 +++ b/fs/cachefiles/proc.c
54070 @@ -14,9 +14,9 @@
54071 #include <linux/seq_file.h>
54072 #include "internal.h"
54073
54074 -atomic_t cachefiles_lookup_histogram[HZ];
54075 -atomic_t cachefiles_mkdir_histogram[HZ];
54076 -atomic_t cachefiles_create_histogram[HZ];
54077 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54078 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54079 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54080
54081 /*
54082 * display the latency histogram
54083 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54084 return 0;
54085 default:
54086 index = (unsigned long) v - 3;
54087 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54088 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54089 - z = atomic_read(&cachefiles_create_histogram[index]);
54090 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54091 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54092 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54093 if (x == 0 && y == 0 && z == 0)
54094 return 0;
54095
54096 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54097 index ebaff36..7e3ea26 100644
54098 --- a/fs/cachefiles/rdwr.c
54099 +++ b/fs/cachefiles/rdwr.c
54100 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54101 old_fs = get_fs();
54102 set_fs(KERNEL_DS);
54103 ret = file->f_op->write(
54104 - file, (const void __user *) data, len, &pos);
54105 + file, (const void __force_user *) data, len, &pos);
54106 set_fs(old_fs);
54107 kunmap(page);
54108 file_end_write(file);
54109 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54110 index 868b61d..58835a5 100644
54111 --- a/fs/ceph/dir.c
54112 +++ b/fs/ceph/dir.c
54113 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
54114 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54115 struct ceph_mds_client *mdsc = fsc->mdsc;
54116 unsigned frag = fpos_frag(ctx->pos);
54117 - int off = fpos_off(ctx->pos);
54118 + unsigned int off = fpos_off(ctx->pos);
54119 int err;
54120 u32 ftype;
54121 struct ceph_mds_reply_info_parsed *rinfo;
54122 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54123 index 6a0951e..03fac6d 100644
54124 --- a/fs/ceph/super.c
54125 +++ b/fs/ceph/super.c
54126 @@ -870,7 +870,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54127 /*
54128 * construct our own bdi so we can control readahead, etc.
54129 */
54130 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54131 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54132
54133 static int ceph_register_bdi(struct super_block *sb,
54134 struct ceph_fs_client *fsc)
54135 @@ -887,7 +887,7 @@ static int ceph_register_bdi(struct super_block *sb,
54136 default_backing_dev_info.ra_pages;
54137
54138 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54139 - atomic_long_inc_return(&bdi_seq));
54140 + atomic_long_inc_return_unchecked(&bdi_seq));
54141 if (!err)
54142 sb->s_bdi = &fsc->backing_dev_info;
54143 return err;
54144 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54145 index f3ac415..3d2420c 100644
54146 --- a/fs/cifs/cifs_debug.c
54147 +++ b/fs/cifs/cifs_debug.c
54148 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54149
54150 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54151 #ifdef CONFIG_CIFS_STATS2
54152 - atomic_set(&totBufAllocCount, 0);
54153 - atomic_set(&totSmBufAllocCount, 0);
54154 + atomic_set_unchecked(&totBufAllocCount, 0);
54155 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54156 #endif /* CONFIG_CIFS_STATS2 */
54157 spin_lock(&cifs_tcp_ses_lock);
54158 list_for_each(tmp1, &cifs_tcp_ses_list) {
54159 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54160 tcon = list_entry(tmp3,
54161 struct cifs_tcon,
54162 tcon_list);
54163 - atomic_set(&tcon->num_smbs_sent, 0);
54164 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54165 if (server->ops->clear_stats)
54166 server->ops->clear_stats(tcon);
54167 }
54168 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54169 smBufAllocCount.counter, cifs_min_small);
54170 #ifdef CONFIG_CIFS_STATS2
54171 seq_printf(m, "Total Large %d Small %d Allocations\n",
54172 - atomic_read(&totBufAllocCount),
54173 - atomic_read(&totSmBufAllocCount));
54174 + atomic_read_unchecked(&totBufAllocCount),
54175 + atomic_read_unchecked(&totSmBufAllocCount));
54176 #endif /* CONFIG_CIFS_STATS2 */
54177
54178 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54179 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54180 if (tcon->need_reconnect)
54181 seq_puts(m, "\tDISCONNECTED ");
54182 seq_printf(m, "\nSMBs: %d",
54183 - atomic_read(&tcon->num_smbs_sent));
54184 + atomic_read_unchecked(&tcon->num_smbs_sent));
54185 if (server->ops->print_stats)
54186 server->ops->print_stats(m, tcon);
54187 }
54188 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54189 index 77fc5e1..e3d13e6 100644
54190 --- a/fs/cifs/cifsfs.c
54191 +++ b/fs/cifs/cifsfs.c
54192 @@ -1056,7 +1056,7 @@ cifs_init_request_bufs(void)
54193 */
54194 cifs_req_cachep = kmem_cache_create("cifs_request",
54195 CIFSMaxBufSize + max_hdr_size, 0,
54196 - SLAB_HWCACHE_ALIGN, NULL);
54197 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54198 if (cifs_req_cachep == NULL)
54199 return -ENOMEM;
54200
54201 @@ -1083,7 +1083,7 @@ cifs_init_request_bufs(void)
54202 efficient to alloc 1 per page off the slab compared to 17K (5page)
54203 alloc of large cifs buffers even when page debugging is on */
54204 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54205 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54206 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54207 NULL);
54208 if (cifs_sm_req_cachep == NULL) {
54209 mempool_destroy(cifs_req_poolp);
54210 @@ -1168,8 +1168,8 @@ init_cifs(void)
54211 atomic_set(&bufAllocCount, 0);
54212 atomic_set(&smBufAllocCount, 0);
54213 #ifdef CONFIG_CIFS_STATS2
54214 - atomic_set(&totBufAllocCount, 0);
54215 - atomic_set(&totSmBufAllocCount, 0);
54216 + atomic_set_unchecked(&totBufAllocCount, 0);
54217 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54218 #endif /* CONFIG_CIFS_STATS2 */
54219
54220 atomic_set(&midCount, 0);
54221 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54222 index 52b6f6c..68db1f4 100644
54223 --- a/fs/cifs/cifsglob.h
54224 +++ b/fs/cifs/cifsglob.h
54225 @@ -758,35 +758,35 @@ struct cifs_tcon {
54226 __u16 Flags; /* optional support bits */
54227 enum statusEnum tidStatus;
54228 #ifdef CONFIG_CIFS_STATS
54229 - atomic_t num_smbs_sent;
54230 + atomic_unchecked_t num_smbs_sent;
54231 union {
54232 struct {
54233 - atomic_t num_writes;
54234 - atomic_t num_reads;
54235 - atomic_t num_flushes;
54236 - atomic_t num_oplock_brks;
54237 - atomic_t num_opens;
54238 - atomic_t num_closes;
54239 - atomic_t num_deletes;
54240 - atomic_t num_mkdirs;
54241 - atomic_t num_posixopens;
54242 - atomic_t num_posixmkdirs;
54243 - atomic_t num_rmdirs;
54244 - atomic_t num_renames;
54245 - atomic_t num_t2renames;
54246 - atomic_t num_ffirst;
54247 - atomic_t num_fnext;
54248 - atomic_t num_fclose;
54249 - atomic_t num_hardlinks;
54250 - atomic_t num_symlinks;
54251 - atomic_t num_locks;
54252 - atomic_t num_acl_get;
54253 - atomic_t num_acl_set;
54254 + atomic_unchecked_t num_writes;
54255 + atomic_unchecked_t num_reads;
54256 + atomic_unchecked_t num_flushes;
54257 + atomic_unchecked_t num_oplock_brks;
54258 + atomic_unchecked_t num_opens;
54259 + atomic_unchecked_t num_closes;
54260 + atomic_unchecked_t num_deletes;
54261 + atomic_unchecked_t num_mkdirs;
54262 + atomic_unchecked_t num_posixopens;
54263 + atomic_unchecked_t num_posixmkdirs;
54264 + atomic_unchecked_t num_rmdirs;
54265 + atomic_unchecked_t num_renames;
54266 + atomic_unchecked_t num_t2renames;
54267 + atomic_unchecked_t num_ffirst;
54268 + atomic_unchecked_t num_fnext;
54269 + atomic_unchecked_t num_fclose;
54270 + atomic_unchecked_t num_hardlinks;
54271 + atomic_unchecked_t num_symlinks;
54272 + atomic_unchecked_t num_locks;
54273 + atomic_unchecked_t num_acl_get;
54274 + atomic_unchecked_t num_acl_set;
54275 } cifs_stats;
54276 #ifdef CONFIG_CIFS_SMB2
54277 struct {
54278 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54279 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54280 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54281 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54282 } smb2_stats;
54283 #endif /* CONFIG_CIFS_SMB2 */
54284 } stats;
54285 @@ -1111,7 +1111,7 @@ convert_delimiter(char *path, char delim)
54286 }
54287
54288 #ifdef CONFIG_CIFS_STATS
54289 -#define cifs_stats_inc atomic_inc
54290 +#define cifs_stats_inc atomic_inc_unchecked
54291
54292 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
54293 unsigned int bytes)
54294 @@ -1477,8 +1477,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
54295 /* Various Debug counters */
54296 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
54297 #ifdef CONFIG_CIFS_STATS2
54298 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
54299 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
54300 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
54301 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
54302 #endif
54303 GLOBAL_EXTERN atomic_t smBufAllocCount;
54304 GLOBAL_EXTERN atomic_t midCount;
54305 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
54306 index 7e36ceb..109252f 100644
54307 --- a/fs/cifs/link.c
54308 +++ b/fs/cifs/link.c
54309 @@ -624,7 +624,7 @@ symlink_exit:
54310
54311 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
54312 {
54313 - char *p = nd_get_link(nd);
54314 + const char *p = nd_get_link(nd);
54315 if (!IS_ERR(p))
54316 kfree(p);
54317 }
54318 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
54319 index 138a011..cf9e13a 100644
54320 --- a/fs/cifs/misc.c
54321 +++ b/fs/cifs/misc.c
54322 @@ -170,7 +170,7 @@ cifs_buf_get(void)
54323 memset(ret_buf, 0, buf_size + 3);
54324 atomic_inc(&bufAllocCount);
54325 #ifdef CONFIG_CIFS_STATS2
54326 - atomic_inc(&totBufAllocCount);
54327 + atomic_inc_unchecked(&totBufAllocCount);
54328 #endif /* CONFIG_CIFS_STATS2 */
54329 }
54330
54331 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
54332 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
54333 atomic_inc(&smBufAllocCount);
54334 #ifdef CONFIG_CIFS_STATS2
54335 - atomic_inc(&totSmBufAllocCount);
54336 + atomic_inc_unchecked(&totSmBufAllocCount);
54337 #endif /* CONFIG_CIFS_STATS2 */
54338
54339 }
54340 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
54341 index 8233b17..2b83e95 100644
54342 --- a/fs/cifs/smb1ops.c
54343 +++ b/fs/cifs/smb1ops.c
54344 @@ -590,27 +590,27 @@ static void
54345 cifs_clear_stats(struct cifs_tcon *tcon)
54346 {
54347 #ifdef CONFIG_CIFS_STATS
54348 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
54349 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
54350 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
54351 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54352 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
54353 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
54354 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54355 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
54356 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
54357 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
54358 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54359 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54360 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54361 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54362 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54363 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54364 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54365 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54366 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54367 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54368 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54369 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54370 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54371 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54372 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54373 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54374 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54375 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54376 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54377 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54378 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54379 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54380 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54381 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54382 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54383 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54384 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54385 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54386 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54387 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54388 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54389 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54390 #endif
54391 }
54392
54393 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54394 {
54395 #ifdef CONFIG_CIFS_STATS
54396 seq_printf(m, " Oplocks breaks: %d",
54397 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54398 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54399 seq_printf(m, "\nReads: %d Bytes: %llu",
54400 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54401 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54402 (long long)(tcon->bytes_read));
54403 seq_printf(m, "\nWrites: %d Bytes: %llu",
54404 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54405 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54406 (long long)(tcon->bytes_written));
54407 seq_printf(m, "\nFlushes: %d",
54408 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54409 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54410 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54411 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54412 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54413 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54414 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54415 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54416 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54417 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54418 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54419 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54420 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54421 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54422 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54423 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54424 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54425 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54426 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54427 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54428 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54429 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54430 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54431 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54432 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54433 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54434 seq_printf(m, "\nRenames: %d T2 Renames %d",
54435 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54436 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54437 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54438 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54439 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54440 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54441 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54442 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54443 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54444 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54445 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54446 #endif
54447 }
54448
54449 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54450 index 861b332..5506392 100644
54451 --- a/fs/cifs/smb2ops.c
54452 +++ b/fs/cifs/smb2ops.c
54453 @@ -282,8 +282,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54454 #ifdef CONFIG_CIFS_STATS
54455 int i;
54456 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54457 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54458 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54459 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54460 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54461 }
54462 #endif
54463 }
54464 @@ -311,65 +311,65 @@ static void
54465 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54466 {
54467 #ifdef CONFIG_CIFS_STATS
54468 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54469 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54470 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54471 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54472 seq_printf(m, "\nNegotiates: %d sent %d failed",
54473 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54474 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54475 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54476 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54477 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54478 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54479 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54480 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54481 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54482 seq_printf(m, "\nLogoffs: %d sent %d failed",
54483 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54484 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54485 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54486 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54487 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54488 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54489 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54490 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54491 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54492 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54493 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54494 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54495 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54496 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54497 seq_printf(m, "\nCreates: %d sent %d failed",
54498 - atomic_read(&sent[SMB2_CREATE_HE]),
54499 - atomic_read(&failed[SMB2_CREATE_HE]));
54500 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54501 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54502 seq_printf(m, "\nCloses: %d sent %d failed",
54503 - atomic_read(&sent[SMB2_CLOSE_HE]),
54504 - atomic_read(&failed[SMB2_CLOSE_HE]));
54505 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54506 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54507 seq_printf(m, "\nFlushes: %d sent %d failed",
54508 - atomic_read(&sent[SMB2_FLUSH_HE]),
54509 - atomic_read(&failed[SMB2_FLUSH_HE]));
54510 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54511 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54512 seq_printf(m, "\nReads: %d sent %d failed",
54513 - atomic_read(&sent[SMB2_READ_HE]),
54514 - atomic_read(&failed[SMB2_READ_HE]));
54515 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54516 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54517 seq_printf(m, "\nWrites: %d sent %d failed",
54518 - atomic_read(&sent[SMB2_WRITE_HE]),
54519 - atomic_read(&failed[SMB2_WRITE_HE]));
54520 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54521 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54522 seq_printf(m, "\nLocks: %d sent %d failed",
54523 - atomic_read(&sent[SMB2_LOCK_HE]),
54524 - atomic_read(&failed[SMB2_LOCK_HE]));
54525 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54526 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54527 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54528 - atomic_read(&sent[SMB2_IOCTL_HE]),
54529 - atomic_read(&failed[SMB2_IOCTL_HE]));
54530 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54531 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54532 seq_printf(m, "\nCancels: %d sent %d failed",
54533 - atomic_read(&sent[SMB2_CANCEL_HE]),
54534 - atomic_read(&failed[SMB2_CANCEL_HE]));
54535 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54536 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54537 seq_printf(m, "\nEchos: %d sent %d failed",
54538 - atomic_read(&sent[SMB2_ECHO_HE]),
54539 - atomic_read(&failed[SMB2_ECHO_HE]));
54540 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54541 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54542 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54543 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54544 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54545 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54546 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54547 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54548 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54549 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54550 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54551 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54552 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54553 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54554 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54555 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54556 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54557 seq_printf(m, "\nSetInfos: %d sent %d failed",
54558 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54559 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54560 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54561 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54562 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54563 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54564 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54565 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54566 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54567 #endif
54568 }
54569
54570 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54571 index edccb52..16bc6db 100644
54572 --- a/fs/cifs/smb2pdu.c
54573 +++ b/fs/cifs/smb2pdu.c
54574 @@ -1957,8 +1957,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54575 default:
54576 cifs_dbg(VFS, "info level %u isn't supported\n",
54577 srch_inf->info_level);
54578 - rc = -EINVAL;
54579 - goto qdir_exit;
54580 + return -EINVAL;
54581 }
54582
54583 req->FileIndex = cpu_to_le32(index);
54584 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54585 index 1da168c..8bc7ff6 100644
54586 --- a/fs/coda/cache.c
54587 +++ b/fs/coda/cache.c
54588 @@ -24,7 +24,7 @@
54589 #include "coda_linux.h"
54590 #include "coda_cache.h"
54591
54592 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54593 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54594
54595 /* replace or extend an acl cache hit */
54596 void coda_cache_enter(struct inode *inode, int mask)
54597 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54598 struct coda_inode_info *cii = ITOC(inode);
54599
54600 spin_lock(&cii->c_lock);
54601 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54602 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54603 if (!uid_eq(cii->c_uid, current_fsuid())) {
54604 cii->c_uid = current_fsuid();
54605 cii->c_cached_perm = mask;
54606 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54607 {
54608 struct coda_inode_info *cii = ITOC(inode);
54609 spin_lock(&cii->c_lock);
54610 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54611 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54612 spin_unlock(&cii->c_lock);
54613 }
54614
54615 /* remove all acl caches */
54616 void coda_cache_clear_all(struct super_block *sb)
54617 {
54618 - atomic_inc(&permission_epoch);
54619 + atomic_inc_unchecked(&permission_epoch);
54620 }
54621
54622
54623 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54624 spin_lock(&cii->c_lock);
54625 hit = (mask & cii->c_cached_perm) == mask &&
54626 uid_eq(cii->c_uid, current_fsuid()) &&
54627 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54628 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54629 spin_unlock(&cii->c_lock);
54630
54631 return hit;
54632 diff --git a/fs/compat.c b/fs/compat.c
54633 index 6af20de..fec3fbb 100644
54634 --- a/fs/compat.c
54635 +++ b/fs/compat.c
54636 @@ -54,7 +54,7 @@
54637 #include <asm/ioctls.h>
54638 #include "internal.h"
54639
54640 -int compat_log = 1;
54641 +int compat_log = 0;
54642
54643 int compat_printk(const char *fmt, ...)
54644 {
54645 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54646
54647 set_fs(KERNEL_DS);
54648 /* The __user pointer cast is valid because of the set_fs() */
54649 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54650 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54651 set_fs(oldfs);
54652 /* truncating is ok because it's a user address */
54653 if (!ret)
54654 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54655 goto out;
54656
54657 ret = -EINVAL;
54658 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54659 + if (nr_segs > UIO_MAXIOV)
54660 goto out;
54661 if (nr_segs > fast_segs) {
54662 ret = -ENOMEM;
54663 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54664 struct compat_readdir_callback {
54665 struct dir_context ctx;
54666 struct compat_old_linux_dirent __user *dirent;
54667 + struct file * file;
54668 int result;
54669 };
54670
54671 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54672 buf->result = -EOVERFLOW;
54673 return -EOVERFLOW;
54674 }
54675 +
54676 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54677 + return 0;
54678 +
54679 buf->result++;
54680 dirent = buf->dirent;
54681 if (!access_ok(VERIFY_WRITE, dirent,
54682 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54683 if (!f.file)
54684 return -EBADF;
54685
54686 + buf.file = f.file;
54687 error = iterate_dir(f.file, &buf.ctx);
54688 if (buf.result)
54689 error = buf.result;
54690 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54691 struct dir_context ctx;
54692 struct compat_linux_dirent __user *current_dir;
54693 struct compat_linux_dirent __user *previous;
54694 + struct file * file;
54695 int count;
54696 int error;
54697 };
54698 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54699 buf->error = -EOVERFLOW;
54700 return -EOVERFLOW;
54701 }
54702 +
54703 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54704 + return 0;
54705 +
54706 dirent = buf->previous;
54707 if (dirent) {
54708 if (__put_user(offset, &dirent->d_off))
54709 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54710 if (!f.file)
54711 return -EBADF;
54712
54713 + buf.file = f.file;
54714 error = iterate_dir(f.file, &buf.ctx);
54715 if (error >= 0)
54716 error = buf.error;
54717 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54718 struct dir_context ctx;
54719 struct linux_dirent64 __user *current_dir;
54720 struct linux_dirent64 __user *previous;
54721 + struct file * file;
54722 int count;
54723 int error;
54724 };
54725 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54726 buf->error = -EINVAL; /* only used if we fail.. */
54727 if (reclen > buf->count)
54728 return -EINVAL;
54729 +
54730 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54731 + return 0;
54732 +
54733 dirent = buf->previous;
54734
54735 if (dirent) {
54736 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54737 if (!f.file)
54738 return -EBADF;
54739
54740 + buf.file = f.file;
54741 error = iterate_dir(f.file, &buf.ctx);
54742 if (error >= 0)
54743 error = buf.error;
54744 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54745 index a81147e..20bf2b5 100644
54746 --- a/fs/compat_binfmt_elf.c
54747 +++ b/fs/compat_binfmt_elf.c
54748 @@ -30,11 +30,13 @@
54749 #undef elf_phdr
54750 #undef elf_shdr
54751 #undef elf_note
54752 +#undef elf_dyn
54753 #undef elf_addr_t
54754 #define elfhdr elf32_hdr
54755 #define elf_phdr elf32_phdr
54756 #define elf_shdr elf32_shdr
54757 #define elf_note elf32_note
54758 +#define elf_dyn Elf32_Dyn
54759 #define elf_addr_t Elf32_Addr
54760
54761 /*
54762 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54763 index 5d19acf..9ab093b 100644
54764 --- a/fs/compat_ioctl.c
54765 +++ b/fs/compat_ioctl.c
54766 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54767 return -EFAULT;
54768 if (__get_user(udata, &ss32->iomem_base))
54769 return -EFAULT;
54770 - ss.iomem_base = compat_ptr(udata);
54771 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54772 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54773 __get_user(ss.port_high, &ss32->port_high))
54774 return -EFAULT;
54775 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54776 for (i = 0; i < nmsgs; i++) {
54777 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54778 return -EFAULT;
54779 - if (get_user(datap, &umsgs[i].buf) ||
54780 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54781 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54782 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54783 return -EFAULT;
54784 }
54785 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54786 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54787 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54788 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54789 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54790 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54791 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54792 return -EFAULT;
54793
54794 return ioctl_preallocate(file, p);
54795 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54796 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54797 {
54798 unsigned int a, b;
54799 - a = *(unsigned int *)p;
54800 - b = *(unsigned int *)q;
54801 + a = *(const unsigned int *)p;
54802 + b = *(const unsigned int *)q;
54803 if (a > b)
54804 return 1;
54805 if (a < b)
54806 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54807 index 277bd1b..f312c9e 100644
54808 --- a/fs/configfs/dir.c
54809 +++ b/fs/configfs/dir.c
54810 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54811 }
54812 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54813 struct configfs_dirent *next;
54814 - const char *name;
54815 + const unsigned char * name;
54816 + char d_name[sizeof(next->s_dentry->d_iname)];
54817 int len;
54818 struct inode *inode = NULL;
54819
54820 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54821 continue;
54822
54823 name = configfs_get_name(next);
54824 - len = strlen(name);
54825 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54826 + len = next->s_dentry->d_name.len;
54827 + memcpy(d_name, name, len);
54828 + name = d_name;
54829 + } else
54830 + len = strlen(name);
54831
54832 /*
54833 * We'll have a dentry and an inode for
54834 diff --git a/fs/coredump.c b/fs/coredump.c
54835 index 9bdeca1..2247b92 100644
54836 --- a/fs/coredump.c
54837 +++ b/fs/coredump.c
54838 @@ -438,8 +438,8 @@ static void wait_for_dump_helpers(struct file *file)
54839 struct pipe_inode_info *pipe = file->private_data;
54840
54841 pipe_lock(pipe);
54842 - pipe->readers++;
54843 - pipe->writers--;
54844 + atomic_inc(&pipe->readers);
54845 + atomic_dec(&pipe->writers);
54846 wake_up_interruptible_sync(&pipe->wait);
54847 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54848 pipe_unlock(pipe);
54849 @@ -448,11 +448,11 @@ static void wait_for_dump_helpers(struct file *file)
54850 * We actually want wait_event_freezable() but then we need
54851 * to clear TIF_SIGPENDING and improve dump_interrupted().
54852 */
54853 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54854 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54855
54856 pipe_lock(pipe);
54857 - pipe->readers--;
54858 - pipe->writers++;
54859 + atomic_dec(&pipe->readers);
54860 + atomic_inc(&pipe->writers);
54861 pipe_unlock(pipe);
54862 }
54863
54864 @@ -499,7 +499,8 @@ void do_coredump(siginfo_t *siginfo)
54865 struct files_struct *displaced;
54866 bool need_nonrelative = false;
54867 bool core_dumped = false;
54868 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54869 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54870 + long signr = siginfo->si_signo;
54871 struct coredump_params cprm = {
54872 .siginfo = siginfo,
54873 .regs = signal_pt_regs(),
54874 @@ -512,7 +513,10 @@ void do_coredump(siginfo_t *siginfo)
54875 .mm_flags = mm->flags,
54876 };
54877
54878 - audit_core_dumps(siginfo->si_signo);
54879 + audit_core_dumps(signr);
54880 +
54881 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54882 + gr_handle_brute_attach(cprm.mm_flags);
54883
54884 binfmt = mm->binfmt;
54885 if (!binfmt || !binfmt->core_dump)
54886 @@ -536,7 +540,7 @@ void do_coredump(siginfo_t *siginfo)
54887 need_nonrelative = true;
54888 }
54889
54890 - retval = coredump_wait(siginfo->si_signo, &core_state);
54891 + retval = coredump_wait(signr, &core_state);
54892 if (retval < 0)
54893 goto fail_creds;
54894
54895 @@ -579,7 +583,7 @@ void do_coredump(siginfo_t *siginfo)
54896 }
54897 cprm.limit = RLIM_INFINITY;
54898
54899 - dump_count = atomic_inc_return(&core_dump_count);
54900 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54901 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54902 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54903 task_tgid_vnr(current), current->comm);
54904 @@ -611,6 +615,8 @@ void do_coredump(siginfo_t *siginfo)
54905 } else {
54906 struct inode *inode;
54907
54908 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54909 +
54910 if (cprm.limit < binfmt->min_coredump)
54911 goto fail_unlock;
54912
54913 @@ -669,7 +675,7 @@ close_fail:
54914 filp_close(cprm.file, NULL);
54915 fail_dropcount:
54916 if (ispipe)
54917 - atomic_dec(&core_dump_count);
54918 + atomic_dec_unchecked(&core_dump_count);
54919 fail_unlock:
54920 kfree(cn.corename);
54921 coredump_finish(mm, core_dumped);
54922 @@ -689,7 +695,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54923 {
54924 return !dump_interrupted() &&
54925 access_ok(VERIFY_READ, addr, nr) &&
54926 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54927 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54928 }
54929 EXPORT_SYMBOL(dump_write);
54930
54931 diff --git a/fs/dcache.c b/fs/dcache.c
54932 index ae6ebb8..5977a84 100644
54933 --- a/fs/dcache.c
54934 +++ b/fs/dcache.c
54935 @@ -2881,9 +2881,9 @@ static int prepend_path(const struct path *path,
54936 const struct path *root,
54937 char **buffer, int *buflen)
54938 {
54939 - struct dentry *dentry = path->dentry;
54940 - struct vfsmount *vfsmnt = path->mnt;
54941 - struct mount *mnt = real_mount(vfsmnt);
54942 + struct dentry *dentry;
54943 + struct vfsmount *vfsmnt;
54944 + struct mount *mnt;
54945 int error = 0;
54946 unsigned seq = 0;
54947 char *bptr;
54948 @@ -2893,6 +2893,10 @@ static int prepend_path(const struct path *path,
54949 restart:
54950 bptr = *buffer;
54951 blen = *buflen;
54952 + error = 0;
54953 + dentry = path->dentry;
54954 + vfsmnt = path->mnt;
54955 + mnt = real_mount(vfsmnt);
54956 read_seqbegin_or_lock(&rename_lock, &seq);
54957 while (dentry != root->dentry || vfsmnt != root->mnt) {
54958 struct dentry * parent;
54959 @@ -3429,7 +3433,8 @@ void __init vfs_caches_init(unsigned long mempages)
54960 mempages -= reserve;
54961
54962 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54963 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54964 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54965 + SLAB_NO_SANITIZE, NULL);
54966
54967 dcache_init();
54968 inode_init();
54969 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54970 index c7c83ff..bda9461 100644
54971 --- a/fs/debugfs/inode.c
54972 +++ b/fs/debugfs/inode.c
54973 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54974 */
54975 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54976 {
54977 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54978 + return __create_file(name, S_IFDIR | S_IRWXU,
54979 +#else
54980 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54981 +#endif
54982 parent, NULL, NULL);
54983 }
54984 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54985 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54986 index 67e9b63..a9adb68 100644
54987 --- a/fs/ecryptfs/inode.c
54988 +++ b/fs/ecryptfs/inode.c
54989 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54990 old_fs = get_fs();
54991 set_fs(get_ds());
54992 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54993 - (char __user *)lower_buf,
54994 + (char __force_user *)lower_buf,
54995 PATH_MAX);
54996 set_fs(old_fs);
54997 if (rc < 0)
54998 @@ -706,7 +706,7 @@ out:
54999 static void
55000 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
55001 {
55002 - char *buf = nd_get_link(nd);
55003 + const char *buf = nd_get_link(nd);
55004 if (!IS_ERR(buf)) {
55005 /* Free the char* */
55006 kfree(buf);
55007 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
55008 index e4141f2..d8263e8 100644
55009 --- a/fs/ecryptfs/miscdev.c
55010 +++ b/fs/ecryptfs/miscdev.c
55011 @@ -304,7 +304,7 @@ check_list:
55012 goto out_unlock_msg_ctx;
55013 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
55014 if (msg_ctx->msg) {
55015 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55016 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55017 goto out_unlock_msg_ctx;
55018 i += packet_length_size;
55019 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55020 diff --git a/fs/exec.c b/fs/exec.c
55021 index 8875dd1..c53682a 100644
55022 --- a/fs/exec.c
55023 +++ b/fs/exec.c
55024 @@ -55,8 +55,20 @@
55025 #include <linux/pipe_fs_i.h>
55026 #include <linux/oom.h>
55027 #include <linux/compat.h>
55028 +#include <linux/random.h>
55029 +#include <linux/seq_file.h>
55030 +#include <linux/coredump.h>
55031 +#include <linux/mman.h>
55032 +
55033 +#ifdef CONFIG_PAX_REFCOUNT
55034 +#include <linux/kallsyms.h>
55035 +#include <linux/kdebug.h>
55036 +#endif
55037 +
55038 +#include <trace/events/fs.h>
55039
55040 #include <asm/uaccess.h>
55041 +#include <asm/sections.h>
55042 #include <asm/mmu_context.h>
55043 #include <asm/tlb.h>
55044
55045 @@ -66,19 +78,34 @@
55046
55047 #include <trace/events/sched.h>
55048
55049 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55050 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55051 +{
55052 + 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");
55053 +}
55054 +#endif
55055 +
55056 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55057 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55058 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55059 +#endif
55060 +
55061 int suid_dumpable = 0;
55062
55063 static LIST_HEAD(formats);
55064 static DEFINE_RWLOCK(binfmt_lock);
55065
55066 +extern int gr_process_kernel_exec_ban(void);
55067 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55068 +
55069 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55070 {
55071 BUG_ON(!fmt);
55072 if (WARN_ON(!fmt->load_binary))
55073 return;
55074 write_lock(&binfmt_lock);
55075 - insert ? list_add(&fmt->lh, &formats) :
55076 - list_add_tail(&fmt->lh, &formats);
55077 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55078 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55079 write_unlock(&binfmt_lock);
55080 }
55081
55082 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
55083 void unregister_binfmt(struct linux_binfmt * fmt)
55084 {
55085 write_lock(&binfmt_lock);
55086 - list_del(&fmt->lh);
55087 + pax_list_del((struct list_head *)&fmt->lh);
55088 write_unlock(&binfmt_lock);
55089 }
55090
55091 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55092 int write)
55093 {
55094 struct page *page;
55095 - int ret;
55096
55097 -#ifdef CONFIG_STACK_GROWSUP
55098 - if (write) {
55099 - ret = expand_downwards(bprm->vma, pos);
55100 - if (ret < 0)
55101 - return NULL;
55102 - }
55103 -#endif
55104 - ret = get_user_pages(current, bprm->mm, pos,
55105 - 1, write, 1, &page, NULL);
55106 - if (ret <= 0)
55107 + if (0 > expand_downwards(bprm->vma, pos))
55108 + return NULL;
55109 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55110 return NULL;
55111
55112 if (write) {
55113 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55114 if (size <= ARG_MAX)
55115 return page;
55116
55117 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55118 + // only allow 512KB for argv+env on suid/sgid binaries
55119 + // to prevent easy ASLR exhaustion
55120 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55121 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55122 + (size > (512 * 1024))) {
55123 + put_page(page);
55124 + return NULL;
55125 + }
55126 +#endif
55127 +
55128 /*
55129 * Limit to 1/4-th the stack size for the argv+env strings.
55130 * This ensures that:
55131 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55132 vma->vm_end = STACK_TOP_MAX;
55133 vma->vm_start = vma->vm_end - PAGE_SIZE;
55134 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55135 +
55136 +#ifdef CONFIG_PAX_SEGMEXEC
55137 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55138 +#endif
55139 +
55140 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55141 INIT_LIST_HEAD(&vma->anon_vma_chain);
55142
55143 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55144 mm->stack_vm = mm->total_vm = 1;
55145 up_write(&mm->mmap_sem);
55146 bprm->p = vma->vm_end - sizeof(void *);
55147 +
55148 +#ifdef CONFIG_PAX_RANDUSTACK
55149 + if (randomize_va_space)
55150 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55151 +#endif
55152 +
55153 return 0;
55154 err:
55155 up_write(&mm->mmap_sem);
55156 @@ -399,7 +440,7 @@ struct user_arg_ptr {
55157 } ptr;
55158 };
55159
55160 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55161 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55162 {
55163 const char __user *native;
55164
55165 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55166 compat_uptr_t compat;
55167
55168 if (get_user(compat, argv.ptr.compat + nr))
55169 - return ERR_PTR(-EFAULT);
55170 + return (const char __force_user *)ERR_PTR(-EFAULT);
55171
55172 return compat_ptr(compat);
55173 }
55174 #endif
55175
55176 if (get_user(native, argv.ptr.native + nr))
55177 - return ERR_PTR(-EFAULT);
55178 + return (const char __force_user *)ERR_PTR(-EFAULT);
55179
55180 return native;
55181 }
55182 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
55183 if (!p)
55184 break;
55185
55186 - if (IS_ERR(p))
55187 + if (IS_ERR((const char __force_kernel *)p))
55188 return -EFAULT;
55189
55190 if (i >= max)
55191 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55192
55193 ret = -EFAULT;
55194 str = get_user_arg_ptr(argv, argc);
55195 - if (IS_ERR(str))
55196 + if (IS_ERR((const char __force_kernel *)str))
55197 goto out;
55198
55199 len = strnlen_user(str, MAX_ARG_STRLEN);
55200 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55201 int r;
55202 mm_segment_t oldfs = get_fs();
55203 struct user_arg_ptr argv = {
55204 - .ptr.native = (const char __user *const __user *)__argv,
55205 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55206 };
55207
55208 set_fs(KERNEL_DS);
55209 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55210 unsigned long new_end = old_end - shift;
55211 struct mmu_gather tlb;
55212
55213 - BUG_ON(new_start > new_end);
55214 + if (new_start >= new_end || new_start < mmap_min_addr)
55215 + return -ENOMEM;
55216
55217 /*
55218 * ensure there are no vmas between where we want to go
55219 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55220 if (vma != find_vma(mm, new_start))
55221 return -EFAULT;
55222
55223 +#ifdef CONFIG_PAX_SEGMEXEC
55224 + BUG_ON(pax_find_mirror_vma(vma));
55225 +#endif
55226 +
55227 /*
55228 * cover the whole range: [new_start, old_end)
55229 */
55230 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55231 stack_top = arch_align_stack(stack_top);
55232 stack_top = PAGE_ALIGN(stack_top);
55233
55234 - if (unlikely(stack_top < mmap_min_addr) ||
55235 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
55236 - return -ENOMEM;
55237 -
55238 stack_shift = vma->vm_end - stack_top;
55239
55240 bprm->p -= stack_shift;
55241 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
55242 bprm->exec -= stack_shift;
55243
55244 down_write(&mm->mmap_sem);
55245 +
55246 + /* Move stack pages down in memory. */
55247 + if (stack_shift) {
55248 + ret = shift_arg_pages(vma, stack_shift);
55249 + if (ret)
55250 + goto out_unlock;
55251 + }
55252 +
55253 vm_flags = VM_STACK_FLAGS;
55254
55255 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55256 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
55257 + vm_flags &= ~VM_EXEC;
55258 +
55259 +#ifdef CONFIG_PAX_MPROTECT
55260 + if (mm->pax_flags & MF_PAX_MPROTECT)
55261 + vm_flags &= ~VM_MAYEXEC;
55262 +#endif
55263 +
55264 + }
55265 +#endif
55266 +
55267 /*
55268 * Adjust stack execute permissions; explicitly enable for
55269 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
55270 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55271 goto out_unlock;
55272 BUG_ON(prev != vma);
55273
55274 - /* Move stack pages down in memory. */
55275 - if (stack_shift) {
55276 - ret = shift_arg_pages(vma, stack_shift);
55277 - if (ret)
55278 - goto out_unlock;
55279 - }
55280 -
55281 /* mprotect_fixup is overkill to remove the temporary stack flags */
55282 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
55283
55284 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
55285 #endif
55286 current->mm->start_stack = bprm->p;
55287 ret = expand_stack(vma, stack_base);
55288 +
55289 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
55290 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
55291 + unsigned long size;
55292 + vm_flags_t vm_flags;
55293 +
55294 + size = STACK_TOP - vma->vm_end;
55295 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
55296 +
55297 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
55298 +
55299 +#ifdef CONFIG_X86
55300 + if (!ret) {
55301 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
55302 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
55303 + }
55304 +#endif
55305 +
55306 + }
55307 +#endif
55308 +
55309 if (ret)
55310 ret = -EFAULT;
55311
55312 @@ -776,6 +852,8 @@ struct file *open_exec(const char *name)
55313
55314 fsnotify_open(file);
55315
55316 + trace_open_exec(name);
55317 +
55318 err = deny_write_access(file);
55319 if (err)
55320 goto exit;
55321 @@ -799,7 +877,7 @@ int kernel_read(struct file *file, loff_t offset,
55322 old_fs = get_fs();
55323 set_fs(get_ds());
55324 /* The cast to a user pointer is valid due to the set_fs() */
55325 - result = vfs_read(file, (void __user *)addr, count, &pos);
55326 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
55327 set_fs(old_fs);
55328 return result;
55329 }
55330 @@ -1255,7 +1333,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
55331 }
55332 rcu_read_unlock();
55333
55334 - if (p->fs->users > n_fs) {
55335 + if (atomic_read(&p->fs->users) > n_fs) {
55336 bprm->unsafe |= LSM_UNSAFE_SHARE;
55337 } else {
55338 res = -EAGAIN;
55339 @@ -1451,6 +1529,31 @@ static int exec_binprm(struct linux_binprm *bprm)
55340 return ret;
55341 }
55342
55343 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55344 +static DEFINE_PER_CPU(u64, exec_counter);
55345 +static int __init init_exec_counters(void)
55346 +{
55347 + unsigned int cpu;
55348 +
55349 + for_each_possible_cpu(cpu) {
55350 + per_cpu(exec_counter, cpu) = (u64)cpu;
55351 + }
55352 +
55353 + return 0;
55354 +}
55355 +early_initcall(init_exec_counters);
55356 +static inline void increment_exec_counter(void)
55357 +{
55358 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
55359 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55360 +}
55361 +#else
55362 +static inline void increment_exec_counter(void) {}
55363 +#endif
55364 +
55365 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55366 + struct user_arg_ptr argv);
55367 +
55368 /*
55369 * sys_execve() executes a new program.
55370 */
55371 @@ -1458,12 +1561,19 @@ static int do_execve_common(const char *filename,
55372 struct user_arg_ptr argv,
55373 struct user_arg_ptr envp)
55374 {
55375 +#ifdef CONFIG_GRKERNSEC
55376 + struct file *old_exec_file;
55377 + struct acl_subject_label *old_acl;
55378 + struct rlimit old_rlim[RLIM_NLIMITS];
55379 +#endif
55380 struct linux_binprm *bprm;
55381 struct file *file;
55382 struct files_struct *displaced;
55383 bool clear_in_exec;
55384 int retval;
55385
55386 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
55387 +
55388 /*
55389 * We move the actual failure in case of RLIMIT_NPROC excess from
55390 * set*uid() to execve() because too many poorly written programs
55391 @@ -1504,12 +1614,22 @@ static int do_execve_common(const char *filename,
55392 if (IS_ERR(file))
55393 goto out_unmark;
55394
55395 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55396 + retval = -EPERM;
55397 + goto out_file;
55398 + }
55399 +
55400 sched_exec();
55401
55402 bprm->file = file;
55403 bprm->filename = filename;
55404 bprm->interp = filename;
55405
55406 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55407 + retval = -EACCES;
55408 + goto out_file;
55409 + }
55410 +
55411 retval = bprm_mm_init(bprm);
55412 if (retval)
55413 goto out_file;
55414 @@ -1526,24 +1646,70 @@ static int do_execve_common(const char *filename,
55415 if (retval < 0)
55416 goto out;
55417
55418 +#ifdef CONFIG_GRKERNSEC
55419 + old_acl = current->acl;
55420 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55421 + old_exec_file = current->exec_file;
55422 + get_file(file);
55423 + current->exec_file = file;
55424 +#endif
55425 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55426 + /* limit suid stack to 8MB
55427 + * we saved the old limits above and will restore them if this exec fails
55428 + */
55429 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55430 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55431 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55432 +#endif
55433 +
55434 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55435 + retval = -EPERM;
55436 + goto out_fail;
55437 + }
55438 +
55439 + if (!gr_tpe_allow(file)) {
55440 + retval = -EACCES;
55441 + goto out_fail;
55442 + }
55443 +
55444 + if (gr_check_crash_exec(file)) {
55445 + retval = -EACCES;
55446 + goto out_fail;
55447 + }
55448 +
55449 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55450 + bprm->unsafe);
55451 + if (retval < 0)
55452 + goto out_fail;
55453 +
55454 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55455 if (retval < 0)
55456 - goto out;
55457 + goto out_fail;
55458
55459 bprm->exec = bprm->p;
55460 retval = copy_strings(bprm->envc, envp, bprm);
55461 if (retval < 0)
55462 - goto out;
55463 + goto out_fail;
55464
55465 retval = copy_strings(bprm->argc, argv, bprm);
55466 if (retval < 0)
55467 - goto out;
55468 + goto out_fail;
55469 +
55470 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55471 +
55472 + gr_handle_exec_args(bprm, argv);
55473
55474 retval = exec_binprm(bprm);
55475 if (retval < 0)
55476 - goto out;
55477 + goto out_fail;
55478 +#ifdef CONFIG_GRKERNSEC
55479 + if (old_exec_file)
55480 + fput(old_exec_file);
55481 +#endif
55482
55483 /* execve succeeded */
55484 +
55485 + increment_exec_counter();
55486 current->fs->in_exec = 0;
55487 current->in_execve = 0;
55488 acct_update_integrals(current);
55489 @@ -1552,6 +1718,14 @@ static int do_execve_common(const char *filename,
55490 put_files_struct(displaced);
55491 return retval;
55492
55493 +out_fail:
55494 +#ifdef CONFIG_GRKERNSEC
55495 + current->acl = old_acl;
55496 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55497 + fput(current->exec_file);
55498 + current->exec_file = old_exec_file;
55499 +#endif
55500 +
55501 out:
55502 if (bprm->mm) {
55503 acct_arg_size(bprm, 0);
55504 @@ -1700,3 +1874,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55505 return error;
55506 }
55507 #endif
55508 +
55509 +int pax_check_flags(unsigned long *flags)
55510 +{
55511 + int retval = 0;
55512 +
55513 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55514 + if (*flags & MF_PAX_SEGMEXEC)
55515 + {
55516 + *flags &= ~MF_PAX_SEGMEXEC;
55517 + retval = -EINVAL;
55518 + }
55519 +#endif
55520 +
55521 + if ((*flags & MF_PAX_PAGEEXEC)
55522 +
55523 +#ifdef CONFIG_PAX_PAGEEXEC
55524 + && (*flags & MF_PAX_SEGMEXEC)
55525 +#endif
55526 +
55527 + )
55528 + {
55529 + *flags &= ~MF_PAX_PAGEEXEC;
55530 + retval = -EINVAL;
55531 + }
55532 +
55533 + if ((*flags & MF_PAX_MPROTECT)
55534 +
55535 +#ifdef CONFIG_PAX_MPROTECT
55536 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55537 +#endif
55538 +
55539 + )
55540 + {
55541 + *flags &= ~MF_PAX_MPROTECT;
55542 + retval = -EINVAL;
55543 + }
55544 +
55545 + if ((*flags & MF_PAX_EMUTRAMP)
55546 +
55547 +#ifdef CONFIG_PAX_EMUTRAMP
55548 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55549 +#endif
55550 +
55551 + )
55552 + {
55553 + *flags &= ~MF_PAX_EMUTRAMP;
55554 + retval = -EINVAL;
55555 + }
55556 +
55557 + return retval;
55558 +}
55559 +
55560 +EXPORT_SYMBOL(pax_check_flags);
55561 +
55562 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55563 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55564 +{
55565 + char *pathname = d_path(path, buf, buflen);
55566 +
55567 + if (IS_ERR(pathname))
55568 + goto toolong;
55569 +
55570 + pathname = mangle_path(buf, pathname, "\t\n\\");
55571 + if (!pathname)
55572 + goto toolong;
55573 +
55574 + *pathname = 0;
55575 + return buf;
55576 +
55577 +toolong:
55578 + return "<path too long>";
55579 +}
55580 +EXPORT_SYMBOL(pax_get_path);
55581 +
55582 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55583 +{
55584 + struct task_struct *tsk = current;
55585 + struct mm_struct *mm = current->mm;
55586 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55587 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55588 + char *path_exec = NULL;
55589 + char *path_fault = NULL;
55590 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55591 + siginfo_t info = { };
55592 +
55593 + if (buffer_exec && buffer_fault) {
55594 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55595 +
55596 + down_read(&mm->mmap_sem);
55597 + vma = mm->mmap;
55598 + while (vma && (!vma_exec || !vma_fault)) {
55599 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55600 + vma_exec = vma;
55601 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55602 + vma_fault = vma;
55603 + vma = vma->vm_next;
55604 + }
55605 + if (vma_exec)
55606 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55607 + if (vma_fault) {
55608 + start = vma_fault->vm_start;
55609 + end = vma_fault->vm_end;
55610 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55611 + if (vma_fault->vm_file)
55612 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55613 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55614 + path_fault = "<heap>";
55615 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55616 + path_fault = "<stack>";
55617 + else
55618 + path_fault = "<anonymous mapping>";
55619 + }
55620 + up_read(&mm->mmap_sem);
55621 + }
55622 + if (tsk->signal->curr_ip)
55623 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55624 + else
55625 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55626 + 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),
55627 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55628 + free_page((unsigned long)buffer_exec);
55629 + free_page((unsigned long)buffer_fault);
55630 + pax_report_insns(regs, pc, sp);
55631 + info.si_signo = SIGKILL;
55632 + info.si_errno = 0;
55633 + info.si_code = SI_KERNEL;
55634 + info.si_pid = 0;
55635 + info.si_uid = 0;
55636 + do_coredump(&info);
55637 +}
55638 +#endif
55639 +
55640 +#ifdef CONFIG_PAX_REFCOUNT
55641 +void pax_report_refcount_overflow(struct pt_regs *regs)
55642 +{
55643 + if (current->signal->curr_ip)
55644 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55645 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55646 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55647 + else
55648 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55649 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55650 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55651 + preempt_disable();
55652 + show_regs(regs);
55653 + preempt_enable();
55654 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55655 +}
55656 +#endif
55657 +
55658 +#ifdef CONFIG_PAX_USERCOPY
55659 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55660 +static noinline int check_stack_object(const void *obj, unsigned long len)
55661 +{
55662 + const void * const stack = task_stack_page(current);
55663 + const void * const stackend = stack + THREAD_SIZE;
55664 +
55665 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55666 + const void *frame = NULL;
55667 + const void *oldframe;
55668 +#endif
55669 +
55670 + if (obj + len < obj)
55671 + return -1;
55672 +
55673 + if (obj + len <= stack || stackend <= obj)
55674 + return 0;
55675 +
55676 + if (obj < stack || stackend < obj + len)
55677 + return -1;
55678 +
55679 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55680 + oldframe = __builtin_frame_address(1);
55681 + if (oldframe)
55682 + frame = __builtin_frame_address(2);
55683 + /*
55684 + low ----------------------------------------------> high
55685 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55686 + ^----------------^
55687 + allow copies only within here
55688 + */
55689 + while (stack <= frame && frame < stackend) {
55690 + /* if obj + len extends past the last frame, this
55691 + check won't pass and the next frame will be 0,
55692 + causing us to bail out and correctly report
55693 + the copy as invalid
55694 + */
55695 + if (obj + len <= frame)
55696 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55697 + oldframe = frame;
55698 + frame = *(const void * const *)frame;
55699 + }
55700 + return -1;
55701 +#else
55702 + return 1;
55703 +#endif
55704 +}
55705 +
55706 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55707 +{
55708 + if (current->signal->curr_ip)
55709 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55710 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55711 + else
55712 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55713 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55714 + dump_stack();
55715 + gr_handle_kernel_exploit();
55716 + do_group_exit(SIGKILL);
55717 +}
55718 +#endif
55719 +
55720 +#ifdef CONFIG_PAX_USERCOPY
55721 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55722 +{
55723 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55724 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55725 +#ifdef CONFIG_MODULES
55726 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55727 +#else
55728 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55729 +#endif
55730 +
55731 +#else
55732 + unsigned long textlow = (unsigned long)_stext;
55733 + unsigned long texthigh = (unsigned long)_etext;
55734 +
55735 +#ifdef CONFIG_X86_64
55736 + /* check against linear mapping as well */
55737 + if (high > (unsigned long)__va(__pa(textlow)) &&
55738 + low <= (unsigned long)__va(__pa(texthigh)))
55739 + return true;
55740 +#endif
55741 +
55742 +#endif
55743 +
55744 + if (high <= textlow || low > texthigh)
55745 + return false;
55746 + else
55747 + return true;
55748 +}
55749 +#endif
55750 +
55751 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55752 +{
55753 +
55754 +#ifdef CONFIG_PAX_USERCOPY
55755 + const char *type;
55756 +
55757 + if (!n)
55758 + return;
55759 +
55760 + type = check_heap_object(ptr, n);
55761 + if (!type) {
55762 + int ret = check_stack_object(ptr, n);
55763 + if (ret == 1 || ret == 2)
55764 + return;
55765 + if (ret == 0) {
55766 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55767 + type = "<kernel text>";
55768 + else
55769 + return;
55770 + } else
55771 + type = "<process stack>";
55772 + }
55773 +
55774 + pax_report_usercopy(ptr, n, to_user, type);
55775 +#endif
55776 +
55777 +}
55778 +EXPORT_SYMBOL(__check_object_size);
55779 +
55780 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55781 +void pax_track_stack(void)
55782 +{
55783 + unsigned long sp = (unsigned long)&sp;
55784 + if (sp < current_thread_info()->lowest_stack &&
55785 + sp > (unsigned long)task_stack_page(current))
55786 + current_thread_info()->lowest_stack = sp;
55787 +}
55788 +EXPORT_SYMBOL(pax_track_stack);
55789 +#endif
55790 +
55791 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55792 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55793 +{
55794 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55795 + dump_stack();
55796 + do_group_exit(SIGKILL);
55797 +}
55798 +EXPORT_SYMBOL(report_size_overflow);
55799 +#endif
55800 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55801 index 9f9992b..8b59411 100644
55802 --- a/fs/ext2/balloc.c
55803 +++ b/fs/ext2/balloc.c
55804 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55805
55806 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55807 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55808 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55809 + if (free_blocks < root_blocks + 1 &&
55810 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55811 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55812 - !in_group_p (sbi->s_resgid))) {
55813 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55814 return 0;
55815 }
55816 return 1;
55817 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
55818 index 2d7557d..14e38f94 100644
55819 --- a/fs/ext2/xattr.c
55820 +++ b/fs/ext2/xattr.c
55821 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
55822 struct buffer_head *bh = NULL;
55823 struct ext2_xattr_entry *entry;
55824 char *end;
55825 - size_t rest = buffer_size;
55826 + size_t rest = buffer_size, total_size = 0;
55827 int error;
55828
55829 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
55830 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
55831 buffer += size;
55832 }
55833 rest -= size;
55834 + total_size += size;
55835 }
55836 }
55837 - error = buffer_size - rest; /* total size */
55838 + error = total_size;
55839
55840 cleanup:
55841 brelse(bh);
55842 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55843 index 22548f5..41521d8 100644
55844 --- a/fs/ext3/balloc.c
55845 +++ b/fs/ext3/balloc.c
55846 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55847
55848 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55849 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55850 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55851 + if (free_blocks < root_blocks + 1 &&
55852 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55853 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55854 - !in_group_p (sbi->s_resgid))) {
55855 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55856 return 0;
55857 }
55858 return 1;
55859 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
55860 index b1fc963..881228c 100644
55861 --- a/fs/ext3/xattr.c
55862 +++ b/fs/ext3/xattr.c
55863 @@ -330,7 +330,7 @@ static int
55864 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
55865 char *buffer, size_t buffer_size)
55866 {
55867 - size_t rest = buffer_size;
55868 + size_t rest = buffer_size, total_size = 0;
55869
55870 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
55871 const struct xattr_handler *handler =
55872 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
55873 buffer += size;
55874 }
55875 rest -= size;
55876 + total_size += size;
55877 }
55878 }
55879 - return buffer_size - rest;
55880 + return total_size;
55881 }
55882
55883 static int
55884 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55885 index dc5d572..4c21f8e 100644
55886 --- a/fs/ext4/balloc.c
55887 +++ b/fs/ext4/balloc.c
55888 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55889 /* Hm, nope. Are (enough) root reserved clusters available? */
55890 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55891 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55892 - capable(CAP_SYS_RESOURCE) ||
55893 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55894 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55895 + capable_nolog(CAP_SYS_RESOURCE)) {
55896
55897 if (free_clusters >= (nclusters + dirty_clusters +
55898 resv_clusters))
55899 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55900 index af815ea..99294a6 100644
55901 --- a/fs/ext4/ext4.h
55902 +++ b/fs/ext4/ext4.h
55903 @@ -1256,19 +1256,19 @@ struct ext4_sb_info {
55904 unsigned long s_mb_last_start;
55905
55906 /* stats for buddy allocator */
55907 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55908 - atomic_t s_bal_success; /* we found long enough chunks */
55909 - atomic_t s_bal_allocated; /* in blocks */
55910 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55911 - atomic_t s_bal_goals; /* goal hits */
55912 - atomic_t s_bal_breaks; /* too long searches */
55913 - atomic_t s_bal_2orders; /* 2^order hits */
55914 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55915 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55916 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55917 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55918 + atomic_unchecked_t s_bal_goals; /* goal hits */
55919 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55920 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55921 spinlock_t s_bal_lock;
55922 unsigned long s_mb_buddies_generated;
55923 unsigned long long s_mb_generation_time;
55924 - atomic_t s_mb_lost_chunks;
55925 - atomic_t s_mb_preallocated;
55926 - atomic_t s_mb_discarded;
55927 + atomic_unchecked_t s_mb_lost_chunks;
55928 + atomic_unchecked_t s_mb_preallocated;
55929 + atomic_unchecked_t s_mb_discarded;
55930 atomic_t s_lock_busy;
55931
55932 /* locality groups */
55933 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55934 index a41e3ba..e574a00 100644
55935 --- a/fs/ext4/mballoc.c
55936 +++ b/fs/ext4/mballoc.c
55937 @@ -1880,7 +1880,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55938 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55939
55940 if (EXT4_SB(sb)->s_mb_stats)
55941 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55942 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55943
55944 break;
55945 }
55946 @@ -2189,7 +2189,7 @@ repeat:
55947 ac->ac_status = AC_STATUS_CONTINUE;
55948 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55949 cr = 3;
55950 - atomic_inc(&sbi->s_mb_lost_chunks);
55951 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55952 goto repeat;
55953 }
55954 }
55955 @@ -2697,25 +2697,25 @@ int ext4_mb_release(struct super_block *sb)
55956 if (sbi->s_mb_stats) {
55957 ext4_msg(sb, KERN_INFO,
55958 "mballoc: %u blocks %u reqs (%u success)",
55959 - atomic_read(&sbi->s_bal_allocated),
55960 - atomic_read(&sbi->s_bal_reqs),
55961 - atomic_read(&sbi->s_bal_success));
55962 + atomic_read_unchecked(&sbi->s_bal_allocated),
55963 + atomic_read_unchecked(&sbi->s_bal_reqs),
55964 + atomic_read_unchecked(&sbi->s_bal_success));
55965 ext4_msg(sb, KERN_INFO,
55966 "mballoc: %u extents scanned, %u goal hits, "
55967 "%u 2^N hits, %u breaks, %u lost",
55968 - atomic_read(&sbi->s_bal_ex_scanned),
55969 - atomic_read(&sbi->s_bal_goals),
55970 - atomic_read(&sbi->s_bal_2orders),
55971 - atomic_read(&sbi->s_bal_breaks),
55972 - atomic_read(&sbi->s_mb_lost_chunks));
55973 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55974 + atomic_read_unchecked(&sbi->s_bal_goals),
55975 + atomic_read_unchecked(&sbi->s_bal_2orders),
55976 + atomic_read_unchecked(&sbi->s_bal_breaks),
55977 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55978 ext4_msg(sb, KERN_INFO,
55979 "mballoc: %lu generated and it took %Lu",
55980 sbi->s_mb_buddies_generated,
55981 sbi->s_mb_generation_time);
55982 ext4_msg(sb, KERN_INFO,
55983 "mballoc: %u preallocated, %u discarded",
55984 - atomic_read(&sbi->s_mb_preallocated),
55985 - atomic_read(&sbi->s_mb_discarded));
55986 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55987 + atomic_read_unchecked(&sbi->s_mb_discarded));
55988 }
55989
55990 free_percpu(sbi->s_locality_groups);
55991 @@ -3169,16 +3169,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55992 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55993
55994 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55995 - atomic_inc(&sbi->s_bal_reqs);
55996 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55997 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55998 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55999 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
56000 - atomic_inc(&sbi->s_bal_success);
56001 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
56002 + atomic_inc_unchecked(&sbi->s_bal_success);
56003 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
56004 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
56005 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
56006 - atomic_inc(&sbi->s_bal_goals);
56007 + atomic_inc_unchecked(&sbi->s_bal_goals);
56008 if (ac->ac_found > sbi->s_mb_max_to_scan)
56009 - atomic_inc(&sbi->s_bal_breaks);
56010 + atomic_inc_unchecked(&sbi->s_bal_breaks);
56011 }
56012
56013 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
56014 @@ -3578,7 +3578,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
56015 trace_ext4_mb_new_inode_pa(ac, pa);
56016
56017 ext4_mb_use_inode_pa(ac, pa);
56018 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56019 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56020
56021 ei = EXT4_I(ac->ac_inode);
56022 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56023 @@ -3638,7 +3638,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56024 trace_ext4_mb_new_group_pa(ac, pa);
56025
56026 ext4_mb_use_group_pa(ac, pa);
56027 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56028 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56029
56030 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56031 lg = ac->ac_lg;
56032 @@ -3727,7 +3727,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56033 * from the bitmap and continue.
56034 */
56035 }
56036 - atomic_add(free, &sbi->s_mb_discarded);
56037 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56038
56039 return err;
56040 }
56041 @@ -3745,7 +3745,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56042 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56043 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56044 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56045 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56046 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56047 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56048
56049 return 0;
56050 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56051 index 214461e..3614c89 100644
56052 --- a/fs/ext4/mmp.c
56053 +++ b/fs/ext4/mmp.c
56054 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56055 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56056 const char *function, unsigned int line, const char *msg)
56057 {
56058 - __ext4_warning(sb, function, line, msg);
56059 + __ext4_warning(sb, function, line, "%s", msg);
56060 __ext4_warning(sb, function, line,
56061 "MMP failure info: last update time: %llu, last update "
56062 "node: %s, last update device: %s\n",
56063 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56064 index 2c2e6cb..7c3ee62 100644
56065 --- a/fs/ext4/super.c
56066 +++ b/fs/ext4/super.c
56067 @@ -1251,7 +1251,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56068 }
56069
56070 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56071 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56072 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56073 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56074
56075 #ifdef CONFIG_QUOTA
56076 @@ -2431,7 +2431,7 @@ struct ext4_attr {
56077 int offset;
56078 int deprecated_val;
56079 } u;
56080 -};
56081 +} __do_const;
56082
56083 static int parse_strtoull(const char *buf,
56084 unsigned long long max, unsigned long long *value)
56085 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
56086 index 03e9beb..e86ce98 100644
56087 --- a/fs/ext4/xattr.c
56088 +++ b/fs/ext4/xattr.c
56089 @@ -381,7 +381,7 @@ static int
56090 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56091 char *buffer, size_t buffer_size)
56092 {
56093 - size_t rest = buffer_size;
56094 + size_t rest = buffer_size, total_size = 0;
56095
56096 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
56097 const struct xattr_handler *handler =
56098 @@ -398,9 +398,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56099 buffer += size;
56100 }
56101 rest -= size;
56102 + total_size += size;
56103 }
56104 }
56105 - return buffer_size - rest;
56106 + return total_size;
56107 }
56108
56109 static int
56110 diff --git a/fs/fcntl.c b/fs/fcntl.c
56111 index 65343c3..9969dcf 100644
56112 --- a/fs/fcntl.c
56113 +++ b/fs/fcntl.c
56114 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56115 if (err)
56116 return err;
56117
56118 + if (gr_handle_chroot_fowner(pid, type))
56119 + return -ENOENT;
56120 + if (gr_check_protected_task_fowner(pid, type))
56121 + return -EACCES;
56122 +
56123 f_modown(filp, pid, type, force);
56124 return 0;
56125 }
56126 diff --git a/fs/fhandle.c b/fs/fhandle.c
56127 index 999ff5c..41f4109 100644
56128 --- a/fs/fhandle.c
56129 +++ b/fs/fhandle.c
56130 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56131 } else
56132 retval = 0;
56133 /* copy the mount id */
56134 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56135 - sizeof(*mnt_id)) ||
56136 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56137 copy_to_user(ufh, handle,
56138 sizeof(struct file_handle) + handle_bytes))
56139 retval = -EFAULT;
56140 diff --git a/fs/file.c b/fs/file.c
56141 index 4a78f98..9447397 100644
56142 --- a/fs/file.c
56143 +++ b/fs/file.c
56144 @@ -16,6 +16,7 @@
56145 #include <linux/slab.h>
56146 #include <linux/vmalloc.h>
56147 #include <linux/file.h>
56148 +#include <linux/security.h>
56149 #include <linux/fdtable.h>
56150 #include <linux/bitops.h>
56151 #include <linux/interrupt.h>
56152 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56153 if (!file)
56154 return __close_fd(files, fd);
56155
56156 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56157 if (fd >= rlimit(RLIMIT_NOFILE))
56158 return -EBADF;
56159
56160 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56161 if (unlikely(oldfd == newfd))
56162 return -EINVAL;
56163
56164 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56165 if (newfd >= rlimit(RLIMIT_NOFILE))
56166 return -EBADF;
56167
56168 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56169 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56170 {
56171 int err;
56172 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56173 if (from >= rlimit(RLIMIT_NOFILE))
56174 return -EINVAL;
56175 err = alloc_fd(from, flags);
56176 diff --git a/fs/filesystems.c b/fs/filesystems.c
56177 index 92567d9..fcd8cbf 100644
56178 --- a/fs/filesystems.c
56179 +++ b/fs/filesystems.c
56180 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56181 int len = dot ? dot - name : strlen(name);
56182
56183 fs = __get_fs_type(name, len);
56184 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56185 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56186 +#else
56187 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56188 +#endif
56189 fs = __get_fs_type(name, len);
56190
56191 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56192 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56193 index d8ac61d..79a36f0 100644
56194 --- a/fs/fs_struct.c
56195 +++ b/fs/fs_struct.c
56196 @@ -4,6 +4,7 @@
56197 #include <linux/path.h>
56198 #include <linux/slab.h>
56199 #include <linux/fs_struct.h>
56200 +#include <linux/grsecurity.h>
56201 #include "internal.h"
56202
56203 /*
56204 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
56205 write_seqcount_begin(&fs->seq);
56206 old_root = fs->root;
56207 fs->root = *path;
56208 + gr_set_chroot_entries(current, path);
56209 write_seqcount_end(&fs->seq);
56210 spin_unlock(&fs->lock);
56211 if (old_root.dentry)
56212 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
56213 int hits = 0;
56214 spin_lock(&fs->lock);
56215 write_seqcount_begin(&fs->seq);
56216 + /* this root replacement is only done by pivot_root,
56217 + leave grsec's chroot tagging alone for this task
56218 + so that a pivoted root isn't treated as a chroot
56219 + */
56220 hits += replace_path(&fs->root, old_root, new_root);
56221 hits += replace_path(&fs->pwd, old_root, new_root);
56222 write_seqcount_end(&fs->seq);
56223 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
56224 task_lock(tsk);
56225 spin_lock(&fs->lock);
56226 tsk->fs = NULL;
56227 - kill = !--fs->users;
56228 + gr_clear_chroot_entries(tsk);
56229 + kill = !atomic_dec_return(&fs->users);
56230 spin_unlock(&fs->lock);
56231 task_unlock(tsk);
56232 if (kill)
56233 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56234 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
56235 /* We don't need to lock fs - think why ;-) */
56236 if (fs) {
56237 - fs->users = 1;
56238 + atomic_set(&fs->users, 1);
56239 fs->in_exec = 0;
56240 spin_lock_init(&fs->lock);
56241 seqcount_init(&fs->seq);
56242 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56243 spin_lock(&old->lock);
56244 fs->root = old->root;
56245 path_get(&fs->root);
56246 + /* instead of calling gr_set_chroot_entries here,
56247 + we call it from every caller of this function
56248 + */
56249 fs->pwd = old->pwd;
56250 path_get(&fs->pwd);
56251 spin_unlock(&old->lock);
56252 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
56253
56254 task_lock(current);
56255 spin_lock(&fs->lock);
56256 - kill = !--fs->users;
56257 + kill = !atomic_dec_return(&fs->users);
56258 current->fs = new_fs;
56259 + gr_set_chroot_entries(current, &new_fs->root);
56260 spin_unlock(&fs->lock);
56261 task_unlock(current);
56262
56263 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
56264
56265 int current_umask(void)
56266 {
56267 - return current->fs->umask;
56268 + return current->fs->umask | gr_acl_umask();
56269 }
56270 EXPORT_SYMBOL(current_umask);
56271
56272 /* to be mentioned only in INIT_TASK */
56273 struct fs_struct init_fs = {
56274 - .users = 1,
56275 + .users = ATOMIC_INIT(1),
56276 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
56277 .seq = SEQCNT_ZERO,
56278 .umask = 0022,
56279 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
56280 index b2a86e3..37f425a 100644
56281 --- a/fs/fscache/cookie.c
56282 +++ b/fs/fscache/cookie.c
56283 @@ -19,7 +19,7 @@
56284
56285 struct kmem_cache *fscache_cookie_jar;
56286
56287 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
56288 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
56289
56290 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
56291 static int fscache_alloc_object(struct fscache_cache *cache,
56292 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
56293 parent ? (char *) parent->def->name : "<no-parent>",
56294 def->name, netfs_data);
56295
56296 - fscache_stat(&fscache_n_acquires);
56297 + fscache_stat_unchecked(&fscache_n_acquires);
56298
56299 /* if there's no parent cookie, then we don't create one here either */
56300 if (!parent) {
56301 - fscache_stat(&fscache_n_acquires_null);
56302 + fscache_stat_unchecked(&fscache_n_acquires_null);
56303 _leave(" [no parent]");
56304 return NULL;
56305 }
56306 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
56307 /* allocate and initialise a cookie */
56308 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
56309 if (!cookie) {
56310 - fscache_stat(&fscache_n_acquires_oom);
56311 + fscache_stat_unchecked(&fscache_n_acquires_oom);
56312 _leave(" [ENOMEM]");
56313 return NULL;
56314 }
56315 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56316
56317 switch (cookie->def->type) {
56318 case FSCACHE_COOKIE_TYPE_INDEX:
56319 - fscache_stat(&fscache_n_cookie_index);
56320 + fscache_stat_unchecked(&fscache_n_cookie_index);
56321 break;
56322 case FSCACHE_COOKIE_TYPE_DATAFILE:
56323 - fscache_stat(&fscache_n_cookie_data);
56324 + fscache_stat_unchecked(&fscache_n_cookie_data);
56325 break;
56326 default:
56327 - fscache_stat(&fscache_n_cookie_special);
56328 + fscache_stat_unchecked(&fscache_n_cookie_special);
56329 break;
56330 }
56331
56332 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56333 if (fscache_acquire_non_index_cookie(cookie) < 0) {
56334 atomic_dec(&parent->n_children);
56335 __fscache_cookie_put(cookie);
56336 - fscache_stat(&fscache_n_acquires_nobufs);
56337 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
56338 _leave(" = NULL");
56339 return NULL;
56340 }
56341 }
56342
56343 - fscache_stat(&fscache_n_acquires_ok);
56344 + fscache_stat_unchecked(&fscache_n_acquires_ok);
56345 _leave(" = %p", cookie);
56346 return cookie;
56347 }
56348 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
56349 cache = fscache_select_cache_for_object(cookie->parent);
56350 if (!cache) {
56351 up_read(&fscache_addremove_sem);
56352 - fscache_stat(&fscache_n_acquires_no_cache);
56353 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
56354 _leave(" = -ENOMEDIUM [no cache]");
56355 return -ENOMEDIUM;
56356 }
56357 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
56358 object = cache->ops->alloc_object(cache, cookie);
56359 fscache_stat_d(&fscache_n_cop_alloc_object);
56360 if (IS_ERR(object)) {
56361 - fscache_stat(&fscache_n_object_no_alloc);
56362 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
56363 ret = PTR_ERR(object);
56364 goto error;
56365 }
56366
56367 - fscache_stat(&fscache_n_object_alloc);
56368 + fscache_stat_unchecked(&fscache_n_object_alloc);
56369
56370 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
56371 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
56372
56373 _debug("ALLOC OBJ%x: %s {%lx}",
56374 object->debug_id, cookie->def->name, object->events);
56375 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
56376
56377 _enter("{%s}", cookie->def->name);
56378
56379 - fscache_stat(&fscache_n_invalidates);
56380 + fscache_stat_unchecked(&fscache_n_invalidates);
56381
56382 /* Only permit invalidation of data files. Invalidating an index will
56383 * require the caller to release all its attachments to the tree rooted
56384 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
56385 {
56386 struct fscache_object *object;
56387
56388 - fscache_stat(&fscache_n_updates);
56389 + fscache_stat_unchecked(&fscache_n_updates);
56390
56391 if (!cookie) {
56392 - fscache_stat(&fscache_n_updates_null);
56393 + fscache_stat_unchecked(&fscache_n_updates_null);
56394 _leave(" [no cookie]");
56395 return;
56396 }
56397 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56398 {
56399 struct fscache_object *object;
56400
56401 - fscache_stat(&fscache_n_relinquishes);
56402 + fscache_stat_unchecked(&fscache_n_relinquishes);
56403 if (retire)
56404 - fscache_stat(&fscache_n_relinquishes_retire);
56405 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
56406
56407 if (!cookie) {
56408 - fscache_stat(&fscache_n_relinquishes_null);
56409 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
56410 _leave(" [no cookie]");
56411 return;
56412 }
56413 @@ -598,7 +598,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
56414 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
56415 goto inconsistent;
56416
56417 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
56418 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56419
56420 atomic_inc(&cookie->n_active);
56421 if (fscache_submit_op(object, op) < 0)
56422 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
56423 index 4226f66..0fb3f45 100644
56424 --- a/fs/fscache/internal.h
56425 +++ b/fs/fscache/internal.h
56426 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
56427 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
56428 extern int fscache_wait_for_operation_activation(struct fscache_object *,
56429 struct fscache_operation *,
56430 - atomic_t *,
56431 - atomic_t *,
56432 + atomic_unchecked_t *,
56433 + atomic_unchecked_t *,
56434 void (*)(struct fscache_operation *));
56435 extern void fscache_invalidate_writes(struct fscache_cookie *);
56436
56437 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
56438 * stats.c
56439 */
56440 #ifdef CONFIG_FSCACHE_STATS
56441 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56442 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56443 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56444 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56445
56446 -extern atomic_t fscache_n_op_pend;
56447 -extern atomic_t fscache_n_op_run;
56448 -extern atomic_t fscache_n_op_enqueue;
56449 -extern atomic_t fscache_n_op_deferred_release;
56450 -extern atomic_t fscache_n_op_release;
56451 -extern atomic_t fscache_n_op_gc;
56452 -extern atomic_t fscache_n_op_cancelled;
56453 -extern atomic_t fscache_n_op_rejected;
56454 +extern atomic_unchecked_t fscache_n_op_pend;
56455 +extern atomic_unchecked_t fscache_n_op_run;
56456 +extern atomic_unchecked_t fscache_n_op_enqueue;
56457 +extern atomic_unchecked_t fscache_n_op_deferred_release;
56458 +extern atomic_unchecked_t fscache_n_op_release;
56459 +extern atomic_unchecked_t fscache_n_op_gc;
56460 +extern atomic_unchecked_t fscache_n_op_cancelled;
56461 +extern atomic_unchecked_t fscache_n_op_rejected;
56462
56463 -extern atomic_t fscache_n_attr_changed;
56464 -extern atomic_t fscache_n_attr_changed_ok;
56465 -extern atomic_t fscache_n_attr_changed_nobufs;
56466 -extern atomic_t fscache_n_attr_changed_nomem;
56467 -extern atomic_t fscache_n_attr_changed_calls;
56468 +extern atomic_unchecked_t fscache_n_attr_changed;
56469 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
56470 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
56471 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
56472 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
56473
56474 -extern atomic_t fscache_n_allocs;
56475 -extern atomic_t fscache_n_allocs_ok;
56476 -extern atomic_t fscache_n_allocs_wait;
56477 -extern atomic_t fscache_n_allocs_nobufs;
56478 -extern atomic_t fscache_n_allocs_intr;
56479 -extern atomic_t fscache_n_allocs_object_dead;
56480 -extern atomic_t fscache_n_alloc_ops;
56481 -extern atomic_t fscache_n_alloc_op_waits;
56482 +extern atomic_unchecked_t fscache_n_allocs;
56483 +extern atomic_unchecked_t fscache_n_allocs_ok;
56484 +extern atomic_unchecked_t fscache_n_allocs_wait;
56485 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
56486 +extern atomic_unchecked_t fscache_n_allocs_intr;
56487 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
56488 +extern atomic_unchecked_t fscache_n_alloc_ops;
56489 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
56490
56491 -extern atomic_t fscache_n_retrievals;
56492 -extern atomic_t fscache_n_retrievals_ok;
56493 -extern atomic_t fscache_n_retrievals_wait;
56494 -extern atomic_t fscache_n_retrievals_nodata;
56495 -extern atomic_t fscache_n_retrievals_nobufs;
56496 -extern atomic_t fscache_n_retrievals_intr;
56497 -extern atomic_t fscache_n_retrievals_nomem;
56498 -extern atomic_t fscache_n_retrievals_object_dead;
56499 -extern atomic_t fscache_n_retrieval_ops;
56500 -extern atomic_t fscache_n_retrieval_op_waits;
56501 +extern atomic_unchecked_t fscache_n_retrievals;
56502 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56503 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56504 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56505 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56506 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56507 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56508 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56509 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56510 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56511
56512 -extern atomic_t fscache_n_stores;
56513 -extern atomic_t fscache_n_stores_ok;
56514 -extern atomic_t fscache_n_stores_again;
56515 -extern atomic_t fscache_n_stores_nobufs;
56516 -extern atomic_t fscache_n_stores_oom;
56517 -extern atomic_t fscache_n_store_ops;
56518 -extern atomic_t fscache_n_store_calls;
56519 -extern atomic_t fscache_n_store_pages;
56520 -extern atomic_t fscache_n_store_radix_deletes;
56521 -extern atomic_t fscache_n_store_pages_over_limit;
56522 +extern atomic_unchecked_t fscache_n_stores;
56523 +extern atomic_unchecked_t fscache_n_stores_ok;
56524 +extern atomic_unchecked_t fscache_n_stores_again;
56525 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56526 +extern atomic_unchecked_t fscache_n_stores_oom;
56527 +extern atomic_unchecked_t fscache_n_store_ops;
56528 +extern atomic_unchecked_t fscache_n_store_calls;
56529 +extern atomic_unchecked_t fscache_n_store_pages;
56530 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56531 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56532
56533 -extern atomic_t fscache_n_store_vmscan_not_storing;
56534 -extern atomic_t fscache_n_store_vmscan_gone;
56535 -extern atomic_t fscache_n_store_vmscan_busy;
56536 -extern atomic_t fscache_n_store_vmscan_cancelled;
56537 -extern atomic_t fscache_n_store_vmscan_wait;
56538 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56539 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56540 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56541 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56542 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56543
56544 -extern atomic_t fscache_n_marks;
56545 -extern atomic_t fscache_n_uncaches;
56546 +extern atomic_unchecked_t fscache_n_marks;
56547 +extern atomic_unchecked_t fscache_n_uncaches;
56548
56549 -extern atomic_t fscache_n_acquires;
56550 -extern atomic_t fscache_n_acquires_null;
56551 -extern atomic_t fscache_n_acquires_no_cache;
56552 -extern atomic_t fscache_n_acquires_ok;
56553 -extern atomic_t fscache_n_acquires_nobufs;
56554 -extern atomic_t fscache_n_acquires_oom;
56555 +extern atomic_unchecked_t fscache_n_acquires;
56556 +extern atomic_unchecked_t fscache_n_acquires_null;
56557 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56558 +extern atomic_unchecked_t fscache_n_acquires_ok;
56559 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56560 +extern atomic_unchecked_t fscache_n_acquires_oom;
56561
56562 -extern atomic_t fscache_n_invalidates;
56563 -extern atomic_t fscache_n_invalidates_run;
56564 +extern atomic_unchecked_t fscache_n_invalidates;
56565 +extern atomic_unchecked_t fscache_n_invalidates_run;
56566
56567 -extern atomic_t fscache_n_updates;
56568 -extern atomic_t fscache_n_updates_null;
56569 -extern atomic_t fscache_n_updates_run;
56570 +extern atomic_unchecked_t fscache_n_updates;
56571 +extern atomic_unchecked_t fscache_n_updates_null;
56572 +extern atomic_unchecked_t fscache_n_updates_run;
56573
56574 -extern atomic_t fscache_n_relinquishes;
56575 -extern atomic_t fscache_n_relinquishes_null;
56576 -extern atomic_t fscache_n_relinquishes_waitcrt;
56577 -extern atomic_t fscache_n_relinquishes_retire;
56578 +extern atomic_unchecked_t fscache_n_relinquishes;
56579 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56580 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56581 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56582
56583 -extern atomic_t fscache_n_cookie_index;
56584 -extern atomic_t fscache_n_cookie_data;
56585 -extern atomic_t fscache_n_cookie_special;
56586 +extern atomic_unchecked_t fscache_n_cookie_index;
56587 +extern atomic_unchecked_t fscache_n_cookie_data;
56588 +extern atomic_unchecked_t fscache_n_cookie_special;
56589
56590 -extern atomic_t fscache_n_object_alloc;
56591 -extern atomic_t fscache_n_object_no_alloc;
56592 -extern atomic_t fscache_n_object_lookups;
56593 -extern atomic_t fscache_n_object_lookups_negative;
56594 -extern atomic_t fscache_n_object_lookups_positive;
56595 -extern atomic_t fscache_n_object_lookups_timed_out;
56596 -extern atomic_t fscache_n_object_created;
56597 -extern atomic_t fscache_n_object_avail;
56598 -extern atomic_t fscache_n_object_dead;
56599 +extern atomic_unchecked_t fscache_n_object_alloc;
56600 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56601 +extern atomic_unchecked_t fscache_n_object_lookups;
56602 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56603 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56604 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56605 +extern atomic_unchecked_t fscache_n_object_created;
56606 +extern atomic_unchecked_t fscache_n_object_avail;
56607 +extern atomic_unchecked_t fscache_n_object_dead;
56608
56609 -extern atomic_t fscache_n_checkaux_none;
56610 -extern atomic_t fscache_n_checkaux_okay;
56611 -extern atomic_t fscache_n_checkaux_update;
56612 -extern atomic_t fscache_n_checkaux_obsolete;
56613 +extern atomic_unchecked_t fscache_n_checkaux_none;
56614 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56615 +extern atomic_unchecked_t fscache_n_checkaux_update;
56616 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56617
56618 extern atomic_t fscache_n_cop_alloc_object;
56619 extern atomic_t fscache_n_cop_lookup_object;
56620 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
56621 atomic_inc(stat);
56622 }
56623
56624 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56625 +{
56626 + atomic_inc_unchecked(stat);
56627 +}
56628 +
56629 static inline void fscache_stat_d(atomic_t *stat)
56630 {
56631 atomic_dec(stat);
56632 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
56633
56634 #define __fscache_stat(stat) (NULL)
56635 #define fscache_stat(stat) do {} while (0)
56636 +#define fscache_stat_unchecked(stat) do {} while (0)
56637 #define fscache_stat_d(stat) do {} while (0)
56638 #endif
56639
56640 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56641 index 86d75a6..5f3d7a0 100644
56642 --- a/fs/fscache/object.c
56643 +++ b/fs/fscache/object.c
56644 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56645 _debug("LOOKUP \"%s\" in \"%s\"",
56646 cookie->def->name, object->cache->tag->name);
56647
56648 - fscache_stat(&fscache_n_object_lookups);
56649 + fscache_stat_unchecked(&fscache_n_object_lookups);
56650 fscache_stat(&fscache_n_cop_lookup_object);
56651 ret = object->cache->ops->lookup_object(object);
56652 fscache_stat_d(&fscache_n_cop_lookup_object);
56653 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56654 if (ret == -ETIMEDOUT) {
56655 /* probably stuck behind another object, so move this one to
56656 * the back of the queue */
56657 - fscache_stat(&fscache_n_object_lookups_timed_out);
56658 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56659 _leave(" [timeout]");
56660 return NO_TRANSIT;
56661 }
56662 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56663 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56664
56665 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56666 - fscache_stat(&fscache_n_object_lookups_negative);
56667 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56668
56669 /* Allow write requests to begin stacking up and read requests to begin
56670 * returning ENODATA.
56671 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56672 /* if we were still looking up, then we must have a positive lookup
56673 * result, in which case there may be data available */
56674 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56675 - fscache_stat(&fscache_n_object_lookups_positive);
56676 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56677
56678 /* We do (presumably) have data */
56679 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56680 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56681 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56682 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56683 } else {
56684 - fscache_stat(&fscache_n_object_created);
56685 + fscache_stat_unchecked(&fscache_n_object_created);
56686 }
56687
56688 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56689 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56690 fscache_stat_d(&fscache_n_cop_lookup_complete);
56691
56692 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56693 - fscache_stat(&fscache_n_object_avail);
56694 + fscache_stat_unchecked(&fscache_n_object_avail);
56695
56696 _leave("");
56697 return transit_to(JUMPSTART_DEPS);
56698 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56699
56700 /* this just shifts the object release to the work processor */
56701 fscache_put_object(object);
56702 - fscache_stat(&fscache_n_object_dead);
56703 + fscache_stat_unchecked(&fscache_n_object_dead);
56704
56705 _leave("");
56706 return transit_to(OBJECT_DEAD);
56707 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56708 enum fscache_checkaux result;
56709
56710 if (!object->cookie->def->check_aux) {
56711 - fscache_stat(&fscache_n_checkaux_none);
56712 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56713 return FSCACHE_CHECKAUX_OKAY;
56714 }
56715
56716 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56717 switch (result) {
56718 /* entry okay as is */
56719 case FSCACHE_CHECKAUX_OKAY:
56720 - fscache_stat(&fscache_n_checkaux_okay);
56721 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56722 break;
56723
56724 /* entry requires update */
56725 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56726 - fscache_stat(&fscache_n_checkaux_update);
56727 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56728 break;
56729
56730 /* entry requires deletion */
56731 case FSCACHE_CHECKAUX_OBSOLETE:
56732 - fscache_stat(&fscache_n_checkaux_obsolete);
56733 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56734 break;
56735
56736 default:
56737 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56738 {
56739 const struct fscache_state *s;
56740
56741 - fscache_stat(&fscache_n_invalidates_run);
56742 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56743 fscache_stat(&fscache_n_cop_invalidate_object);
56744 s = _fscache_invalidate_object(object, event);
56745 fscache_stat_d(&fscache_n_cop_invalidate_object);
56746 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56747 {
56748 _enter("{OBJ%x},%d", object->debug_id, event);
56749
56750 - fscache_stat(&fscache_n_updates_run);
56751 + fscache_stat_unchecked(&fscache_n_updates_run);
56752 fscache_stat(&fscache_n_cop_update_object);
56753 object->cache->ops->update_object(object);
56754 fscache_stat_d(&fscache_n_cop_update_object);
56755 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56756 index 318071a..379938b 100644
56757 --- a/fs/fscache/operation.c
56758 +++ b/fs/fscache/operation.c
56759 @@ -17,7 +17,7 @@
56760 #include <linux/slab.h>
56761 #include "internal.h"
56762
56763 -atomic_t fscache_op_debug_id;
56764 +atomic_unchecked_t fscache_op_debug_id;
56765 EXPORT_SYMBOL(fscache_op_debug_id);
56766
56767 /**
56768 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56769 ASSERTCMP(atomic_read(&op->usage), >, 0);
56770 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56771
56772 - fscache_stat(&fscache_n_op_enqueue);
56773 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56774 switch (op->flags & FSCACHE_OP_TYPE) {
56775 case FSCACHE_OP_ASYNC:
56776 _debug("queue async");
56777 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56778 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56779 if (op->processor)
56780 fscache_enqueue_operation(op);
56781 - fscache_stat(&fscache_n_op_run);
56782 + fscache_stat_unchecked(&fscache_n_op_run);
56783 }
56784
56785 /*
56786 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56787 if (object->n_in_progress > 0) {
56788 atomic_inc(&op->usage);
56789 list_add_tail(&op->pend_link, &object->pending_ops);
56790 - fscache_stat(&fscache_n_op_pend);
56791 + fscache_stat_unchecked(&fscache_n_op_pend);
56792 } else if (!list_empty(&object->pending_ops)) {
56793 atomic_inc(&op->usage);
56794 list_add_tail(&op->pend_link, &object->pending_ops);
56795 - fscache_stat(&fscache_n_op_pend);
56796 + fscache_stat_unchecked(&fscache_n_op_pend);
56797 fscache_start_operations(object);
56798 } else {
56799 ASSERTCMP(object->n_in_progress, ==, 0);
56800 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56801 object->n_exclusive++; /* reads and writes must wait */
56802 atomic_inc(&op->usage);
56803 list_add_tail(&op->pend_link, &object->pending_ops);
56804 - fscache_stat(&fscache_n_op_pend);
56805 + fscache_stat_unchecked(&fscache_n_op_pend);
56806 ret = 0;
56807 } else {
56808 /* If we're in any other state, there must have been an I/O
56809 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56810 if (object->n_exclusive > 0) {
56811 atomic_inc(&op->usage);
56812 list_add_tail(&op->pend_link, &object->pending_ops);
56813 - fscache_stat(&fscache_n_op_pend);
56814 + fscache_stat_unchecked(&fscache_n_op_pend);
56815 } else if (!list_empty(&object->pending_ops)) {
56816 atomic_inc(&op->usage);
56817 list_add_tail(&op->pend_link, &object->pending_ops);
56818 - fscache_stat(&fscache_n_op_pend);
56819 + fscache_stat_unchecked(&fscache_n_op_pend);
56820 fscache_start_operations(object);
56821 } else {
56822 ASSERTCMP(object->n_exclusive, ==, 0);
56823 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56824 object->n_ops++;
56825 atomic_inc(&op->usage);
56826 list_add_tail(&op->pend_link, &object->pending_ops);
56827 - fscache_stat(&fscache_n_op_pend);
56828 + fscache_stat_unchecked(&fscache_n_op_pend);
56829 ret = 0;
56830 } else if (fscache_object_is_dying(object)) {
56831 - fscache_stat(&fscache_n_op_rejected);
56832 + fscache_stat_unchecked(&fscache_n_op_rejected);
56833 op->state = FSCACHE_OP_ST_CANCELLED;
56834 ret = -ENOBUFS;
56835 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56836 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56837 ret = -EBUSY;
56838 if (op->state == FSCACHE_OP_ST_PENDING) {
56839 ASSERT(!list_empty(&op->pend_link));
56840 - fscache_stat(&fscache_n_op_cancelled);
56841 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56842 list_del_init(&op->pend_link);
56843 if (do_cancel)
56844 do_cancel(op);
56845 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56846 while (!list_empty(&object->pending_ops)) {
56847 op = list_entry(object->pending_ops.next,
56848 struct fscache_operation, pend_link);
56849 - fscache_stat(&fscache_n_op_cancelled);
56850 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56851 list_del_init(&op->pend_link);
56852
56853 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56854 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56855 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56856 op->state = FSCACHE_OP_ST_DEAD;
56857
56858 - fscache_stat(&fscache_n_op_release);
56859 + fscache_stat_unchecked(&fscache_n_op_release);
56860
56861 if (op->release) {
56862 op->release(op);
56863 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56864 * lock, and defer it otherwise */
56865 if (!spin_trylock(&object->lock)) {
56866 _debug("defer put");
56867 - fscache_stat(&fscache_n_op_deferred_release);
56868 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56869
56870 cache = object->cache;
56871 spin_lock(&cache->op_gc_list_lock);
56872 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56873
56874 _debug("GC DEFERRED REL OBJ%x OP%x",
56875 object->debug_id, op->debug_id);
56876 - fscache_stat(&fscache_n_op_gc);
56877 + fscache_stat_unchecked(&fscache_n_op_gc);
56878
56879 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56880 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56881 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56882 index 73899c1..ae40c58 100644
56883 --- a/fs/fscache/page.c
56884 +++ b/fs/fscache/page.c
56885 @@ -61,7 +61,7 @@ try_again:
56886 val = radix_tree_lookup(&cookie->stores, page->index);
56887 if (!val) {
56888 rcu_read_unlock();
56889 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56890 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56891 __fscache_uncache_page(cookie, page);
56892 return true;
56893 }
56894 @@ -91,11 +91,11 @@ try_again:
56895 spin_unlock(&cookie->stores_lock);
56896
56897 if (xpage) {
56898 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56899 - fscache_stat(&fscache_n_store_radix_deletes);
56900 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56901 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56902 ASSERTCMP(xpage, ==, page);
56903 } else {
56904 - fscache_stat(&fscache_n_store_vmscan_gone);
56905 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56906 }
56907
56908 wake_up_bit(&cookie->flags, 0);
56909 @@ -110,11 +110,11 @@ page_busy:
56910 * sleeping on memory allocation, so we may need to impose a timeout
56911 * too. */
56912 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56913 - fscache_stat(&fscache_n_store_vmscan_busy);
56914 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56915 return false;
56916 }
56917
56918 - fscache_stat(&fscache_n_store_vmscan_wait);
56919 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56920 __fscache_wait_on_page_write(cookie, page);
56921 gfp &= ~__GFP_WAIT;
56922 goto try_again;
56923 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56924 FSCACHE_COOKIE_STORING_TAG);
56925 if (!radix_tree_tag_get(&cookie->stores, page->index,
56926 FSCACHE_COOKIE_PENDING_TAG)) {
56927 - fscache_stat(&fscache_n_store_radix_deletes);
56928 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56929 xpage = radix_tree_delete(&cookie->stores, page->index);
56930 }
56931 spin_unlock(&cookie->stores_lock);
56932 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56933
56934 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56935
56936 - fscache_stat(&fscache_n_attr_changed_calls);
56937 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56938
56939 if (fscache_object_is_active(object) &&
56940 fscache_use_cookie(object)) {
56941 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56942
56943 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56944
56945 - fscache_stat(&fscache_n_attr_changed);
56946 + fscache_stat_unchecked(&fscache_n_attr_changed);
56947
56948 op = kzalloc(sizeof(*op), GFP_KERNEL);
56949 if (!op) {
56950 - fscache_stat(&fscache_n_attr_changed_nomem);
56951 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56952 _leave(" = -ENOMEM");
56953 return -ENOMEM;
56954 }
56955 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56956 if (fscache_submit_exclusive_op(object, op) < 0)
56957 goto nobufs;
56958 spin_unlock(&cookie->lock);
56959 - fscache_stat(&fscache_n_attr_changed_ok);
56960 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56961 fscache_put_operation(op);
56962 _leave(" = 0");
56963 return 0;
56964 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56965 nobufs:
56966 spin_unlock(&cookie->lock);
56967 kfree(op);
56968 - fscache_stat(&fscache_n_attr_changed_nobufs);
56969 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56970 _leave(" = %d", -ENOBUFS);
56971 return -ENOBUFS;
56972 }
56973 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56974 /* allocate a retrieval operation and attempt to submit it */
56975 op = kzalloc(sizeof(*op), GFP_NOIO);
56976 if (!op) {
56977 - fscache_stat(&fscache_n_retrievals_nomem);
56978 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56979 return NULL;
56980 }
56981
56982 @@ -289,13 +289,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56983 return 0;
56984 }
56985
56986 - fscache_stat(&fscache_n_retrievals_wait);
56987 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56988
56989 jif = jiffies;
56990 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56991 fscache_wait_bit_interruptible,
56992 TASK_INTERRUPTIBLE) != 0) {
56993 - fscache_stat(&fscache_n_retrievals_intr);
56994 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56995 _leave(" = -ERESTARTSYS");
56996 return -ERESTARTSYS;
56997 }
56998 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56999 */
57000 int fscache_wait_for_operation_activation(struct fscache_object *object,
57001 struct fscache_operation *op,
57002 - atomic_t *stat_op_waits,
57003 - atomic_t *stat_object_dead,
57004 + atomic_unchecked_t *stat_op_waits,
57005 + atomic_unchecked_t *stat_object_dead,
57006 void (*do_cancel)(struct fscache_operation *))
57007 {
57008 int ret;
57009 @@ -335,7 +335,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57010
57011 _debug(">>> WT");
57012 if (stat_op_waits)
57013 - fscache_stat(stat_op_waits);
57014 + fscache_stat_unchecked(stat_op_waits);
57015 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
57016 fscache_wait_bit_interruptible,
57017 TASK_INTERRUPTIBLE) != 0) {
57018 @@ -353,7 +353,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57019 check_if_dead:
57020 if (op->state == FSCACHE_OP_ST_CANCELLED) {
57021 if (stat_object_dead)
57022 - fscache_stat(stat_object_dead);
57023 + fscache_stat_unchecked(stat_object_dead);
57024 _leave(" = -ENOBUFS [cancelled]");
57025 return -ENOBUFS;
57026 }
57027 @@ -361,7 +361,7 @@ check_if_dead:
57028 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
57029 fscache_cancel_op(op, do_cancel);
57030 if (stat_object_dead)
57031 - fscache_stat(stat_object_dead);
57032 + fscache_stat_unchecked(stat_object_dead);
57033 return -ENOBUFS;
57034 }
57035 return 0;
57036 @@ -388,7 +388,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57037
57038 _enter("%p,%p,,,", cookie, page);
57039
57040 - fscache_stat(&fscache_n_retrievals);
57041 + fscache_stat_unchecked(&fscache_n_retrievals);
57042
57043 if (hlist_empty(&cookie->backing_objects))
57044 goto nobufs;
57045 @@ -428,7 +428,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57046 goto nobufs_unlock_dec;
57047 spin_unlock(&cookie->lock);
57048
57049 - fscache_stat(&fscache_n_retrieval_ops);
57050 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57051
57052 /* pin the netfs read context in case we need to do the actual netfs
57053 * read because we've encountered a cache read failure */
57054 @@ -459,15 +459,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57055
57056 error:
57057 if (ret == -ENOMEM)
57058 - fscache_stat(&fscache_n_retrievals_nomem);
57059 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57060 else if (ret == -ERESTARTSYS)
57061 - fscache_stat(&fscache_n_retrievals_intr);
57062 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57063 else if (ret == -ENODATA)
57064 - fscache_stat(&fscache_n_retrievals_nodata);
57065 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57066 else if (ret < 0)
57067 - fscache_stat(&fscache_n_retrievals_nobufs);
57068 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57069 else
57070 - fscache_stat(&fscache_n_retrievals_ok);
57071 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57072
57073 fscache_put_retrieval(op);
57074 _leave(" = %d", ret);
57075 @@ -480,7 +480,7 @@ nobufs_unlock:
57076 atomic_dec(&cookie->n_active);
57077 kfree(op);
57078 nobufs:
57079 - fscache_stat(&fscache_n_retrievals_nobufs);
57080 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57081 _leave(" = -ENOBUFS");
57082 return -ENOBUFS;
57083 }
57084 @@ -518,7 +518,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57085
57086 _enter("%p,,%d,,,", cookie, *nr_pages);
57087
57088 - fscache_stat(&fscache_n_retrievals);
57089 + fscache_stat_unchecked(&fscache_n_retrievals);
57090
57091 if (hlist_empty(&cookie->backing_objects))
57092 goto nobufs;
57093 @@ -554,7 +554,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57094 goto nobufs_unlock_dec;
57095 spin_unlock(&cookie->lock);
57096
57097 - fscache_stat(&fscache_n_retrieval_ops);
57098 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57099
57100 /* pin the netfs read context in case we need to do the actual netfs
57101 * read because we've encountered a cache read failure */
57102 @@ -585,15 +585,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57103
57104 error:
57105 if (ret == -ENOMEM)
57106 - fscache_stat(&fscache_n_retrievals_nomem);
57107 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57108 else if (ret == -ERESTARTSYS)
57109 - fscache_stat(&fscache_n_retrievals_intr);
57110 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57111 else if (ret == -ENODATA)
57112 - fscache_stat(&fscache_n_retrievals_nodata);
57113 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57114 else if (ret < 0)
57115 - fscache_stat(&fscache_n_retrievals_nobufs);
57116 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57117 else
57118 - fscache_stat(&fscache_n_retrievals_ok);
57119 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57120
57121 fscache_put_retrieval(op);
57122 _leave(" = %d", ret);
57123 @@ -606,7 +606,7 @@ nobufs_unlock:
57124 atomic_dec(&cookie->n_active);
57125 kfree(op);
57126 nobufs:
57127 - fscache_stat(&fscache_n_retrievals_nobufs);
57128 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57129 _leave(" = -ENOBUFS");
57130 return -ENOBUFS;
57131 }
57132 @@ -630,7 +630,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57133
57134 _enter("%p,%p,,,", cookie, page);
57135
57136 - fscache_stat(&fscache_n_allocs);
57137 + fscache_stat_unchecked(&fscache_n_allocs);
57138
57139 if (hlist_empty(&cookie->backing_objects))
57140 goto nobufs;
57141 @@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57142 goto nobufs_unlock;
57143 spin_unlock(&cookie->lock);
57144
57145 - fscache_stat(&fscache_n_alloc_ops);
57146 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57147
57148 ret = fscache_wait_for_operation_activation(
57149 object, &op->op,
57150 @@ -679,11 +679,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57151
57152 error:
57153 if (ret == -ERESTARTSYS)
57154 - fscache_stat(&fscache_n_allocs_intr);
57155 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57156 else if (ret < 0)
57157 - fscache_stat(&fscache_n_allocs_nobufs);
57158 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57159 else
57160 - fscache_stat(&fscache_n_allocs_ok);
57161 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57162
57163 fscache_put_retrieval(op);
57164 _leave(" = %d", ret);
57165 @@ -694,7 +694,7 @@ nobufs_unlock:
57166 atomic_dec(&cookie->n_active);
57167 kfree(op);
57168 nobufs:
57169 - fscache_stat(&fscache_n_allocs_nobufs);
57170 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57171 _leave(" = -ENOBUFS");
57172 return -ENOBUFS;
57173 }
57174 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57175
57176 spin_lock(&cookie->stores_lock);
57177
57178 - fscache_stat(&fscache_n_store_calls);
57179 + fscache_stat_unchecked(&fscache_n_store_calls);
57180
57181 /* find a page to store */
57182 page = NULL;
57183 @@ -781,7 +781,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57184 page = results[0];
57185 _debug("gang %d [%lx]", n, page->index);
57186 if (page->index > op->store_limit) {
57187 - fscache_stat(&fscache_n_store_pages_over_limit);
57188 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57189 goto superseded;
57190 }
57191
57192 @@ -793,7 +793,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57193 spin_unlock(&cookie->stores_lock);
57194 spin_unlock(&object->lock);
57195
57196 - fscache_stat(&fscache_n_store_pages);
57197 + fscache_stat_unchecked(&fscache_n_store_pages);
57198 fscache_stat(&fscache_n_cop_write_page);
57199 ret = object->cache->ops->write_page(op, page);
57200 fscache_stat_d(&fscache_n_cop_write_page);
57201 @@ -896,7 +896,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57202 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57203 ASSERT(PageFsCache(page));
57204
57205 - fscache_stat(&fscache_n_stores);
57206 + fscache_stat_unchecked(&fscache_n_stores);
57207
57208 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
57209 _leave(" = -ENOBUFS [invalidating]");
57210 @@ -954,7 +954,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57211 spin_unlock(&cookie->stores_lock);
57212 spin_unlock(&object->lock);
57213
57214 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
57215 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57216 op->store_limit = object->store_limit;
57217
57218 atomic_inc(&cookie->n_active);
57219 @@ -963,8 +963,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57220
57221 spin_unlock(&cookie->lock);
57222 radix_tree_preload_end();
57223 - fscache_stat(&fscache_n_store_ops);
57224 - fscache_stat(&fscache_n_stores_ok);
57225 + fscache_stat_unchecked(&fscache_n_store_ops);
57226 + fscache_stat_unchecked(&fscache_n_stores_ok);
57227
57228 /* the work queue now carries its own ref on the object */
57229 fscache_put_operation(&op->op);
57230 @@ -972,14 +972,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57231 return 0;
57232
57233 already_queued:
57234 - fscache_stat(&fscache_n_stores_again);
57235 + fscache_stat_unchecked(&fscache_n_stores_again);
57236 already_pending:
57237 spin_unlock(&cookie->stores_lock);
57238 spin_unlock(&object->lock);
57239 spin_unlock(&cookie->lock);
57240 radix_tree_preload_end();
57241 kfree(op);
57242 - fscache_stat(&fscache_n_stores_ok);
57243 + fscache_stat_unchecked(&fscache_n_stores_ok);
57244 _leave(" = 0");
57245 return 0;
57246
57247 @@ -999,14 +999,14 @@ nobufs:
57248 spin_unlock(&cookie->lock);
57249 radix_tree_preload_end();
57250 kfree(op);
57251 - fscache_stat(&fscache_n_stores_nobufs);
57252 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
57253 _leave(" = -ENOBUFS");
57254 return -ENOBUFS;
57255
57256 nomem_free:
57257 kfree(op);
57258 nomem:
57259 - fscache_stat(&fscache_n_stores_oom);
57260 + fscache_stat_unchecked(&fscache_n_stores_oom);
57261 _leave(" = -ENOMEM");
57262 return -ENOMEM;
57263 }
57264 @@ -1024,7 +1024,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
57265 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57266 ASSERTCMP(page, !=, NULL);
57267
57268 - fscache_stat(&fscache_n_uncaches);
57269 + fscache_stat_unchecked(&fscache_n_uncaches);
57270
57271 /* cache withdrawal may beat us to it */
57272 if (!PageFsCache(page))
57273 @@ -1075,7 +1075,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
57274 struct fscache_cookie *cookie = op->op.object->cookie;
57275
57276 #ifdef CONFIG_FSCACHE_STATS
57277 - atomic_inc(&fscache_n_marks);
57278 + atomic_inc_unchecked(&fscache_n_marks);
57279 #endif
57280
57281 _debug("- mark %p{%lx}", page, page->index);
57282 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
57283 index 40d13c7..ddf52b9 100644
57284 --- a/fs/fscache/stats.c
57285 +++ b/fs/fscache/stats.c
57286 @@ -18,99 +18,99 @@
57287 /*
57288 * operation counters
57289 */
57290 -atomic_t fscache_n_op_pend;
57291 -atomic_t fscache_n_op_run;
57292 -atomic_t fscache_n_op_enqueue;
57293 -atomic_t fscache_n_op_requeue;
57294 -atomic_t fscache_n_op_deferred_release;
57295 -atomic_t fscache_n_op_release;
57296 -atomic_t fscache_n_op_gc;
57297 -atomic_t fscache_n_op_cancelled;
57298 -atomic_t fscache_n_op_rejected;
57299 +atomic_unchecked_t fscache_n_op_pend;
57300 +atomic_unchecked_t fscache_n_op_run;
57301 +atomic_unchecked_t fscache_n_op_enqueue;
57302 +atomic_unchecked_t fscache_n_op_requeue;
57303 +atomic_unchecked_t fscache_n_op_deferred_release;
57304 +atomic_unchecked_t fscache_n_op_release;
57305 +atomic_unchecked_t fscache_n_op_gc;
57306 +atomic_unchecked_t fscache_n_op_cancelled;
57307 +atomic_unchecked_t fscache_n_op_rejected;
57308
57309 -atomic_t fscache_n_attr_changed;
57310 -atomic_t fscache_n_attr_changed_ok;
57311 -atomic_t fscache_n_attr_changed_nobufs;
57312 -atomic_t fscache_n_attr_changed_nomem;
57313 -atomic_t fscache_n_attr_changed_calls;
57314 +atomic_unchecked_t fscache_n_attr_changed;
57315 +atomic_unchecked_t fscache_n_attr_changed_ok;
57316 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
57317 +atomic_unchecked_t fscache_n_attr_changed_nomem;
57318 +atomic_unchecked_t fscache_n_attr_changed_calls;
57319
57320 -atomic_t fscache_n_allocs;
57321 -atomic_t fscache_n_allocs_ok;
57322 -atomic_t fscache_n_allocs_wait;
57323 -atomic_t fscache_n_allocs_nobufs;
57324 -atomic_t fscache_n_allocs_intr;
57325 -atomic_t fscache_n_allocs_object_dead;
57326 -atomic_t fscache_n_alloc_ops;
57327 -atomic_t fscache_n_alloc_op_waits;
57328 +atomic_unchecked_t fscache_n_allocs;
57329 +atomic_unchecked_t fscache_n_allocs_ok;
57330 +atomic_unchecked_t fscache_n_allocs_wait;
57331 +atomic_unchecked_t fscache_n_allocs_nobufs;
57332 +atomic_unchecked_t fscache_n_allocs_intr;
57333 +atomic_unchecked_t fscache_n_allocs_object_dead;
57334 +atomic_unchecked_t fscache_n_alloc_ops;
57335 +atomic_unchecked_t fscache_n_alloc_op_waits;
57336
57337 -atomic_t fscache_n_retrievals;
57338 -atomic_t fscache_n_retrievals_ok;
57339 -atomic_t fscache_n_retrievals_wait;
57340 -atomic_t fscache_n_retrievals_nodata;
57341 -atomic_t fscache_n_retrievals_nobufs;
57342 -atomic_t fscache_n_retrievals_intr;
57343 -atomic_t fscache_n_retrievals_nomem;
57344 -atomic_t fscache_n_retrievals_object_dead;
57345 -atomic_t fscache_n_retrieval_ops;
57346 -atomic_t fscache_n_retrieval_op_waits;
57347 +atomic_unchecked_t fscache_n_retrievals;
57348 +atomic_unchecked_t fscache_n_retrievals_ok;
57349 +atomic_unchecked_t fscache_n_retrievals_wait;
57350 +atomic_unchecked_t fscache_n_retrievals_nodata;
57351 +atomic_unchecked_t fscache_n_retrievals_nobufs;
57352 +atomic_unchecked_t fscache_n_retrievals_intr;
57353 +atomic_unchecked_t fscache_n_retrievals_nomem;
57354 +atomic_unchecked_t fscache_n_retrievals_object_dead;
57355 +atomic_unchecked_t fscache_n_retrieval_ops;
57356 +atomic_unchecked_t fscache_n_retrieval_op_waits;
57357
57358 -atomic_t fscache_n_stores;
57359 -atomic_t fscache_n_stores_ok;
57360 -atomic_t fscache_n_stores_again;
57361 -atomic_t fscache_n_stores_nobufs;
57362 -atomic_t fscache_n_stores_oom;
57363 -atomic_t fscache_n_store_ops;
57364 -atomic_t fscache_n_store_calls;
57365 -atomic_t fscache_n_store_pages;
57366 -atomic_t fscache_n_store_radix_deletes;
57367 -atomic_t fscache_n_store_pages_over_limit;
57368 +atomic_unchecked_t fscache_n_stores;
57369 +atomic_unchecked_t fscache_n_stores_ok;
57370 +atomic_unchecked_t fscache_n_stores_again;
57371 +atomic_unchecked_t fscache_n_stores_nobufs;
57372 +atomic_unchecked_t fscache_n_stores_oom;
57373 +atomic_unchecked_t fscache_n_store_ops;
57374 +atomic_unchecked_t fscache_n_store_calls;
57375 +atomic_unchecked_t fscache_n_store_pages;
57376 +atomic_unchecked_t fscache_n_store_radix_deletes;
57377 +atomic_unchecked_t fscache_n_store_pages_over_limit;
57378
57379 -atomic_t fscache_n_store_vmscan_not_storing;
57380 -atomic_t fscache_n_store_vmscan_gone;
57381 -atomic_t fscache_n_store_vmscan_busy;
57382 -atomic_t fscache_n_store_vmscan_cancelled;
57383 -atomic_t fscache_n_store_vmscan_wait;
57384 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57385 +atomic_unchecked_t fscache_n_store_vmscan_gone;
57386 +atomic_unchecked_t fscache_n_store_vmscan_busy;
57387 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57388 +atomic_unchecked_t fscache_n_store_vmscan_wait;
57389
57390 -atomic_t fscache_n_marks;
57391 -atomic_t fscache_n_uncaches;
57392 +atomic_unchecked_t fscache_n_marks;
57393 +atomic_unchecked_t fscache_n_uncaches;
57394
57395 -atomic_t fscache_n_acquires;
57396 -atomic_t fscache_n_acquires_null;
57397 -atomic_t fscache_n_acquires_no_cache;
57398 -atomic_t fscache_n_acquires_ok;
57399 -atomic_t fscache_n_acquires_nobufs;
57400 -atomic_t fscache_n_acquires_oom;
57401 +atomic_unchecked_t fscache_n_acquires;
57402 +atomic_unchecked_t fscache_n_acquires_null;
57403 +atomic_unchecked_t fscache_n_acquires_no_cache;
57404 +atomic_unchecked_t fscache_n_acquires_ok;
57405 +atomic_unchecked_t fscache_n_acquires_nobufs;
57406 +atomic_unchecked_t fscache_n_acquires_oom;
57407
57408 -atomic_t fscache_n_invalidates;
57409 -atomic_t fscache_n_invalidates_run;
57410 +atomic_unchecked_t fscache_n_invalidates;
57411 +atomic_unchecked_t fscache_n_invalidates_run;
57412
57413 -atomic_t fscache_n_updates;
57414 -atomic_t fscache_n_updates_null;
57415 -atomic_t fscache_n_updates_run;
57416 +atomic_unchecked_t fscache_n_updates;
57417 +atomic_unchecked_t fscache_n_updates_null;
57418 +atomic_unchecked_t fscache_n_updates_run;
57419
57420 -atomic_t fscache_n_relinquishes;
57421 -atomic_t fscache_n_relinquishes_null;
57422 -atomic_t fscache_n_relinquishes_waitcrt;
57423 -atomic_t fscache_n_relinquishes_retire;
57424 +atomic_unchecked_t fscache_n_relinquishes;
57425 +atomic_unchecked_t fscache_n_relinquishes_null;
57426 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57427 +atomic_unchecked_t fscache_n_relinquishes_retire;
57428
57429 -atomic_t fscache_n_cookie_index;
57430 -atomic_t fscache_n_cookie_data;
57431 -atomic_t fscache_n_cookie_special;
57432 +atomic_unchecked_t fscache_n_cookie_index;
57433 +atomic_unchecked_t fscache_n_cookie_data;
57434 +atomic_unchecked_t fscache_n_cookie_special;
57435
57436 -atomic_t fscache_n_object_alloc;
57437 -atomic_t fscache_n_object_no_alloc;
57438 -atomic_t fscache_n_object_lookups;
57439 -atomic_t fscache_n_object_lookups_negative;
57440 -atomic_t fscache_n_object_lookups_positive;
57441 -atomic_t fscache_n_object_lookups_timed_out;
57442 -atomic_t fscache_n_object_created;
57443 -atomic_t fscache_n_object_avail;
57444 -atomic_t fscache_n_object_dead;
57445 +atomic_unchecked_t fscache_n_object_alloc;
57446 +atomic_unchecked_t fscache_n_object_no_alloc;
57447 +atomic_unchecked_t fscache_n_object_lookups;
57448 +atomic_unchecked_t fscache_n_object_lookups_negative;
57449 +atomic_unchecked_t fscache_n_object_lookups_positive;
57450 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
57451 +atomic_unchecked_t fscache_n_object_created;
57452 +atomic_unchecked_t fscache_n_object_avail;
57453 +atomic_unchecked_t fscache_n_object_dead;
57454
57455 -atomic_t fscache_n_checkaux_none;
57456 -atomic_t fscache_n_checkaux_okay;
57457 -atomic_t fscache_n_checkaux_update;
57458 -atomic_t fscache_n_checkaux_obsolete;
57459 +atomic_unchecked_t fscache_n_checkaux_none;
57460 +atomic_unchecked_t fscache_n_checkaux_okay;
57461 +atomic_unchecked_t fscache_n_checkaux_update;
57462 +atomic_unchecked_t fscache_n_checkaux_obsolete;
57463
57464 atomic_t fscache_n_cop_alloc_object;
57465 atomic_t fscache_n_cop_lookup_object;
57466 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
57467 seq_puts(m, "FS-Cache statistics\n");
57468
57469 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
57470 - atomic_read(&fscache_n_cookie_index),
57471 - atomic_read(&fscache_n_cookie_data),
57472 - atomic_read(&fscache_n_cookie_special));
57473 + atomic_read_unchecked(&fscache_n_cookie_index),
57474 + atomic_read_unchecked(&fscache_n_cookie_data),
57475 + atomic_read_unchecked(&fscache_n_cookie_special));
57476
57477 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
57478 - atomic_read(&fscache_n_object_alloc),
57479 - atomic_read(&fscache_n_object_no_alloc),
57480 - atomic_read(&fscache_n_object_avail),
57481 - atomic_read(&fscache_n_object_dead));
57482 + atomic_read_unchecked(&fscache_n_object_alloc),
57483 + atomic_read_unchecked(&fscache_n_object_no_alloc),
57484 + atomic_read_unchecked(&fscache_n_object_avail),
57485 + atomic_read_unchecked(&fscache_n_object_dead));
57486 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
57487 - atomic_read(&fscache_n_checkaux_none),
57488 - atomic_read(&fscache_n_checkaux_okay),
57489 - atomic_read(&fscache_n_checkaux_update),
57490 - atomic_read(&fscache_n_checkaux_obsolete));
57491 + atomic_read_unchecked(&fscache_n_checkaux_none),
57492 + atomic_read_unchecked(&fscache_n_checkaux_okay),
57493 + atomic_read_unchecked(&fscache_n_checkaux_update),
57494 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
57495
57496 seq_printf(m, "Pages : mrk=%u unc=%u\n",
57497 - atomic_read(&fscache_n_marks),
57498 - atomic_read(&fscache_n_uncaches));
57499 + atomic_read_unchecked(&fscache_n_marks),
57500 + atomic_read_unchecked(&fscache_n_uncaches));
57501
57502 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57503 " oom=%u\n",
57504 - atomic_read(&fscache_n_acquires),
57505 - atomic_read(&fscache_n_acquires_null),
57506 - atomic_read(&fscache_n_acquires_no_cache),
57507 - atomic_read(&fscache_n_acquires_ok),
57508 - atomic_read(&fscache_n_acquires_nobufs),
57509 - atomic_read(&fscache_n_acquires_oom));
57510 + atomic_read_unchecked(&fscache_n_acquires),
57511 + atomic_read_unchecked(&fscache_n_acquires_null),
57512 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57513 + atomic_read_unchecked(&fscache_n_acquires_ok),
57514 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57515 + atomic_read_unchecked(&fscache_n_acquires_oom));
57516
57517 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57518 - atomic_read(&fscache_n_object_lookups),
57519 - atomic_read(&fscache_n_object_lookups_negative),
57520 - atomic_read(&fscache_n_object_lookups_positive),
57521 - atomic_read(&fscache_n_object_created),
57522 - atomic_read(&fscache_n_object_lookups_timed_out));
57523 + atomic_read_unchecked(&fscache_n_object_lookups),
57524 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57525 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57526 + atomic_read_unchecked(&fscache_n_object_created),
57527 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57528
57529 seq_printf(m, "Invals : n=%u run=%u\n",
57530 - atomic_read(&fscache_n_invalidates),
57531 - atomic_read(&fscache_n_invalidates_run));
57532 + atomic_read_unchecked(&fscache_n_invalidates),
57533 + atomic_read_unchecked(&fscache_n_invalidates_run));
57534
57535 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57536 - atomic_read(&fscache_n_updates),
57537 - atomic_read(&fscache_n_updates_null),
57538 - atomic_read(&fscache_n_updates_run));
57539 + atomic_read_unchecked(&fscache_n_updates),
57540 + atomic_read_unchecked(&fscache_n_updates_null),
57541 + atomic_read_unchecked(&fscache_n_updates_run));
57542
57543 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57544 - atomic_read(&fscache_n_relinquishes),
57545 - atomic_read(&fscache_n_relinquishes_null),
57546 - atomic_read(&fscache_n_relinquishes_waitcrt),
57547 - atomic_read(&fscache_n_relinquishes_retire));
57548 + atomic_read_unchecked(&fscache_n_relinquishes),
57549 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57550 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57551 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57552
57553 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57554 - atomic_read(&fscache_n_attr_changed),
57555 - atomic_read(&fscache_n_attr_changed_ok),
57556 - atomic_read(&fscache_n_attr_changed_nobufs),
57557 - atomic_read(&fscache_n_attr_changed_nomem),
57558 - atomic_read(&fscache_n_attr_changed_calls));
57559 + atomic_read_unchecked(&fscache_n_attr_changed),
57560 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57561 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57562 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57563 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57564
57565 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57566 - atomic_read(&fscache_n_allocs),
57567 - atomic_read(&fscache_n_allocs_ok),
57568 - atomic_read(&fscache_n_allocs_wait),
57569 - atomic_read(&fscache_n_allocs_nobufs),
57570 - atomic_read(&fscache_n_allocs_intr));
57571 + atomic_read_unchecked(&fscache_n_allocs),
57572 + atomic_read_unchecked(&fscache_n_allocs_ok),
57573 + atomic_read_unchecked(&fscache_n_allocs_wait),
57574 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57575 + atomic_read_unchecked(&fscache_n_allocs_intr));
57576 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57577 - atomic_read(&fscache_n_alloc_ops),
57578 - atomic_read(&fscache_n_alloc_op_waits),
57579 - atomic_read(&fscache_n_allocs_object_dead));
57580 + atomic_read_unchecked(&fscache_n_alloc_ops),
57581 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57582 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57583
57584 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57585 " int=%u oom=%u\n",
57586 - atomic_read(&fscache_n_retrievals),
57587 - atomic_read(&fscache_n_retrievals_ok),
57588 - atomic_read(&fscache_n_retrievals_wait),
57589 - atomic_read(&fscache_n_retrievals_nodata),
57590 - atomic_read(&fscache_n_retrievals_nobufs),
57591 - atomic_read(&fscache_n_retrievals_intr),
57592 - atomic_read(&fscache_n_retrievals_nomem));
57593 + atomic_read_unchecked(&fscache_n_retrievals),
57594 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57595 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57596 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57597 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57598 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57599 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57600 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57601 - atomic_read(&fscache_n_retrieval_ops),
57602 - atomic_read(&fscache_n_retrieval_op_waits),
57603 - atomic_read(&fscache_n_retrievals_object_dead));
57604 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57605 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57606 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57607
57608 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57609 - atomic_read(&fscache_n_stores),
57610 - atomic_read(&fscache_n_stores_ok),
57611 - atomic_read(&fscache_n_stores_again),
57612 - atomic_read(&fscache_n_stores_nobufs),
57613 - atomic_read(&fscache_n_stores_oom));
57614 + atomic_read_unchecked(&fscache_n_stores),
57615 + atomic_read_unchecked(&fscache_n_stores_ok),
57616 + atomic_read_unchecked(&fscache_n_stores_again),
57617 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57618 + atomic_read_unchecked(&fscache_n_stores_oom));
57619 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57620 - atomic_read(&fscache_n_store_ops),
57621 - atomic_read(&fscache_n_store_calls),
57622 - atomic_read(&fscache_n_store_pages),
57623 - atomic_read(&fscache_n_store_radix_deletes),
57624 - atomic_read(&fscache_n_store_pages_over_limit));
57625 + atomic_read_unchecked(&fscache_n_store_ops),
57626 + atomic_read_unchecked(&fscache_n_store_calls),
57627 + atomic_read_unchecked(&fscache_n_store_pages),
57628 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57629 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57630
57631 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57632 - atomic_read(&fscache_n_store_vmscan_not_storing),
57633 - atomic_read(&fscache_n_store_vmscan_gone),
57634 - atomic_read(&fscache_n_store_vmscan_busy),
57635 - atomic_read(&fscache_n_store_vmscan_cancelled),
57636 - atomic_read(&fscache_n_store_vmscan_wait));
57637 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57638 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57639 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57640 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57641 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57642
57643 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57644 - atomic_read(&fscache_n_op_pend),
57645 - atomic_read(&fscache_n_op_run),
57646 - atomic_read(&fscache_n_op_enqueue),
57647 - atomic_read(&fscache_n_op_cancelled),
57648 - atomic_read(&fscache_n_op_rejected));
57649 + atomic_read_unchecked(&fscache_n_op_pend),
57650 + atomic_read_unchecked(&fscache_n_op_run),
57651 + atomic_read_unchecked(&fscache_n_op_enqueue),
57652 + atomic_read_unchecked(&fscache_n_op_cancelled),
57653 + atomic_read_unchecked(&fscache_n_op_rejected));
57654 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57655 - atomic_read(&fscache_n_op_deferred_release),
57656 - atomic_read(&fscache_n_op_release),
57657 - atomic_read(&fscache_n_op_gc));
57658 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57659 + atomic_read_unchecked(&fscache_n_op_release),
57660 + atomic_read_unchecked(&fscache_n_op_gc));
57661
57662 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57663 atomic_read(&fscache_n_cop_alloc_object),
57664 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57665 index adbfd66..4b25822 100644
57666 --- a/fs/fuse/cuse.c
57667 +++ b/fs/fuse/cuse.c
57668 @@ -603,10 +603,12 @@ static int __init cuse_init(void)
57669 INIT_LIST_HEAD(&cuse_conntbl[i]);
57670
57671 /* inherit and extend fuse_dev_operations */
57672 - cuse_channel_fops = fuse_dev_operations;
57673 - cuse_channel_fops.owner = THIS_MODULE;
57674 - cuse_channel_fops.open = cuse_channel_open;
57675 - cuse_channel_fops.release = cuse_channel_release;
57676 + pax_open_kernel();
57677 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57678 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57679 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57680 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57681 + pax_close_kernel();
57682
57683 cuse_class = class_create(THIS_MODULE, "cuse");
57684 if (IS_ERR(cuse_class))
57685 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57686 index ef74ad5..c9ac759e 100644
57687 --- a/fs/fuse/dev.c
57688 +++ b/fs/fuse/dev.c
57689 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57690 ret = 0;
57691 pipe_lock(pipe);
57692
57693 - if (!pipe->readers) {
57694 + if (!atomic_read(&pipe->readers)) {
57695 send_sig(SIGPIPE, current, 0);
57696 if (!ret)
57697 ret = -EPIPE;
57698 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57699 page_nr++;
57700 ret += buf->len;
57701
57702 - if (pipe->files)
57703 + if (atomic_read(&pipe->files))
57704 do_wakeup = 1;
57705 }
57706
57707 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57708 index b7989f2..1f72ec4 100644
57709 --- a/fs/fuse/dir.c
57710 +++ b/fs/fuse/dir.c
57711 @@ -1438,7 +1438,7 @@ static char *read_link(struct dentry *dentry)
57712 return link;
57713 }
57714
57715 -static void free_link(char *link)
57716 +static void free_link(const char *link)
57717 {
57718 if (!IS_ERR(link))
57719 free_page((unsigned long) link);
57720 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57721 index ced3257..b5c3b942 100644
57722 --- a/fs/gfs2/inode.c
57723 +++ b/fs/gfs2/inode.c
57724 @@ -1508,7 +1508,7 @@ out:
57725
57726 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57727 {
57728 - char *s = nd_get_link(nd);
57729 + const char *s = nd_get_link(nd);
57730 if (!IS_ERR(s))
57731 kfree(s);
57732 }
57733 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
57734 index 2543728..14d7bd4 100644
57735 --- a/fs/hostfs/hostfs_kern.c
57736 +++ b/fs/hostfs/hostfs_kern.c
57737 @@ -904,7 +904,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
57738
57739 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
57740 {
57741 - char *s = nd_get_link(nd);
57742 + const char *s = nd_get_link(nd);
57743 if (!IS_ERR(s))
57744 __putname(s);
57745 }
57746 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57747 index d19b30a..ef89c36 100644
57748 --- a/fs/hugetlbfs/inode.c
57749 +++ b/fs/hugetlbfs/inode.c
57750 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57751 struct mm_struct *mm = current->mm;
57752 struct vm_area_struct *vma;
57753 struct hstate *h = hstate_file(file);
57754 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57755 struct vm_unmapped_area_info info;
57756
57757 if (len & ~huge_page_mask(h))
57758 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57759 return addr;
57760 }
57761
57762 +#ifdef CONFIG_PAX_RANDMMAP
57763 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57764 +#endif
57765 +
57766 if (addr) {
57767 addr = ALIGN(addr, huge_page_size(h));
57768 vma = find_vma(mm, addr);
57769 - if (TASK_SIZE - len >= addr &&
57770 - (!vma || addr + len <= vma->vm_start))
57771 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57772 return addr;
57773 }
57774
57775 info.flags = 0;
57776 info.length = len;
57777 info.low_limit = TASK_UNMAPPED_BASE;
57778 +
57779 +#ifdef CONFIG_PAX_RANDMMAP
57780 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57781 + info.low_limit += mm->delta_mmap;
57782 +#endif
57783 +
57784 info.high_limit = TASK_SIZE;
57785 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57786 info.align_offset = 0;
57787 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57788 };
57789 MODULE_ALIAS_FS("hugetlbfs");
57790
57791 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57792 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57793
57794 static int can_do_hugetlb_shm(void)
57795 {
57796 diff --git a/fs/inode.c b/fs/inode.c
57797 index b33ba8e..3c79a47 100644
57798 --- a/fs/inode.c
57799 +++ b/fs/inode.c
57800 @@ -849,8 +849,8 @@ unsigned int get_next_ino(void)
57801
57802 #ifdef CONFIG_SMP
57803 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57804 - static atomic_t shared_last_ino;
57805 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57806 + static atomic_unchecked_t shared_last_ino;
57807 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57808
57809 res = next - LAST_INO_BATCH;
57810 }
57811 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57812 index 4a6cf28..d3a29d3 100644
57813 --- a/fs/jffs2/erase.c
57814 +++ b/fs/jffs2/erase.c
57815 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57816 struct jffs2_unknown_node marker = {
57817 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57818 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57819 - .totlen = cpu_to_je32(c->cleanmarker_size)
57820 + .totlen = cpu_to_je32(c->cleanmarker_size),
57821 + .hdr_crc = cpu_to_je32(0)
57822 };
57823
57824 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57825 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57826 index a6597d6..41b30ec 100644
57827 --- a/fs/jffs2/wbuf.c
57828 +++ b/fs/jffs2/wbuf.c
57829 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57830 {
57831 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57832 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57833 - .totlen = constant_cpu_to_je32(8)
57834 + .totlen = constant_cpu_to_je32(8),
57835 + .hdr_crc = constant_cpu_to_je32(0)
57836 };
57837
57838 /*
57839 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57840 index 6669aa2..36b033d 100644
57841 --- a/fs/jfs/super.c
57842 +++ b/fs/jfs/super.c
57843 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57844
57845 jfs_inode_cachep =
57846 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57847 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57848 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57849 init_once);
57850 if (jfs_inode_cachep == NULL)
57851 return -ENOMEM;
57852 diff --git a/fs/libfs.c b/fs/libfs.c
57853 index 3a3a9b5..3a9b074 100644
57854 --- a/fs/libfs.c
57855 +++ b/fs/libfs.c
57856 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57857
57858 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57859 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57860 + char d_name[sizeof(next->d_iname)];
57861 + const unsigned char *name;
57862 +
57863 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57864 if (!simple_positive(next)) {
57865 spin_unlock(&next->d_lock);
57866 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57867
57868 spin_unlock(&next->d_lock);
57869 spin_unlock(&dentry->d_lock);
57870 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57871 + name = next->d_name.name;
57872 + if (name == next->d_iname) {
57873 + memcpy(d_name, name, next->d_name.len);
57874 + name = d_name;
57875 + }
57876 + if (!dir_emit(ctx, name, next->d_name.len,
57877 next->d_inode->i_ino, dt_type(next->d_inode)))
57878 return 0;
57879 spin_lock(&dentry->d_lock);
57880 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57881 index acd3947..1f896e2 100644
57882 --- a/fs/lockd/clntproc.c
57883 +++ b/fs/lockd/clntproc.c
57884 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57885 /*
57886 * Cookie counter for NLM requests
57887 */
57888 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57889 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57890
57891 void nlmclnt_next_cookie(struct nlm_cookie *c)
57892 {
57893 - u32 cookie = atomic_inc_return(&nlm_cookie);
57894 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57895
57896 memcpy(c->data, &cookie, 4);
57897 c->len=4;
57898 diff --git a/fs/locks.c b/fs/locks.c
57899 index b27a300..4156d0b 100644
57900 --- a/fs/locks.c
57901 +++ b/fs/locks.c
57902 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57903 return;
57904
57905 if (filp->f_op && filp->f_op->flock) {
57906 - struct file_lock fl = {
57907 + struct file_lock flock = {
57908 .fl_pid = current->tgid,
57909 .fl_file = filp,
57910 .fl_flags = FL_FLOCK,
57911 .fl_type = F_UNLCK,
57912 .fl_end = OFFSET_MAX,
57913 };
57914 - filp->f_op->flock(filp, F_SETLKW, &fl);
57915 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57916 - fl.fl_ops->fl_release_private(&fl);
57917 + filp->f_op->flock(filp, F_SETLKW, &flock);
57918 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57919 + flock.fl_ops->fl_release_private(&flock);
57920 }
57921
57922 spin_lock(&inode->i_lock);
57923 diff --git a/fs/namei.c b/fs/namei.c
57924 index caa2805..c9d3edc 100644
57925 --- a/fs/namei.c
57926 +++ b/fs/namei.c
57927 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57928 if (ret != -EACCES)
57929 return ret;
57930
57931 +#ifdef CONFIG_GRKERNSEC
57932 + /* we'll block if we have to log due to a denied capability use */
57933 + if (mask & MAY_NOT_BLOCK)
57934 + return -ECHILD;
57935 +#endif
57936 +
57937 if (S_ISDIR(inode->i_mode)) {
57938 /* DACs are overridable for directories */
57939 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57940 - return 0;
57941 if (!(mask & MAY_WRITE))
57942 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57943 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57944 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57945 return 0;
57946 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57947 + return 0;
57948 return -EACCES;
57949 }
57950 /*
57951 + * Searching includes executable on directories, else just read.
57952 + */
57953 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57954 + if (mask == MAY_READ)
57955 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57956 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57957 + return 0;
57958 +
57959 + /*
57960 * Read/write DACs are always overridable.
57961 * Executable DACs are overridable when there is
57962 * at least one exec bit set.
57963 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57964 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57965 return 0;
57966
57967 - /*
57968 - * Searching includes executable on directories, else just read.
57969 - */
57970 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57971 - if (mask == MAY_READ)
57972 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57973 - return 0;
57974 -
57975 return -EACCES;
57976 }
57977
57978 @@ -821,7 +829,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57979 {
57980 struct dentry *dentry = link->dentry;
57981 int error;
57982 - char *s;
57983 + const char *s;
57984
57985 BUG_ON(nd->flags & LOOKUP_RCU);
57986
57987 @@ -842,6 +850,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57988 if (error)
57989 goto out_put_nd_path;
57990
57991 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57992 + dentry->d_inode, dentry, nd->path.mnt)) {
57993 + error = -EACCES;
57994 + goto out_put_nd_path;
57995 + }
57996 +
57997 nd->last_type = LAST_BIND;
57998 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57999 error = PTR_ERR(*p);
58000 @@ -1602,6 +1616,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
58001 if (res)
58002 break;
58003 res = walk_component(nd, path, LOOKUP_FOLLOW);
58004 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
58005 + res = -EACCES;
58006 put_link(nd, &link, cookie);
58007 } while (res > 0);
58008
58009 @@ -1700,7 +1716,7 @@ EXPORT_SYMBOL(full_name_hash);
58010 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
58011 {
58012 unsigned long a, b, adata, bdata, mask, hash, len;
58013 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58014 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58015
58016 hash = a = 0;
58017 len = -sizeof(unsigned long);
58018 @@ -1981,6 +1997,8 @@ static int path_lookupat(int dfd, const char *name,
58019 if (err)
58020 break;
58021 err = lookup_last(nd, &path);
58022 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
58023 + err = -EACCES;
58024 put_link(nd, &link, cookie);
58025 }
58026 }
58027 @@ -1988,6 +2006,13 @@ static int path_lookupat(int dfd, const char *name,
58028 if (!err)
58029 err = complete_walk(nd);
58030
58031 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58032 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58033 + path_put(&nd->path);
58034 + err = -ENOENT;
58035 + }
58036 + }
58037 +
58038 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58039 if (!can_lookup(nd->inode)) {
58040 path_put(&nd->path);
58041 @@ -2015,8 +2040,15 @@ static int filename_lookup(int dfd, struct filename *name,
58042 retval = path_lookupat(dfd, name->name,
58043 flags | LOOKUP_REVAL, nd);
58044
58045 - if (likely(!retval))
58046 + if (likely(!retval)) {
58047 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58048 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58049 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58050 + path_put(&nd->path);
58051 + return -ENOENT;
58052 + }
58053 + }
58054 + }
58055 return retval;
58056 }
58057
58058 @@ -2586,6 +2618,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58059 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58060 return -EPERM;
58061
58062 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58063 + return -EPERM;
58064 + if (gr_handle_rawio(inode))
58065 + return -EPERM;
58066 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58067 + return -EACCES;
58068 +
58069 return 0;
58070 }
58071
58072 @@ -2817,7 +2856,7 @@ looked_up:
58073 * cleared otherwise prior to returning.
58074 */
58075 static int lookup_open(struct nameidata *nd, struct path *path,
58076 - struct file *file,
58077 + struct path *link, struct file *file,
58078 const struct open_flags *op,
58079 bool got_write, int *opened)
58080 {
58081 @@ -2852,6 +2891,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58082 /* Negative dentry, just create the file */
58083 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58084 umode_t mode = op->mode;
58085 +
58086 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58087 + error = -EACCES;
58088 + goto out_dput;
58089 + }
58090 +
58091 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58092 + error = -EACCES;
58093 + goto out_dput;
58094 + }
58095 +
58096 if (!IS_POSIXACL(dir->d_inode))
58097 mode &= ~current_umask();
58098 /*
58099 @@ -2873,6 +2923,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58100 nd->flags & LOOKUP_EXCL);
58101 if (error)
58102 goto out_dput;
58103 + else
58104 + gr_handle_create(dentry, nd->path.mnt);
58105 }
58106 out_no_open:
58107 path->dentry = dentry;
58108 @@ -2887,7 +2939,7 @@ out_dput:
58109 /*
58110 * Handle the last step of open()
58111 */
58112 -static int do_last(struct nameidata *nd, struct path *path,
58113 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58114 struct file *file, const struct open_flags *op,
58115 int *opened, struct filename *name)
58116 {
58117 @@ -2937,6 +2989,15 @@ static int do_last(struct nameidata *nd, struct path *path,
58118 if (error)
58119 return error;
58120
58121 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58122 + error = -ENOENT;
58123 + goto out;
58124 + }
58125 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58126 + error = -EACCES;
58127 + goto out;
58128 + }
58129 +
58130 audit_inode(name, dir, LOOKUP_PARENT);
58131 error = -EISDIR;
58132 /* trailing slashes? */
58133 @@ -2956,7 +3017,7 @@ retry_lookup:
58134 */
58135 }
58136 mutex_lock(&dir->d_inode->i_mutex);
58137 - error = lookup_open(nd, path, file, op, got_write, opened);
58138 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58139 mutex_unlock(&dir->d_inode->i_mutex);
58140
58141 if (error <= 0) {
58142 @@ -2980,11 +3041,28 @@ retry_lookup:
58143 goto finish_open_created;
58144 }
58145
58146 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58147 + error = -ENOENT;
58148 + goto exit_dput;
58149 + }
58150 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58151 + error = -EACCES;
58152 + goto exit_dput;
58153 + }
58154 +
58155 /*
58156 * create/update audit record if it already exists.
58157 */
58158 - if (path->dentry->d_inode)
58159 + if (path->dentry->d_inode) {
58160 + /* only check if O_CREAT is specified, all other checks need to go
58161 + into may_open */
58162 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58163 + error = -EACCES;
58164 + goto exit_dput;
58165 + }
58166 +
58167 audit_inode(name, path->dentry, 0);
58168 + }
58169
58170 /*
58171 * If atomic_open() acquired write access it is dropped now due to
58172 @@ -3025,6 +3103,11 @@ finish_lookup:
58173 }
58174 }
58175 BUG_ON(inode != path->dentry->d_inode);
58176 + /* if we're resolving a symlink to another symlink */
58177 + if (link && gr_handle_symlink_owner(link, inode)) {
58178 + error = -EACCES;
58179 + goto out;
58180 + }
58181 return 1;
58182 }
58183
58184 @@ -3034,7 +3117,6 @@ finish_lookup:
58185 save_parent.dentry = nd->path.dentry;
58186 save_parent.mnt = mntget(path->mnt);
58187 nd->path.dentry = path->dentry;
58188 -
58189 }
58190 nd->inode = inode;
58191 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58192 @@ -3044,7 +3126,18 @@ finish_open:
58193 path_put(&save_parent);
58194 return error;
58195 }
58196 +
58197 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58198 + error = -ENOENT;
58199 + goto out;
58200 + }
58201 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58202 + error = -EACCES;
58203 + goto out;
58204 + }
58205 +
58206 audit_inode(name, nd->path.dentry, 0);
58207 +
58208 error = -EISDIR;
58209 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
58210 goto out;
58211 @@ -3207,7 +3300,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58212 if (unlikely(error))
58213 goto out;
58214
58215 - error = do_last(nd, &path, file, op, &opened, pathname);
58216 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
58217 while (unlikely(error > 0)) { /* trailing symlink */
58218 struct path link = path;
58219 void *cookie;
58220 @@ -3225,7 +3318,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58221 error = follow_link(&link, nd, &cookie);
58222 if (unlikely(error))
58223 break;
58224 - error = do_last(nd, &path, file, op, &opened, pathname);
58225 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
58226 put_link(nd, &link, cookie);
58227 }
58228 out:
58229 @@ -3325,8 +3418,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
58230 goto unlock;
58231
58232 error = -EEXIST;
58233 - if (dentry->d_inode)
58234 + if (dentry->d_inode) {
58235 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
58236 + error = -ENOENT;
58237 + }
58238 goto fail;
58239 + }
58240 /*
58241 * Special case - lookup gave negative, but... we had foo/bar/
58242 * From the vfs_mknod() POV we just have a negative dentry -
58243 @@ -3378,6 +3475,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
58244 }
58245 EXPORT_SYMBOL(user_path_create);
58246
58247 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
58248 +{
58249 + struct filename *tmp = getname(pathname);
58250 + struct dentry *res;
58251 + if (IS_ERR(tmp))
58252 + return ERR_CAST(tmp);
58253 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
58254 + if (IS_ERR(res))
58255 + putname(tmp);
58256 + else
58257 + *to = tmp;
58258 + return res;
58259 +}
58260 +
58261 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
58262 {
58263 int error = may_create(dir, dentry);
58264 @@ -3440,6 +3551,17 @@ retry:
58265
58266 if (!IS_POSIXACL(path.dentry->d_inode))
58267 mode &= ~current_umask();
58268 +
58269 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
58270 + error = -EPERM;
58271 + goto out;
58272 + }
58273 +
58274 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
58275 + error = -EACCES;
58276 + goto out;
58277 + }
58278 +
58279 error = security_path_mknod(&path, dentry, mode, dev);
58280 if (error)
58281 goto out;
58282 @@ -3456,6 +3578,8 @@ retry:
58283 break;
58284 }
58285 out:
58286 + if (!error)
58287 + gr_handle_create(dentry, path.mnt);
58288 done_path_create(&path, dentry);
58289 if (retry_estale(error, lookup_flags)) {
58290 lookup_flags |= LOOKUP_REVAL;
58291 @@ -3508,9 +3632,16 @@ retry:
58292
58293 if (!IS_POSIXACL(path.dentry->d_inode))
58294 mode &= ~current_umask();
58295 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
58296 + error = -EACCES;
58297 + goto out;
58298 + }
58299 error = security_path_mkdir(&path, dentry, mode);
58300 if (!error)
58301 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
58302 + if (!error)
58303 + gr_handle_create(dentry, path.mnt);
58304 +out:
58305 done_path_create(&path, dentry);
58306 if (retry_estale(error, lookup_flags)) {
58307 lookup_flags |= LOOKUP_REVAL;
58308 @@ -3591,6 +3722,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
58309 struct filename *name;
58310 struct dentry *dentry;
58311 struct nameidata nd;
58312 + ino_t saved_ino = 0;
58313 + dev_t saved_dev = 0;
58314 unsigned int lookup_flags = 0;
58315 retry:
58316 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58317 @@ -3623,10 +3756,21 @@ retry:
58318 error = -ENOENT;
58319 goto exit3;
58320 }
58321 +
58322 + saved_ino = dentry->d_inode->i_ino;
58323 + saved_dev = gr_get_dev_from_dentry(dentry);
58324 +
58325 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
58326 + error = -EACCES;
58327 + goto exit3;
58328 + }
58329 +
58330 error = security_path_rmdir(&nd.path, dentry);
58331 if (error)
58332 goto exit3;
58333 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
58334 + if (!error && (saved_dev || saved_ino))
58335 + gr_handle_delete(saved_ino, saved_dev);
58336 exit3:
58337 dput(dentry);
58338 exit2:
58339 @@ -3692,6 +3836,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
58340 struct dentry *dentry;
58341 struct nameidata nd;
58342 struct inode *inode = NULL;
58343 + ino_t saved_ino = 0;
58344 + dev_t saved_dev = 0;
58345 unsigned int lookup_flags = 0;
58346 retry:
58347 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58348 @@ -3718,10 +3864,22 @@ retry:
58349 if (!inode)
58350 goto slashes;
58351 ihold(inode);
58352 +
58353 + if (inode->i_nlink <= 1) {
58354 + saved_ino = inode->i_ino;
58355 + saved_dev = gr_get_dev_from_dentry(dentry);
58356 + }
58357 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
58358 + error = -EACCES;
58359 + goto exit2;
58360 + }
58361 +
58362 error = security_path_unlink(&nd.path, dentry);
58363 if (error)
58364 goto exit2;
58365 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
58366 + if (!error && (saved_ino || saved_dev))
58367 + gr_handle_delete(saved_ino, saved_dev);
58368 exit2:
58369 dput(dentry);
58370 }
58371 @@ -3799,9 +3957,17 @@ retry:
58372 if (IS_ERR(dentry))
58373 goto out_putname;
58374
58375 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
58376 + error = -EACCES;
58377 + goto out;
58378 + }
58379 +
58380 error = security_path_symlink(&path, dentry, from->name);
58381 if (!error)
58382 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
58383 + if (!error)
58384 + gr_handle_create(dentry, path.mnt);
58385 +out:
58386 done_path_create(&path, dentry);
58387 if (retry_estale(error, lookup_flags)) {
58388 lookup_flags |= LOOKUP_REVAL;
58389 @@ -3881,6 +4047,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
58390 {
58391 struct dentry *new_dentry;
58392 struct path old_path, new_path;
58393 + struct filename *to = NULL;
58394 int how = 0;
58395 int error;
58396
58397 @@ -3904,7 +4071,7 @@ retry:
58398 if (error)
58399 return error;
58400
58401 - new_dentry = user_path_create(newdfd, newname, &new_path,
58402 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
58403 (how & LOOKUP_REVAL));
58404 error = PTR_ERR(new_dentry);
58405 if (IS_ERR(new_dentry))
58406 @@ -3916,11 +4083,28 @@ retry:
58407 error = may_linkat(&old_path);
58408 if (unlikely(error))
58409 goto out_dput;
58410 +
58411 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
58412 + old_path.dentry->d_inode,
58413 + old_path.dentry->d_inode->i_mode, to)) {
58414 + error = -EACCES;
58415 + goto out_dput;
58416 + }
58417 +
58418 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
58419 + old_path.dentry, old_path.mnt, to)) {
58420 + error = -EACCES;
58421 + goto out_dput;
58422 + }
58423 +
58424 error = security_path_link(old_path.dentry, &new_path, new_dentry);
58425 if (error)
58426 goto out_dput;
58427 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
58428 + if (!error)
58429 + gr_handle_create(new_dentry, new_path.mnt);
58430 out_dput:
58431 + putname(to);
58432 done_path_create(&new_path, new_dentry);
58433 if (retry_estale(error, how)) {
58434 how |= LOOKUP_REVAL;
58435 @@ -4166,12 +4350,21 @@ retry:
58436 if (new_dentry == trap)
58437 goto exit5;
58438
58439 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
58440 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
58441 + to);
58442 + if (error)
58443 + goto exit5;
58444 +
58445 error = security_path_rename(&oldnd.path, old_dentry,
58446 &newnd.path, new_dentry);
58447 if (error)
58448 goto exit5;
58449 error = vfs_rename(old_dir->d_inode, old_dentry,
58450 new_dir->d_inode, new_dentry);
58451 + if (!error)
58452 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
58453 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
58454 exit5:
58455 dput(new_dentry);
58456 exit4:
58457 @@ -4203,6 +4396,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
58458
58459 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
58460 {
58461 + char tmpbuf[64];
58462 + const char *newlink;
58463 int len;
58464
58465 len = PTR_ERR(link);
58466 @@ -4212,7 +4407,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
58467 len = strlen(link);
58468 if (len > (unsigned) buflen)
58469 len = buflen;
58470 - if (copy_to_user(buffer, link, len))
58471 +
58472 + if (len < sizeof(tmpbuf)) {
58473 + memcpy(tmpbuf, link, len);
58474 + newlink = tmpbuf;
58475 + } else
58476 + newlink = link;
58477 +
58478 + if (copy_to_user(buffer, newlink, len))
58479 len = -EFAULT;
58480 out:
58481 return len;
58482 diff --git a/fs/namespace.c b/fs/namespace.c
58483 index da5c494..a755a54 100644
58484 --- a/fs/namespace.c
58485 +++ b/fs/namespace.c
58486 @@ -1268,6 +1268,9 @@ static int do_umount(struct mount *mnt, int flags)
58487 if (!(sb->s_flags & MS_RDONLY))
58488 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
58489 up_write(&sb->s_umount);
58490 +
58491 + gr_log_remount(mnt->mnt_devname, retval);
58492 +
58493 return retval;
58494 }
58495
58496 @@ -1286,6 +1289,9 @@ static int do_umount(struct mount *mnt, int flags)
58497 }
58498 br_write_unlock(&vfsmount_lock);
58499 namespace_unlock();
58500 +
58501 + gr_log_unmount(mnt->mnt_devname, retval);
58502 +
58503 return retval;
58504 }
58505
58506 @@ -1305,7 +1311,7 @@ static inline bool may_mount(void)
58507 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
58508 */
58509
58510 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
58511 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58512 {
58513 struct path path;
58514 struct mount *mnt;
58515 @@ -1347,7 +1353,7 @@ out:
58516 /*
58517 * The 2.0 compatible umount. No flags.
58518 */
58519 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58520 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58521 {
58522 return sys_umount(name, 0);
58523 }
58524 @@ -2358,6 +2364,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58525 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58526 MS_STRICTATIME);
58527
58528 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58529 + retval = -EPERM;
58530 + goto dput_out;
58531 + }
58532 +
58533 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58534 + retval = -EPERM;
58535 + goto dput_out;
58536 + }
58537 +
58538 if (flags & MS_REMOUNT)
58539 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58540 data_page);
58541 @@ -2372,6 +2388,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58542 dev_name, data_page);
58543 dput_out:
58544 path_put(&path);
58545 +
58546 + gr_log_mount(dev_name, dir_name, retval);
58547 +
58548 return retval;
58549 }
58550
58551 @@ -2389,7 +2408,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58552 * number incrementing at 10Ghz will take 12,427 years to wrap which
58553 * is effectively never, so we can ignore the possibility.
58554 */
58555 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58556 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58557
58558 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58559 {
58560 @@ -2404,7 +2423,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58561 kfree(new_ns);
58562 return ERR_PTR(ret);
58563 }
58564 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58565 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58566 atomic_set(&new_ns->count, 1);
58567 new_ns->root = NULL;
58568 INIT_LIST_HEAD(&new_ns->list);
58569 @@ -2418,7 +2437,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58570 * Allocate a new namespace structure and populate it with contents
58571 * copied from the namespace of the passed in task structure.
58572 */
58573 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58574 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58575 struct user_namespace *user_ns, struct fs_struct *fs)
58576 {
58577 struct mnt_namespace *new_ns;
58578 @@ -2549,8 +2568,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58579 }
58580 EXPORT_SYMBOL(mount_subtree);
58581
58582 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58583 - char __user *, type, unsigned long, flags, void __user *, data)
58584 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58585 + const char __user *, type, unsigned long, flags, void __user *, data)
58586 {
58587 int ret;
58588 char *kernel_type;
58589 @@ -2663,6 +2682,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58590 if (error)
58591 goto out2;
58592
58593 + if (gr_handle_chroot_pivot()) {
58594 + error = -EPERM;
58595 + goto out2;
58596 + }
58597 +
58598 get_fs_root(current->fs, &root);
58599 old_mp = lock_mount(&old);
58600 error = PTR_ERR(old_mp);
58601 @@ -2932,7 +2956,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58602 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
58603 return -EPERM;
58604
58605 - if (fs->users != 1)
58606 + if (atomic_read(&fs->users) != 1)
58607 return -EINVAL;
58608
58609 get_mnt_ns(mnt_ns);
58610 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58611 index f4ccfe6..a5cf064 100644
58612 --- a/fs/nfs/callback_xdr.c
58613 +++ b/fs/nfs/callback_xdr.c
58614 @@ -51,7 +51,7 @@ struct callback_op {
58615 callback_decode_arg_t decode_args;
58616 callback_encode_res_t encode_res;
58617 long res_maxsize;
58618 -};
58619 +} __do_const;
58620
58621 static struct callback_op callback_ops[];
58622
58623 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58624 index eda8879..bfc6837 100644
58625 --- a/fs/nfs/inode.c
58626 +++ b/fs/nfs/inode.c
58627 @@ -1150,16 +1150,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58628 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58629 }
58630
58631 -static atomic_long_t nfs_attr_generation_counter;
58632 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58633
58634 static unsigned long nfs_read_attr_generation_counter(void)
58635 {
58636 - return atomic_long_read(&nfs_attr_generation_counter);
58637 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58638 }
58639
58640 unsigned long nfs_inc_attr_generation_counter(void)
58641 {
58642 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58643 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58644 }
58645
58646 void nfs_fattr_init(struct nfs_fattr *fattr)
58647 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
58648 index cc14cbb..6021bb6 100644
58649 --- a/fs/nfs/nfs4state.c
58650 +++ b/fs/nfs/nfs4state.c
58651 @@ -1881,10 +1881,15 @@ again:
58652 nfs4_root_machine_cred(clp);
58653 goto again;
58654 }
58655 - if (i > 2)
58656 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX)
58657 break;
58658 case -NFS4ERR_CLID_INUSE:
58659 case -NFS4ERR_WRONGSEC:
58660 + /* No point in retrying if we already used RPC_AUTH_UNIX */
58661 + if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) {
58662 + status = -EPERM;
58663 + break;
58664 + }
58665 clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_UNIX);
58666 if (IS_ERR(clnt)) {
58667 status = PTR_ERR(clnt);
58668 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58669 index 419572f..5414a23 100644
58670 --- a/fs/nfsd/nfs4proc.c
58671 +++ b/fs/nfsd/nfs4proc.c
58672 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58673 nfsd4op_rsize op_rsize_bop;
58674 stateid_getter op_get_currentstateid;
58675 stateid_setter op_set_currentstateid;
58676 -};
58677 +} __do_const;
58678
58679 static struct nfsd4_operation nfsd4_ops[];
58680
58681 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58682 index d9454fe..855c9d1 100644
58683 --- a/fs/nfsd/nfs4xdr.c
58684 +++ b/fs/nfsd/nfs4xdr.c
58685 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58686
58687 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58688
58689 -static nfsd4_dec nfsd4_dec_ops[] = {
58690 +static const nfsd4_dec nfsd4_dec_ops[] = {
58691 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58692 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58693 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58694 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58695 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58696 };
58697
58698 -static nfsd4_dec nfsd41_dec_ops[] = {
58699 +static const nfsd4_dec nfsd41_dec_ops[] = {
58700 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58701 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58702 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58703 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58704 };
58705
58706 struct nfsd4_minorversion_ops {
58707 - nfsd4_dec *decoders;
58708 + const nfsd4_dec *decoders;
58709 int nops;
58710 };
58711
58712 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58713 index 9186c7c..3fdde3e 100644
58714 --- a/fs/nfsd/nfscache.c
58715 +++ b/fs/nfsd/nfscache.c
58716 @@ -540,14 +540,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58717 {
58718 struct svc_cacherep *rp = rqstp->rq_cacherep;
58719 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58720 - int len;
58721 + long len;
58722 size_t bufsize = 0;
58723
58724 if (!rp)
58725 return;
58726
58727 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58728 - len >>= 2;
58729 + if (statp) {
58730 + len = (char*)statp - (char*)resv->iov_base;
58731 + len = resv->iov_len - len;
58732 + len >>= 2;
58733 + }
58734
58735 /* Don't cache excessive amounts of data and XDR failures */
58736 if (!statp || len > (256 >> 2)) {
58737 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58738 index c827acb..b253b77 100644
58739 --- a/fs/nfsd/vfs.c
58740 +++ b/fs/nfsd/vfs.c
58741 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58742 } else {
58743 oldfs = get_fs();
58744 set_fs(KERNEL_DS);
58745 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58746 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58747 set_fs(oldfs);
58748 }
58749
58750 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58751
58752 /* Write the data. */
58753 oldfs = get_fs(); set_fs(KERNEL_DS);
58754 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58755 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58756 set_fs(oldfs);
58757 if (host_err < 0)
58758 goto out_nfserr;
58759 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58760 */
58761
58762 oldfs = get_fs(); set_fs(KERNEL_DS);
58763 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58764 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58765 set_fs(oldfs);
58766
58767 if (host_err < 0)
58768 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58769 index fea6bd5..8ee9d81 100644
58770 --- a/fs/nls/nls_base.c
58771 +++ b/fs/nls/nls_base.c
58772 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58773
58774 int register_nls(struct nls_table * nls)
58775 {
58776 - struct nls_table ** tmp = &tables;
58777 + struct nls_table *tmp = tables;
58778
58779 if (nls->next)
58780 return -EBUSY;
58781
58782 spin_lock(&nls_lock);
58783 - while (*tmp) {
58784 - if (nls == *tmp) {
58785 + while (tmp) {
58786 + if (nls == tmp) {
58787 spin_unlock(&nls_lock);
58788 return -EBUSY;
58789 }
58790 - tmp = &(*tmp)->next;
58791 + tmp = tmp->next;
58792 }
58793 - nls->next = tables;
58794 + pax_open_kernel();
58795 + *(struct nls_table **)&nls->next = tables;
58796 + pax_close_kernel();
58797 tables = nls;
58798 spin_unlock(&nls_lock);
58799 return 0;
58800 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58801
58802 int unregister_nls(struct nls_table * nls)
58803 {
58804 - struct nls_table ** tmp = &tables;
58805 + struct nls_table * const * tmp = &tables;
58806
58807 spin_lock(&nls_lock);
58808 while (*tmp) {
58809 if (nls == *tmp) {
58810 - *tmp = nls->next;
58811 + pax_open_kernel();
58812 + *(struct nls_table **)tmp = nls->next;
58813 + pax_close_kernel();
58814 spin_unlock(&nls_lock);
58815 return 0;
58816 }
58817 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58818 index 7424929..35f6be5 100644
58819 --- a/fs/nls/nls_euc-jp.c
58820 +++ b/fs/nls/nls_euc-jp.c
58821 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58822 p_nls = load_nls("cp932");
58823
58824 if (p_nls) {
58825 - table.charset2upper = p_nls->charset2upper;
58826 - table.charset2lower = p_nls->charset2lower;
58827 + pax_open_kernel();
58828 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58829 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58830 + pax_close_kernel();
58831 return register_nls(&table);
58832 }
58833
58834 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58835 index e7bc1d7..06bd4bb 100644
58836 --- a/fs/nls/nls_koi8-ru.c
58837 +++ b/fs/nls/nls_koi8-ru.c
58838 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58839 p_nls = load_nls("koi8-u");
58840
58841 if (p_nls) {
58842 - table.charset2upper = p_nls->charset2upper;
58843 - table.charset2lower = p_nls->charset2lower;
58844 + pax_open_kernel();
58845 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58846 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58847 + pax_close_kernel();
58848 return register_nls(&table);
58849 }
58850
58851 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58852 index e44cb64..4807084 100644
58853 --- a/fs/notify/fanotify/fanotify_user.c
58854 +++ b/fs/notify/fanotify/fanotify_user.c
58855 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58856
58857 fd = fanotify_event_metadata.fd;
58858 ret = -EFAULT;
58859 - if (copy_to_user(buf, &fanotify_event_metadata,
58860 - fanotify_event_metadata.event_len))
58861 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58862 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58863 goto out_close_fd;
58864
58865 ret = prepare_for_access_response(group, event, fd);
58866 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58867 index 7b51b05..5ea5ef6 100644
58868 --- a/fs/notify/notification.c
58869 +++ b/fs/notify/notification.c
58870 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58871 * get set to 0 so it will never get 'freed'
58872 */
58873 static struct fsnotify_event *q_overflow_event;
58874 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58875 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58876
58877 /**
58878 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58879 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58880 */
58881 u32 fsnotify_get_cookie(void)
58882 {
58883 - return atomic_inc_return(&fsnotify_sync_cookie);
58884 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58885 }
58886 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58887
58888 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58889 index 9e38daf..5727cae 100644
58890 --- a/fs/ntfs/dir.c
58891 +++ b/fs/ntfs/dir.c
58892 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58893 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58894 ~(s64)(ndir->itype.index.block_size - 1)));
58895 /* Bounds checks. */
58896 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58897 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58898 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58899 "inode 0x%lx or driver bug.", vdir->i_ino);
58900 goto err_out;
58901 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58902 index ea4ba9d..1e13d34 100644
58903 --- a/fs/ntfs/file.c
58904 +++ b/fs/ntfs/file.c
58905 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58906 char *addr;
58907 size_t total = 0;
58908 unsigned len;
58909 - int left;
58910 + unsigned left;
58911
58912 do {
58913 len = PAGE_CACHE_SIZE - ofs;
58914 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58915 index 82650d5..db37dcf 100644
58916 --- a/fs/ntfs/super.c
58917 +++ b/fs/ntfs/super.c
58918 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58919 if (!silent)
58920 ntfs_error(sb, "Primary boot sector is invalid.");
58921 } else if (!silent)
58922 - ntfs_error(sb, read_err_str, "primary");
58923 + ntfs_error(sb, read_err_str, "%s", "primary");
58924 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58925 if (bh_primary)
58926 brelse(bh_primary);
58927 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58928 goto hotfix_primary_boot_sector;
58929 brelse(bh_backup);
58930 } else if (!silent)
58931 - ntfs_error(sb, read_err_str, "backup");
58932 + ntfs_error(sb, read_err_str, "%s", "backup");
58933 /* Try to read NT3.51- backup boot sector. */
58934 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58935 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58936 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58937 "sector.");
58938 brelse(bh_backup);
58939 } else if (!silent)
58940 - ntfs_error(sb, read_err_str, "backup");
58941 + ntfs_error(sb, read_err_str, "%s", "backup");
58942 /* We failed. Cleanup and return. */
58943 if (bh_primary)
58944 brelse(bh_primary);
58945 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58946 index cd5496b..26a1055 100644
58947 --- a/fs/ocfs2/localalloc.c
58948 +++ b/fs/ocfs2/localalloc.c
58949 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58950 goto bail;
58951 }
58952
58953 - atomic_inc(&osb->alloc_stats.moves);
58954 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58955
58956 bail:
58957 if (handle)
58958 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58959 index 3a90347..c40bef8 100644
58960 --- a/fs/ocfs2/ocfs2.h
58961 +++ b/fs/ocfs2/ocfs2.h
58962 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58963
58964 struct ocfs2_alloc_stats
58965 {
58966 - atomic_t moves;
58967 - atomic_t local_data;
58968 - atomic_t bitmap_data;
58969 - atomic_t bg_allocs;
58970 - atomic_t bg_extends;
58971 + atomic_unchecked_t moves;
58972 + atomic_unchecked_t local_data;
58973 + atomic_unchecked_t bitmap_data;
58974 + atomic_unchecked_t bg_allocs;
58975 + atomic_unchecked_t bg_extends;
58976 };
58977
58978 enum ocfs2_local_alloc_state
58979 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58980 index 5397c07..54afc55 100644
58981 --- a/fs/ocfs2/suballoc.c
58982 +++ b/fs/ocfs2/suballoc.c
58983 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58984 mlog_errno(status);
58985 goto bail;
58986 }
58987 - atomic_inc(&osb->alloc_stats.bg_extends);
58988 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58989
58990 /* You should never ask for this much metadata */
58991 BUG_ON(bits_wanted >
58992 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58993 mlog_errno(status);
58994 goto bail;
58995 }
58996 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58997 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58998
58999 *suballoc_loc = res.sr_bg_blkno;
59000 *suballoc_bit_start = res.sr_bit_offset;
59001 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
59002 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
59003 res->sr_bits);
59004
59005 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59006 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59007
59008 BUG_ON(res->sr_bits != 1);
59009
59010 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
59011 mlog_errno(status);
59012 goto bail;
59013 }
59014 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59015 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59016
59017 BUG_ON(res.sr_bits != 1);
59018
59019 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59020 cluster_start,
59021 num_clusters);
59022 if (!status)
59023 - atomic_inc(&osb->alloc_stats.local_data);
59024 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
59025 } else {
59026 if (min_clusters > (osb->bitmap_cpg - 1)) {
59027 /* The only paths asking for contiguousness
59028 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59029 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
59030 res.sr_bg_blkno,
59031 res.sr_bit_offset);
59032 - atomic_inc(&osb->alloc_stats.bitmap_data);
59033 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
59034 *num_clusters = res.sr_bits;
59035 }
59036 }
59037 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59038 index d4e81e4..ad89f5f 100644
59039 --- a/fs/ocfs2/super.c
59040 +++ b/fs/ocfs2/super.c
59041 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59042 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59043 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59044 "Stats",
59045 - atomic_read(&osb->alloc_stats.bitmap_data),
59046 - atomic_read(&osb->alloc_stats.local_data),
59047 - atomic_read(&osb->alloc_stats.bg_allocs),
59048 - atomic_read(&osb->alloc_stats.moves),
59049 - atomic_read(&osb->alloc_stats.bg_extends));
59050 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59051 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59052 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59053 + atomic_read_unchecked(&osb->alloc_stats.moves),
59054 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59055
59056 out += snprintf(buf + out, len - out,
59057 "%10s => State: %u Descriptor: %llu Size: %u bits "
59058 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59059 spin_lock_init(&osb->osb_xattr_lock);
59060 ocfs2_init_steal_slots(osb);
59061
59062 - atomic_set(&osb->alloc_stats.moves, 0);
59063 - atomic_set(&osb->alloc_stats.local_data, 0);
59064 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59065 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59066 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59067 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59068 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59069 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59070 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59071 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59072
59073 /* Copy the blockcheck stats from the superblock probe */
59074 osb->osb_ecc_stats = *stats;
59075 diff --git a/fs/open.c b/fs/open.c
59076 index d420331..2dbb3fd 100644
59077 --- a/fs/open.c
59078 +++ b/fs/open.c
59079 @@ -32,6 +32,8 @@
59080 #include <linux/dnotify.h>
59081 #include <linux/compat.h>
59082
59083 +#define CREATE_TRACE_POINTS
59084 +#include <trace/events/fs.h>
59085 #include "internal.h"
59086
59087 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59088 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59089 error = locks_verify_truncate(inode, NULL, length);
59090 if (!error)
59091 error = security_path_truncate(path);
59092 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59093 + error = -EACCES;
59094 if (!error)
59095 error = do_truncate(path->dentry, length, 0, NULL);
59096
59097 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59098 error = locks_verify_truncate(inode, f.file, length);
59099 if (!error)
59100 error = security_path_truncate(&f.file->f_path);
59101 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59102 + error = -EACCES;
59103 if (!error)
59104 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59105 sb_end_write(inode->i_sb);
59106 @@ -360,6 +366,9 @@ retry:
59107 if (__mnt_is_readonly(path.mnt))
59108 res = -EROFS;
59109
59110 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59111 + res = -EACCES;
59112 +
59113 out_path_release:
59114 path_put(&path);
59115 if (retry_estale(res, lookup_flags)) {
59116 @@ -391,6 +400,8 @@ retry:
59117 if (error)
59118 goto dput_and_out;
59119
59120 + gr_log_chdir(path.dentry, path.mnt);
59121 +
59122 set_fs_pwd(current->fs, &path);
59123
59124 dput_and_out:
59125 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59126 goto out_putf;
59127
59128 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59129 +
59130 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59131 + error = -EPERM;
59132 +
59133 + if (!error)
59134 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59135 +
59136 if (!error)
59137 set_fs_pwd(current->fs, &f.file->f_path);
59138 out_putf:
59139 @@ -449,7 +467,13 @@ retry:
59140 if (error)
59141 goto dput_and_out;
59142
59143 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59144 + goto dput_and_out;
59145 +
59146 set_fs_root(current->fs, &path);
59147 +
59148 + gr_handle_chroot_chdir(&path);
59149 +
59150 error = 0;
59151 dput_and_out:
59152 path_put(&path);
59153 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59154 if (error)
59155 return error;
59156 mutex_lock(&inode->i_mutex);
59157 +
59158 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59159 + error = -EACCES;
59160 + goto out_unlock;
59161 + }
59162 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59163 + error = -EACCES;
59164 + goto out_unlock;
59165 + }
59166 +
59167 error = security_path_chmod(path, mode);
59168 if (error)
59169 goto out_unlock;
59170 @@ -530,6 +564,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59171 uid = make_kuid(current_user_ns(), user);
59172 gid = make_kgid(current_user_ns(), group);
59173
59174 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59175 + return -EACCES;
59176 +
59177 newattrs.ia_valid = ATTR_CTIME;
59178 if (user != (uid_t) -1) {
59179 if (!uid_valid(uid))
59180 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
59181 } else {
59182 fsnotify_open(f);
59183 fd_install(fd, f);
59184 + trace_do_sys_open(tmp->name, flags, mode);
59185 }
59186 }
59187 putname(tmp);
59188 diff --git a/fs/pipe.c b/fs/pipe.c
59189 index d2c45e1..009fe1c 100644
59190 --- a/fs/pipe.c
59191 +++ b/fs/pipe.c
59192 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
59193
59194 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
59195 {
59196 - if (pipe->files)
59197 + if (atomic_read(&pipe->files))
59198 mutex_lock_nested(&pipe->mutex, subclass);
59199 }
59200
59201 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
59202
59203 void pipe_unlock(struct pipe_inode_info *pipe)
59204 {
59205 - if (pipe->files)
59206 + if (atomic_read(&pipe->files))
59207 mutex_unlock(&pipe->mutex);
59208 }
59209 EXPORT_SYMBOL(pipe_unlock);
59210 @@ -449,9 +449,9 @@ redo:
59211 }
59212 if (bufs) /* More to do? */
59213 continue;
59214 - if (!pipe->writers)
59215 + if (!atomic_read(&pipe->writers))
59216 break;
59217 - if (!pipe->waiting_writers) {
59218 + if (!atomic_read(&pipe->waiting_writers)) {
59219 /* syscall merging: Usually we must not sleep
59220 * if O_NONBLOCK is set, or if we got some data.
59221 * But if a writer sleeps in kernel space, then
59222 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
59223 ret = 0;
59224 __pipe_lock(pipe);
59225
59226 - if (!pipe->readers) {
59227 + if (!atomic_read(&pipe->readers)) {
59228 send_sig(SIGPIPE, current, 0);
59229 ret = -EPIPE;
59230 goto out;
59231 @@ -562,7 +562,7 @@ redo1:
59232 for (;;) {
59233 int bufs;
59234
59235 - if (!pipe->readers) {
59236 + if (!atomic_read(&pipe->readers)) {
59237 send_sig(SIGPIPE, current, 0);
59238 if (!ret)
59239 ret = -EPIPE;
59240 @@ -653,9 +653,9 @@ redo2:
59241 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59242 do_wakeup = 0;
59243 }
59244 - pipe->waiting_writers++;
59245 + atomic_inc(&pipe->waiting_writers);
59246 pipe_wait(pipe);
59247 - pipe->waiting_writers--;
59248 + atomic_dec(&pipe->waiting_writers);
59249 }
59250 out:
59251 __pipe_unlock(pipe);
59252 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59253 mask = 0;
59254 if (filp->f_mode & FMODE_READ) {
59255 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
59256 - if (!pipe->writers && filp->f_version != pipe->w_counter)
59257 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
59258 mask |= POLLHUP;
59259 }
59260
59261 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59262 * Most Unices do not set POLLERR for FIFOs but on Linux they
59263 * behave exactly like pipes for poll().
59264 */
59265 - if (!pipe->readers)
59266 + if (!atomic_read(&pipe->readers))
59267 mask |= POLLERR;
59268 }
59269
59270 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
59271
59272 __pipe_lock(pipe);
59273 if (file->f_mode & FMODE_READ)
59274 - pipe->readers--;
59275 + atomic_dec(&pipe->readers);
59276 if (file->f_mode & FMODE_WRITE)
59277 - pipe->writers--;
59278 + atomic_dec(&pipe->writers);
59279
59280 - if (pipe->readers || pipe->writers) {
59281 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
59282 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
59283 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59284 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
59285 }
59286 spin_lock(&inode->i_lock);
59287 - if (!--pipe->files) {
59288 + if (atomic_dec_and_test(&pipe->files)) {
59289 inode->i_pipe = NULL;
59290 kill = 1;
59291 }
59292 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
59293 kfree(pipe);
59294 }
59295
59296 -static struct vfsmount *pipe_mnt __read_mostly;
59297 +struct vfsmount *pipe_mnt __read_mostly;
59298
59299 /*
59300 * pipefs_dname() is called from d_path().
59301 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
59302 goto fail_iput;
59303
59304 inode->i_pipe = pipe;
59305 - pipe->files = 2;
59306 - pipe->readers = pipe->writers = 1;
59307 + atomic_set(&pipe->files, 2);
59308 + atomic_set(&pipe->readers, 1);
59309 + atomic_set(&pipe->writers, 1);
59310 inode->i_fop = &pipefifo_fops;
59311
59312 /*
59313 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
59314 spin_lock(&inode->i_lock);
59315 if (inode->i_pipe) {
59316 pipe = inode->i_pipe;
59317 - pipe->files++;
59318 + atomic_inc(&pipe->files);
59319 spin_unlock(&inode->i_lock);
59320 } else {
59321 spin_unlock(&inode->i_lock);
59322 pipe = alloc_pipe_info();
59323 if (!pipe)
59324 return -ENOMEM;
59325 - pipe->files = 1;
59326 + atomic_set(&pipe->files, 1);
59327 spin_lock(&inode->i_lock);
59328 if (unlikely(inode->i_pipe)) {
59329 - inode->i_pipe->files++;
59330 + atomic_inc(&inode->i_pipe->files);
59331 spin_unlock(&inode->i_lock);
59332 free_pipe_info(pipe);
59333 pipe = inode->i_pipe;
59334 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
59335 * opened, even when there is no process writing the FIFO.
59336 */
59337 pipe->r_counter++;
59338 - if (pipe->readers++ == 0)
59339 + if (atomic_inc_return(&pipe->readers) == 1)
59340 wake_up_partner(pipe);
59341
59342 - if (!is_pipe && !pipe->writers) {
59343 + if (!is_pipe && !atomic_read(&pipe->writers)) {
59344 if ((filp->f_flags & O_NONBLOCK)) {
59345 /* suppress POLLHUP until we have
59346 * seen a writer */
59347 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
59348 * errno=ENXIO when there is no process reading the FIFO.
59349 */
59350 ret = -ENXIO;
59351 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
59352 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
59353 goto err;
59354
59355 pipe->w_counter++;
59356 - if (!pipe->writers++)
59357 + if (atomic_inc_return(&pipe->writers) == 1)
59358 wake_up_partner(pipe);
59359
59360 - if (!is_pipe && !pipe->readers) {
59361 + if (!is_pipe && !atomic_read(&pipe->readers)) {
59362 if (wait_for_partner(pipe, &pipe->r_counter))
59363 goto err_wr;
59364 }
59365 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
59366 * the process can at least talk to itself.
59367 */
59368
59369 - pipe->readers++;
59370 - pipe->writers++;
59371 + atomic_inc(&pipe->readers);
59372 + atomic_inc(&pipe->writers);
59373 pipe->r_counter++;
59374 pipe->w_counter++;
59375 - if (pipe->readers == 1 || pipe->writers == 1)
59376 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
59377 wake_up_partner(pipe);
59378 break;
59379
59380 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
59381 return 0;
59382
59383 err_rd:
59384 - if (!--pipe->readers)
59385 + if (atomic_dec_and_test(&pipe->readers))
59386 wake_up_interruptible(&pipe->wait);
59387 ret = -ERESTARTSYS;
59388 goto err;
59389
59390 err_wr:
59391 - if (!--pipe->writers)
59392 + if (atomic_dec_and_test(&pipe->writers))
59393 wake_up_interruptible(&pipe->wait);
59394 ret = -ERESTARTSYS;
59395 goto err;
59396
59397 err:
59398 spin_lock(&inode->i_lock);
59399 - if (!--pipe->files) {
59400 + if (atomic_dec_and_test(&pipe->files)) {
59401 inode->i_pipe = NULL;
59402 kill = 1;
59403 }
59404 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
59405 index 15af622..0e9f4467 100644
59406 --- a/fs/proc/Kconfig
59407 +++ b/fs/proc/Kconfig
59408 @@ -30,12 +30,12 @@ config PROC_FS
59409
59410 config PROC_KCORE
59411 bool "/proc/kcore support" if !ARM
59412 - depends on PROC_FS && MMU
59413 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
59414
59415 config PROC_VMCORE
59416 bool "/proc/vmcore support"
59417 - depends on PROC_FS && CRASH_DUMP
59418 - default y
59419 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
59420 + default n
59421 help
59422 Exports the dump image of crashed kernel in ELF format.
59423
59424 @@ -59,8 +59,8 @@ config PROC_SYSCTL
59425 limited in memory.
59426
59427 config PROC_PAGE_MONITOR
59428 - default y
59429 - depends on PROC_FS && MMU
59430 + default n
59431 + depends on PROC_FS && MMU && !GRKERNSEC
59432 bool "Enable /proc page monitoring" if EXPERT
59433 help
59434 Various /proc files exist to monitor process memory utilization:
59435 diff --git a/fs/proc/array.c b/fs/proc/array.c
59436 index cbd0f1b..adec3f0 100644
59437 --- a/fs/proc/array.c
59438 +++ b/fs/proc/array.c
59439 @@ -60,6 +60,7 @@
59440 #include <linux/tty.h>
59441 #include <linux/string.h>
59442 #include <linux/mman.h>
59443 +#include <linux/grsecurity.h>
59444 #include <linux/proc_fs.h>
59445 #include <linux/ioport.h>
59446 #include <linux/uaccess.h>
59447 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
59448 seq_putc(m, '\n');
59449 }
59450
59451 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59452 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
59453 +{
59454 + if (p->mm)
59455 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
59456 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
59457 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
59458 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
59459 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
59460 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
59461 + else
59462 + seq_printf(m, "PaX:\t-----\n");
59463 +}
59464 +#endif
59465 +
59466 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59467 struct pid *pid, struct task_struct *task)
59468 {
59469 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59470 task_cpus_allowed(m, task);
59471 cpuset_task_status_allowed(m, task);
59472 task_context_switch_counts(m, task);
59473 +
59474 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59475 + task_pax(m, task);
59476 +#endif
59477 +
59478 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
59479 + task_grsec_rbac(m, task);
59480 +#endif
59481 +
59482 return 0;
59483 }
59484
59485 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59486 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59487 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59488 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59489 +#endif
59490 +
59491 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59492 struct pid *pid, struct task_struct *task, int whole)
59493 {
59494 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59495 char tcomm[sizeof(task->comm)];
59496 unsigned long flags;
59497
59498 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59499 + if (current->exec_id != m->exec_id) {
59500 + gr_log_badprocpid("stat");
59501 + return 0;
59502 + }
59503 +#endif
59504 +
59505 state = *get_task_state(task);
59506 vsize = eip = esp = 0;
59507 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59508 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59509 gtime = task_gtime(task);
59510 }
59511
59512 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59513 + if (PAX_RAND_FLAGS(mm)) {
59514 + eip = 0;
59515 + esp = 0;
59516 + wchan = 0;
59517 + }
59518 +#endif
59519 +#ifdef CONFIG_GRKERNSEC_HIDESYM
59520 + wchan = 0;
59521 + eip =0;
59522 + esp =0;
59523 +#endif
59524 +
59525 /* scale priority and nice values from timeslices to -20..20 */
59526 /* to make it look like a "normal" Unix priority/nice value */
59527 priority = task_prio(task);
59528 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59529 seq_put_decimal_ull(m, ' ', vsize);
59530 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59531 seq_put_decimal_ull(m, ' ', rsslim);
59532 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59533 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59534 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59535 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59536 +#else
59537 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59538 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59539 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59540 +#endif
59541 seq_put_decimal_ull(m, ' ', esp);
59542 seq_put_decimal_ull(m, ' ', eip);
59543 /* The signal information here is obsolete.
59544 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59545 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59546 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59547
59548 - if (mm && permitted) {
59549 + if (mm && permitted
59550 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59551 + && !PAX_RAND_FLAGS(mm)
59552 +#endif
59553 + ) {
59554 seq_put_decimal_ull(m, ' ', mm->start_data);
59555 seq_put_decimal_ull(m, ' ', mm->end_data);
59556 seq_put_decimal_ull(m, ' ', mm->start_brk);
59557 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59558 struct pid *pid, struct task_struct *task)
59559 {
59560 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59561 - struct mm_struct *mm = get_task_mm(task);
59562 + struct mm_struct *mm;
59563
59564 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59565 + if (current->exec_id != m->exec_id) {
59566 + gr_log_badprocpid("statm");
59567 + return 0;
59568 + }
59569 +#endif
59570 + mm = get_task_mm(task);
59571 if (mm) {
59572 size = task_statm(mm, &shared, &text, &data, &resident);
59573 mmput(mm);
59574 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59575 return 0;
59576 }
59577
59578 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59579 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59580 +{
59581 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59582 +}
59583 +#endif
59584 +
59585 #ifdef CONFIG_CHECKPOINT_RESTORE
59586 static struct pid *
59587 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59588 diff --git a/fs/proc/base.c b/fs/proc/base.c
59589 index 1485e38..8ad4236 100644
59590 --- a/fs/proc/base.c
59591 +++ b/fs/proc/base.c
59592 @@ -113,6 +113,14 @@ struct pid_entry {
59593 union proc_op op;
59594 };
59595
59596 +struct getdents_callback {
59597 + struct linux_dirent __user * current_dir;
59598 + struct linux_dirent __user * previous;
59599 + struct file * file;
59600 + int count;
59601 + int error;
59602 +};
59603 +
59604 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59605 .name = (NAME), \
59606 .len = sizeof(NAME) - 1, \
59607 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59608 if (!mm->arg_end)
59609 goto out_mm; /* Shh! No looking before we're done */
59610
59611 + if (gr_acl_handle_procpidmem(task))
59612 + goto out_mm;
59613 +
59614 len = mm->arg_end - mm->arg_start;
59615
59616 if (len > PAGE_SIZE)
59617 @@ -237,12 +248,28 @@ out:
59618 return res;
59619 }
59620
59621 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59622 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59623 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59624 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59625 +#endif
59626 +
59627 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59628 {
59629 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59630 int res = PTR_ERR(mm);
59631 if (mm && !IS_ERR(mm)) {
59632 unsigned int nwords = 0;
59633 +
59634 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59635 + /* allow if we're currently ptracing this task */
59636 + if (PAX_RAND_FLAGS(mm) &&
59637 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59638 + mmput(mm);
59639 + return 0;
59640 + }
59641 +#endif
59642 +
59643 do {
59644 nwords += 2;
59645 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59646 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59647 }
59648
59649
59650 -#ifdef CONFIG_KALLSYMS
59651 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59652 /*
59653 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59654 * Returns the resolved symbol. If that fails, simply return the address.
59655 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59656 mutex_unlock(&task->signal->cred_guard_mutex);
59657 }
59658
59659 -#ifdef CONFIG_STACKTRACE
59660 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59661
59662 #define MAX_STACK_TRACE_DEPTH 64
59663
59664 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59665 return count;
59666 }
59667
59668 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59669 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59670 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59671 {
59672 long nr;
59673 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59674 /************************************************************************/
59675
59676 /* permission checks */
59677 -static int proc_fd_access_allowed(struct inode *inode)
59678 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59679 {
59680 struct task_struct *task;
59681 int allowed = 0;
59682 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59683 */
59684 task = get_proc_task(inode);
59685 if (task) {
59686 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59687 + if (log)
59688 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59689 + else
59690 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59691 put_task_struct(task);
59692 }
59693 return allowed;
59694 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59695 struct task_struct *task,
59696 int hide_pid_min)
59697 {
59698 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59699 + return false;
59700 +
59701 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59702 + rcu_read_lock();
59703 + {
59704 + const struct cred *tmpcred = current_cred();
59705 + const struct cred *cred = __task_cred(task);
59706 +
59707 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59708 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59709 + || in_group_p(grsec_proc_gid)
59710 +#endif
59711 + ) {
59712 + rcu_read_unlock();
59713 + return true;
59714 + }
59715 + }
59716 + rcu_read_unlock();
59717 +
59718 + if (!pid->hide_pid)
59719 + return false;
59720 +#endif
59721 +
59722 if (pid->hide_pid < hide_pid_min)
59723 return true;
59724 if (in_group_p(pid->pid_gid))
59725 return true;
59726 +
59727 return ptrace_may_access(task, PTRACE_MODE_READ);
59728 }
59729
59730 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59731 put_task_struct(task);
59732
59733 if (!has_perms) {
59734 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59735 + {
59736 +#else
59737 if (pid->hide_pid == 2) {
59738 +#endif
59739 /*
59740 * Let's make getdents(), stat(), and open()
59741 * consistent with each other. If a process
59742 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59743 if (!task)
59744 return -ESRCH;
59745
59746 + if (gr_acl_handle_procpidmem(task)) {
59747 + put_task_struct(task);
59748 + return -EPERM;
59749 + }
59750 +
59751 mm = mm_access(task, mode);
59752 put_task_struct(task);
59753
59754 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59755
59756 file->private_data = mm;
59757
59758 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59759 + file->f_version = current->exec_id;
59760 +#endif
59761 +
59762 return 0;
59763 }
59764
59765 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59766 ssize_t copied;
59767 char *page;
59768
59769 +#ifdef CONFIG_GRKERNSEC
59770 + if (write)
59771 + return -EPERM;
59772 +#endif
59773 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59774 + if (file->f_version != current->exec_id) {
59775 + gr_log_badprocpid("mem");
59776 + return 0;
59777 + }
59778 +#endif
59779 +
59780 if (!mm)
59781 return 0;
59782
59783 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59784 goto free;
59785
59786 while (count > 0) {
59787 - int this_len = min_t(int, count, PAGE_SIZE);
59788 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59789
59790 if (write && copy_from_user(page, buf, this_len)) {
59791 copied = -EFAULT;
59792 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59793 if (!mm)
59794 return 0;
59795
59796 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59797 + if (file->f_version != current->exec_id) {
59798 + gr_log_badprocpid("environ");
59799 + return 0;
59800 + }
59801 +#endif
59802 +
59803 page = (char *)__get_free_page(GFP_TEMPORARY);
59804 if (!page)
59805 return -ENOMEM;
59806 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59807 goto free;
59808 while (count > 0) {
59809 size_t this_len, max_len;
59810 - int retval;
59811 + ssize_t retval;
59812
59813 if (src >= (mm->env_end - mm->env_start))
59814 break;
59815 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59816 int error = -EACCES;
59817
59818 /* Are we allowed to snoop on the tasks file descriptors? */
59819 - if (!proc_fd_access_allowed(inode))
59820 + if (!proc_fd_access_allowed(inode, 0))
59821 goto out;
59822
59823 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59824 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59825 struct path path;
59826
59827 /* Are we allowed to snoop on the tasks file descriptors? */
59828 - if (!proc_fd_access_allowed(inode))
59829 - goto out;
59830 + /* logging this is needed for learning on chromium to work properly,
59831 + but we don't want to flood the logs from 'ps' which does a readlink
59832 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59833 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59834 + */
59835 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59836 + if (!proc_fd_access_allowed(inode,0))
59837 + goto out;
59838 + } else {
59839 + if (!proc_fd_access_allowed(inode,1))
59840 + goto out;
59841 + }
59842
59843 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59844 if (error)
59845 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59846 rcu_read_lock();
59847 cred = __task_cred(task);
59848 inode->i_uid = cred->euid;
59849 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59850 + inode->i_gid = grsec_proc_gid;
59851 +#else
59852 inode->i_gid = cred->egid;
59853 +#endif
59854 rcu_read_unlock();
59855 }
59856 security_task_to_inode(task, inode);
59857 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59858 return -ENOENT;
59859 }
59860 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59861 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59862 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59863 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59864 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59865 +#endif
59866 task_dumpable(task)) {
59867 cred = __task_cred(task);
59868 stat->uid = cred->euid;
59869 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59870 + stat->gid = grsec_proc_gid;
59871 +#else
59872 stat->gid = cred->egid;
59873 +#endif
59874 }
59875 }
59876 rcu_read_unlock();
59877 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59878
59879 if (task) {
59880 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59881 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59882 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59883 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59884 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59885 +#endif
59886 task_dumpable(task)) {
59887 rcu_read_lock();
59888 cred = __task_cred(task);
59889 inode->i_uid = cred->euid;
59890 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59891 + inode->i_gid = grsec_proc_gid;
59892 +#else
59893 inode->i_gid = cred->egid;
59894 +#endif
59895 rcu_read_unlock();
59896 } else {
59897 inode->i_uid = GLOBAL_ROOT_UID;
59898 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59899 if (!task)
59900 goto out_no_task;
59901
59902 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59903 + goto out;
59904 +
59905 /*
59906 * Yes, it does not scale. And it should not. Don't add
59907 * new entries into /proc/<tgid>/ without very good reasons.
59908 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59909 if (!task)
59910 return -ENOENT;
59911
59912 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59913 + goto out;
59914 +
59915 if (!dir_emit_dots(file, ctx))
59916 goto out;
59917
59918 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59919 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59920 #endif
59921 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59922 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59923 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59924 INF("syscall", S_IRUGO, proc_pid_syscall),
59925 #endif
59926 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59927 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59928 #ifdef CONFIG_SECURITY
59929 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59930 #endif
59931 -#ifdef CONFIG_KALLSYMS
59932 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59933 INF("wchan", S_IRUGO, proc_pid_wchan),
59934 #endif
59935 -#ifdef CONFIG_STACKTRACE
59936 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59937 ONE("stack", S_IRUGO, proc_pid_stack),
59938 #endif
59939 #ifdef CONFIG_SCHEDSTATS
59940 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59941 #ifdef CONFIG_HARDWALL
59942 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59943 #endif
59944 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59945 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59946 +#endif
59947 #ifdef CONFIG_USER_NS
59948 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59949 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59950 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59951 if (!inode)
59952 goto out;
59953
59954 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59955 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59956 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59957 + inode->i_gid = grsec_proc_gid;
59958 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59959 +#else
59960 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59961 +#endif
59962 inode->i_op = &proc_tgid_base_inode_operations;
59963 inode->i_fop = &proc_tgid_base_operations;
59964 inode->i_flags|=S_IMMUTABLE;
59965 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59966 if (!task)
59967 goto out;
59968
59969 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59970 + goto out_put_task;
59971 +
59972 result = proc_pid_instantiate(dir, dentry, task, NULL);
59973 +out_put_task:
59974 put_task_struct(task);
59975 out:
59976 return ERR_PTR(result);
59977 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59978 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59979 #endif
59980 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59981 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59982 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59983 INF("syscall", S_IRUGO, proc_pid_syscall),
59984 #endif
59985 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59986 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59987 #ifdef CONFIG_SECURITY
59988 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59989 #endif
59990 -#ifdef CONFIG_KALLSYMS
59991 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59992 INF("wchan", S_IRUGO, proc_pid_wchan),
59993 #endif
59994 -#ifdef CONFIG_STACKTRACE
59995 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59996 ONE("stack", S_IRUGO, proc_pid_stack),
59997 #endif
59998 #ifdef CONFIG_SCHEDSTATS
59999 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
60000 index 82676e3..5f8518a 100644
60001 --- a/fs/proc/cmdline.c
60002 +++ b/fs/proc/cmdline.c
60003 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
60004
60005 static int __init proc_cmdline_init(void)
60006 {
60007 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60008 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
60009 +#else
60010 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
60011 +#endif
60012 return 0;
60013 }
60014 module_init(proc_cmdline_init);
60015 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
60016 index b143471..bb105e5 100644
60017 --- a/fs/proc/devices.c
60018 +++ b/fs/proc/devices.c
60019 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
60020
60021 static int __init proc_devices_init(void)
60022 {
60023 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60024 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
60025 +#else
60026 proc_create("devices", 0, NULL, &proc_devinfo_operations);
60027 +#endif
60028 return 0;
60029 }
60030 module_init(proc_devices_init);
60031 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
60032 index 985ea88..d118a0a 100644
60033 --- a/fs/proc/fd.c
60034 +++ b/fs/proc/fd.c
60035 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
60036 if (!task)
60037 return -ENOENT;
60038
60039 - files = get_files_struct(task);
60040 + if (!gr_acl_handle_procpidmem(task))
60041 + files = get_files_struct(task);
60042 put_task_struct(task);
60043
60044 if (files) {
60045 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60046 */
60047 int proc_fd_permission(struct inode *inode, int mask)
60048 {
60049 + struct task_struct *task;
60050 int rv = generic_permission(inode, mask);
60051 - if (rv == 0)
60052 - return 0;
60053 +
60054 if (task_tgid(current) == proc_pid(inode))
60055 rv = 0;
60056 +
60057 + task = get_proc_task(inode);
60058 + if (task == NULL)
60059 + return rv;
60060 +
60061 + if (gr_acl_handle_procpidmem(task))
60062 + rv = -EACCES;
60063 +
60064 + put_task_struct(task);
60065 +
60066 return rv;
60067 }
60068
60069 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60070 index 8eaa1ba..cc6ff42 100644
60071 --- a/fs/proc/inode.c
60072 +++ b/fs/proc/inode.c
60073 @@ -23,11 +23,17 @@
60074 #include <linux/slab.h>
60075 #include <linux/mount.h>
60076 #include <linux/magic.h>
60077 +#include <linux/grsecurity.h>
60078
60079 #include <asm/uaccess.h>
60080
60081 #include "internal.h"
60082
60083 +#ifdef CONFIG_PROC_SYSCTL
60084 +extern const struct inode_operations proc_sys_inode_operations;
60085 +extern const struct inode_operations proc_sys_dir_operations;
60086 +#endif
60087 +
60088 static void proc_evict_inode(struct inode *inode)
60089 {
60090 struct proc_dir_entry *de;
60091 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60092 ns = PROC_I(inode)->ns.ns;
60093 if (ns_ops && ns)
60094 ns_ops->put(ns);
60095 +
60096 +#ifdef CONFIG_PROC_SYSCTL
60097 + if (inode->i_op == &proc_sys_inode_operations ||
60098 + inode->i_op == &proc_sys_dir_operations)
60099 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60100 +#endif
60101 +
60102 }
60103
60104 static struct kmem_cache * proc_inode_cachep;
60105 @@ -405,7 +418,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60106 if (de->mode) {
60107 inode->i_mode = de->mode;
60108 inode->i_uid = de->uid;
60109 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60110 + inode->i_gid = grsec_proc_gid;
60111 +#else
60112 inode->i_gid = de->gid;
60113 +#endif
60114 }
60115 if (de->size)
60116 inode->i_size = de->size;
60117 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60118 index 651d09a..60c73ae 100644
60119 --- a/fs/proc/internal.h
60120 +++ b/fs/proc/internal.h
60121 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60122 struct pid *, struct task_struct *);
60123 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60124 struct pid *, struct task_struct *);
60125 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60126 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60127 +#endif
60128
60129 /*
60130 * base.c
60131 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60132 index 06ea155..9a798c7 100644
60133 --- a/fs/proc/kcore.c
60134 +++ b/fs/proc/kcore.c
60135 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60136 * the addresses in the elf_phdr on our list.
60137 */
60138 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60139 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60140 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60141 + if (tsz > buflen)
60142 tsz = buflen;
60143 -
60144 +
60145 while (buflen) {
60146 struct kcore_list *m;
60147
60148 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60149 kfree(elf_buf);
60150 } else {
60151 if (kern_addr_valid(start)) {
60152 - unsigned long n;
60153 + char *elf_buf;
60154 + mm_segment_t oldfs;
60155
60156 - n = copy_to_user(buffer, (char *)start, tsz);
60157 - /*
60158 - * We cannot distinguish between fault on source
60159 - * and fault on destination. When this happens
60160 - * we clear too and hope it will trigger the
60161 - * EFAULT again.
60162 - */
60163 - if (n) {
60164 - if (clear_user(buffer + tsz - n,
60165 - n))
60166 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60167 + if (!elf_buf)
60168 + return -ENOMEM;
60169 + oldfs = get_fs();
60170 + set_fs(KERNEL_DS);
60171 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
60172 + set_fs(oldfs);
60173 + if (copy_to_user(buffer, elf_buf, tsz)) {
60174 + kfree(elf_buf);
60175 return -EFAULT;
60176 + }
60177 }
60178 + set_fs(oldfs);
60179 + kfree(elf_buf);
60180 } else {
60181 if (clear_user(buffer, tsz))
60182 return -EFAULT;
60183 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60184
60185 static int open_kcore(struct inode *inode, struct file *filp)
60186 {
60187 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
60188 + return -EPERM;
60189 +#endif
60190 if (!capable(CAP_SYS_RAWIO))
60191 return -EPERM;
60192 if (kcore_need_update)
60193 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
60194 index 59d85d6..ac6fc05 100644
60195 --- a/fs/proc/meminfo.c
60196 +++ b/fs/proc/meminfo.c
60197 @@ -153,7 +153,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
60198 vmi.used >> 10,
60199 vmi.largest_chunk >> 10
60200 #ifdef CONFIG_MEMORY_FAILURE
60201 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60202 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60203 #endif
60204 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
60205 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
60206 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
60207 index ccfd99b..1b7e255 100644
60208 --- a/fs/proc/nommu.c
60209 +++ b/fs/proc/nommu.c
60210 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
60211 if (len < 1)
60212 len = 1;
60213 seq_printf(m, "%*c", len, ' ');
60214 - seq_path(m, &file->f_path, "");
60215 + seq_path(m, &file->f_path, "\n\\");
60216 }
60217
60218 seq_putc(m, '\n');
60219 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
60220 index 4677bb7..408e936 100644
60221 --- a/fs/proc/proc_net.c
60222 +++ b/fs/proc/proc_net.c
60223 @@ -23,6 +23,7 @@
60224 #include <linux/nsproxy.h>
60225 #include <net/net_namespace.h>
60226 #include <linux/seq_file.h>
60227 +#include <linux/grsecurity.h>
60228
60229 #include "internal.h"
60230
60231 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
60232 struct task_struct *task;
60233 struct nsproxy *ns;
60234 struct net *net = NULL;
60235 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60236 + const struct cred *cred = current_cred();
60237 +#endif
60238 +
60239 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60240 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
60241 + return net;
60242 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60243 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
60244 + return net;
60245 +#endif
60246
60247 rcu_read_lock();
60248 task = pid_task(proc_pid(dir), PIDTYPE_PID);
60249 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
60250 index 7129046..6914844 100644
60251 --- a/fs/proc/proc_sysctl.c
60252 +++ b/fs/proc/proc_sysctl.c
60253 @@ -11,13 +11,21 @@
60254 #include <linux/namei.h>
60255 #include <linux/mm.h>
60256 #include <linux/module.h>
60257 +#include <linux/nsproxy.h>
60258 +#ifdef CONFIG_GRKERNSEC
60259 +#include <net/net_namespace.h>
60260 +#endif
60261 #include "internal.h"
60262
60263 +extern int gr_handle_chroot_sysctl(const int op);
60264 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
60265 + const int op);
60266 +
60267 static const struct dentry_operations proc_sys_dentry_operations;
60268 static const struct file_operations proc_sys_file_operations;
60269 -static const struct inode_operations proc_sys_inode_operations;
60270 +const struct inode_operations proc_sys_inode_operations;
60271 static const struct file_operations proc_sys_dir_file_operations;
60272 -static const struct inode_operations proc_sys_dir_operations;
60273 +const struct inode_operations proc_sys_dir_operations;
60274
60275 void proc_sys_poll_notify(struct ctl_table_poll *poll)
60276 {
60277 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
60278
60279 err = NULL;
60280 d_set_d_op(dentry, &proc_sys_dentry_operations);
60281 +
60282 + gr_handle_proc_create(dentry, inode);
60283 +
60284 d_add(dentry, inode);
60285
60286 out:
60287 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60288 struct inode *inode = file_inode(filp);
60289 struct ctl_table_header *head = grab_header(inode);
60290 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
60291 + int op = write ? MAY_WRITE : MAY_READ;
60292 ssize_t error;
60293 size_t res;
60294
60295 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60296 * and won't be until we finish.
60297 */
60298 error = -EPERM;
60299 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
60300 + if (sysctl_perm(head, table, op))
60301 goto out;
60302
60303 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
60304 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60305 if (!table->proc_handler)
60306 goto out;
60307
60308 +#ifdef CONFIG_GRKERNSEC
60309 + error = -EPERM;
60310 + if (gr_handle_chroot_sysctl(op))
60311 + goto out;
60312 + dget(filp->f_path.dentry);
60313 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
60314 + dput(filp->f_path.dentry);
60315 + goto out;
60316 + }
60317 + dput(filp->f_path.dentry);
60318 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
60319 + goto out;
60320 + if (write) {
60321 + if (current->nsproxy->net_ns != table->extra2) {
60322 + if (!capable(CAP_SYS_ADMIN))
60323 + goto out;
60324 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
60325 + goto out;
60326 + }
60327 +#endif
60328 +
60329 /* careful: calling conventions are nasty here */
60330 res = count;
60331 error = table->proc_handler(table, write, buf, &res, ppos);
60332 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
60333 return false;
60334 } else {
60335 d_set_d_op(child, &proc_sys_dentry_operations);
60336 +
60337 + gr_handle_proc_create(child, inode);
60338 +
60339 d_add(child, inode);
60340 }
60341 } else {
60342 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
60343 if ((*pos)++ < ctx->pos)
60344 return true;
60345
60346 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
60347 + return 0;
60348 +
60349 if (unlikely(S_ISLNK(table->mode)))
60350 res = proc_sys_link_fill_cache(file, ctx, head, table);
60351 else
60352 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
60353 if (IS_ERR(head))
60354 return PTR_ERR(head);
60355
60356 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
60357 + return -ENOENT;
60358 +
60359 generic_fillattr(inode, stat);
60360 if (table)
60361 stat->mode = (stat->mode & S_IFMT) | table->mode;
60362 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
60363 .llseek = generic_file_llseek,
60364 };
60365
60366 -static const struct inode_operations proc_sys_inode_operations = {
60367 +const struct inode_operations proc_sys_inode_operations = {
60368 .permission = proc_sys_permission,
60369 .setattr = proc_sys_setattr,
60370 .getattr = proc_sys_getattr,
60371 };
60372
60373 -static const struct inode_operations proc_sys_dir_operations = {
60374 +const struct inode_operations proc_sys_dir_operations = {
60375 .lookup = proc_sys_lookup,
60376 .permission = proc_sys_permission,
60377 .setattr = proc_sys_setattr,
60378 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
60379 static struct ctl_dir *new_dir(struct ctl_table_set *set,
60380 const char *name, int namelen)
60381 {
60382 - struct ctl_table *table;
60383 + ctl_table_no_const *table;
60384 struct ctl_dir *new;
60385 struct ctl_node *node;
60386 char *new_name;
60387 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
60388 return NULL;
60389
60390 node = (struct ctl_node *)(new + 1);
60391 - table = (struct ctl_table *)(node + 1);
60392 + table = (ctl_table_no_const *)(node + 1);
60393 new_name = (char *)(table + 2);
60394 memcpy(new_name, name, namelen);
60395 new_name[namelen] = '\0';
60396 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
60397 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
60398 struct ctl_table_root *link_root)
60399 {
60400 - struct ctl_table *link_table, *entry, *link;
60401 + ctl_table_no_const *link_table, *link;
60402 + struct ctl_table *entry;
60403 struct ctl_table_header *links;
60404 struct ctl_node *node;
60405 char *link_name;
60406 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
60407 return NULL;
60408
60409 node = (struct ctl_node *)(links + 1);
60410 - link_table = (struct ctl_table *)(node + nr_entries);
60411 + link_table = (ctl_table_no_const *)(node + nr_entries);
60412 link_name = (char *)&link_table[nr_entries + 1];
60413
60414 for (link = link_table, entry = table; entry->procname; link++, entry++) {
60415 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60416 struct ctl_table_header ***subheader, struct ctl_table_set *set,
60417 struct ctl_table *table)
60418 {
60419 - struct ctl_table *ctl_table_arg = NULL;
60420 - struct ctl_table *entry, *files;
60421 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
60422 + struct ctl_table *entry;
60423 int nr_files = 0;
60424 int nr_dirs = 0;
60425 int err = -ENOMEM;
60426 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60427 nr_files++;
60428 }
60429
60430 - files = table;
60431 /* If there are mixed files and directories we need a new table */
60432 if (nr_dirs && nr_files) {
60433 - struct ctl_table *new;
60434 + ctl_table_no_const *new;
60435 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
60436 GFP_KERNEL);
60437 if (!files)
60438 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60439 /* Register everything except a directory full of subdirectories */
60440 if (nr_files || !nr_dirs) {
60441 struct ctl_table_header *header;
60442 - header = __register_sysctl_table(set, path, files);
60443 + header = __register_sysctl_table(set, path, files ? files : table);
60444 if (!header) {
60445 kfree(ctl_table_arg);
60446 goto out;
60447 diff --git a/fs/proc/root.c b/fs/proc/root.c
60448 index 87dbcbe..55e1b4d 100644
60449 --- a/fs/proc/root.c
60450 +++ b/fs/proc/root.c
60451 @@ -186,7 +186,15 @@ void __init proc_root_init(void)
60452 #ifdef CONFIG_PROC_DEVICETREE
60453 proc_device_tree_init();
60454 #endif
60455 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60456 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60457 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
60458 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60459 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
60460 +#endif
60461 +#else
60462 proc_mkdir("bus", NULL);
60463 +#endif
60464 proc_sys_init();
60465 }
60466
60467 diff --git a/fs/proc/self.c b/fs/proc/self.c
60468 index 6b6a993..807cccc 100644
60469 --- a/fs/proc/self.c
60470 +++ b/fs/proc/self.c
60471 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
60472 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
60473 void *cookie)
60474 {
60475 - char *s = nd_get_link(nd);
60476 + const char *s = nd_get_link(nd);
60477 if (!IS_ERR(s))
60478 kfree(s);
60479 }
60480 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
60481 index 390bdab..83c1e8a 100644
60482 --- a/fs/proc/task_mmu.c
60483 +++ b/fs/proc/task_mmu.c
60484 @@ -12,12 +12,19 @@
60485 #include <linux/swap.h>
60486 #include <linux/swapops.h>
60487 #include <linux/mmu_notifier.h>
60488 +#include <linux/grsecurity.h>
60489
60490 #include <asm/elf.h>
60491 #include <asm/uaccess.h>
60492 #include <asm/tlbflush.h>
60493 #include "internal.h"
60494
60495 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60496 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60497 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60498 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60499 +#endif
60500 +
60501 void task_mem(struct seq_file *m, struct mm_struct *mm)
60502 {
60503 unsigned long data, text, lib, swap;
60504 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60505 "VmExe:\t%8lu kB\n"
60506 "VmLib:\t%8lu kB\n"
60507 "VmPTE:\t%8lu kB\n"
60508 - "VmSwap:\t%8lu kB\n",
60509 - hiwater_vm << (PAGE_SHIFT-10),
60510 + "VmSwap:\t%8lu kB\n"
60511 +
60512 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60513 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
60514 +#endif
60515 +
60516 + ,hiwater_vm << (PAGE_SHIFT-10),
60517 total_vm << (PAGE_SHIFT-10),
60518 mm->locked_vm << (PAGE_SHIFT-10),
60519 mm->pinned_vm << (PAGE_SHIFT-10),
60520 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60521 data << (PAGE_SHIFT-10),
60522 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
60523 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
60524 - swap << (PAGE_SHIFT-10));
60525 + swap << (PAGE_SHIFT-10)
60526 +
60527 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60528 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60529 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60530 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60531 +#else
60532 + , mm->context.user_cs_base
60533 + , mm->context.user_cs_limit
60534 +#endif
60535 +#endif
60536 +
60537 + );
60538 }
60539
60540 unsigned long task_vsize(struct mm_struct *mm)
60541 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60542 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60543 }
60544
60545 - /* We don't show the stack guard page in /proc/maps */
60546 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60547 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60548 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60549 +#else
60550 start = vma->vm_start;
60551 - if (stack_guard_page_start(vma, start))
60552 - start += PAGE_SIZE;
60553 end = vma->vm_end;
60554 - if (stack_guard_page_end(vma, end))
60555 - end -= PAGE_SIZE;
60556 +#endif
60557
60558 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60559 start,
60560 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60561 flags & VM_WRITE ? 'w' : '-',
60562 flags & VM_EXEC ? 'x' : '-',
60563 flags & VM_MAYSHARE ? 's' : 'p',
60564 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60565 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60566 +#else
60567 pgoff,
60568 +#endif
60569 MAJOR(dev), MINOR(dev), ino, &len);
60570
60571 /*
60572 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60573 */
60574 if (file) {
60575 pad_len_spaces(m, len);
60576 - seq_path(m, &file->f_path, "\n");
60577 + seq_path(m, &file->f_path, "\n\\");
60578 goto done;
60579 }
60580
60581 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60582 * Thread stack in /proc/PID/task/TID/maps or
60583 * the main process stack.
60584 */
60585 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60586 - vma->vm_end >= mm->start_stack)) {
60587 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60588 + (vma->vm_start <= mm->start_stack &&
60589 + vma->vm_end >= mm->start_stack)) {
60590 name = "[stack]";
60591 } else {
60592 /* Thread stack in /proc/PID/maps */
60593 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60594 struct proc_maps_private *priv = m->private;
60595 struct task_struct *task = priv->task;
60596
60597 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60598 + if (current->exec_id != m->exec_id) {
60599 + gr_log_badprocpid("maps");
60600 + return 0;
60601 + }
60602 +#endif
60603 +
60604 show_map_vma(m, vma, is_pid);
60605
60606 if (m->count < m->size) /* vma is copied successfully */
60607 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60608 .private = &mss,
60609 };
60610
60611 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60612 + if (current->exec_id != m->exec_id) {
60613 + gr_log_badprocpid("smaps");
60614 + return 0;
60615 + }
60616 +#endif
60617 memset(&mss, 0, sizeof mss);
60618 - mss.vma = vma;
60619 - /* mmap_sem is held in m_start */
60620 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60621 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60622 -
60623 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60624 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60625 +#endif
60626 + mss.vma = vma;
60627 + /* mmap_sem is held in m_start */
60628 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60629 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60630 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60631 + }
60632 +#endif
60633 show_map_vma(m, vma, is_pid);
60634
60635 seq_printf(m,
60636 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60637 "KernelPageSize: %8lu kB\n"
60638 "MMUPageSize: %8lu kB\n"
60639 "Locked: %8lu kB\n",
60640 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60641 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60642 +#else
60643 (vma->vm_end - vma->vm_start) >> 10,
60644 +#endif
60645 mss.resident >> 10,
60646 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60647 mss.shared_clean >> 10,
60648 @@ -1390,6 +1441,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60649 int n;
60650 char buffer[50];
60651
60652 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60653 + if (current->exec_id != m->exec_id) {
60654 + gr_log_badprocpid("numa_maps");
60655 + return 0;
60656 + }
60657 +#endif
60658 +
60659 if (!mm)
60660 return 0;
60661
60662 @@ -1409,11 +1467,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60663 if (n < 0)
60664 return n;
60665
60666 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60667 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60668 +#else
60669 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60670 +#endif
60671
60672 if (file) {
60673 seq_printf(m, " file=");
60674 - seq_path(m, &file->f_path, "\n\t= ");
60675 + seq_path(m, &file->f_path, "\n\t\\= ");
60676 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60677 seq_printf(m, " heap");
60678 } else {
60679 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60680 index 56123a6..5a2f6ec 100644
60681 --- a/fs/proc/task_nommu.c
60682 +++ b/fs/proc/task_nommu.c
60683 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60684 else
60685 bytes += kobjsize(mm);
60686
60687 - if (current->fs && current->fs->users > 1)
60688 + if (current->fs && atomic_read(&current->fs->users) > 1)
60689 sbytes += kobjsize(current->fs);
60690 else
60691 bytes += kobjsize(current->fs);
60692 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60693
60694 if (file) {
60695 pad_len_spaces(m, len);
60696 - seq_path(m, &file->f_path, "");
60697 + seq_path(m, &file->f_path, "\n\\");
60698 } else if (mm) {
60699 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60700
60701 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60702 index 9100d69..f1f9fc9 100644
60703 --- a/fs/proc/vmcore.c
60704 +++ b/fs/proc/vmcore.c
60705 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60706 nr_bytes = count;
60707
60708 /* If pfn is not ram, return zeros for sparse dump files */
60709 - if (pfn_is_ram(pfn) == 0)
60710 - memset(buf, 0, nr_bytes);
60711 - else {
60712 + if (pfn_is_ram(pfn) == 0) {
60713 + if (userbuf) {
60714 + if (clear_user((char __force_user *)buf, nr_bytes))
60715 + return -EFAULT;
60716 + } else
60717 + memset(buf, 0, nr_bytes);
60718 + } else {
60719 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60720 offset, userbuf);
60721 if (tmp < 0)
60722 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
60723 if (*fpos < m->offset + m->size) {
60724 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60725 start = m->paddr + *fpos - m->offset;
60726 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
60727 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
60728 if (tmp < 0)
60729 return tmp;
60730 buflen -= tsz;
60731 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60732 index b00fcc9..e0c6381 100644
60733 --- a/fs/qnx6/qnx6.h
60734 +++ b/fs/qnx6/qnx6.h
60735 @@ -74,7 +74,7 @@ enum {
60736 BYTESEX_BE,
60737 };
60738
60739 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60740 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60741 {
60742 if (sbi->s_bytesex == BYTESEX_LE)
60743 return le64_to_cpu((__force __le64)n);
60744 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60745 return (__force __fs64)cpu_to_be64(n);
60746 }
60747
60748 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60749 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60750 {
60751 if (sbi->s_bytesex == BYTESEX_LE)
60752 return le32_to_cpu((__force __le32)n);
60753 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60754 index 16e8abb..2dcf914 100644
60755 --- a/fs/quota/netlink.c
60756 +++ b/fs/quota/netlink.c
60757 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60758 void quota_send_warning(struct kqid qid, dev_t dev,
60759 const char warntype)
60760 {
60761 - static atomic_t seq;
60762 + static atomic_unchecked_t seq;
60763 struct sk_buff *skb;
60764 void *msg_head;
60765 int ret;
60766 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60767 "VFS: Not enough memory to send quota warning.\n");
60768 return;
60769 }
60770 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60771 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60772 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60773 if (!msg_head) {
60774 printk(KERN_ERR
60775 diff --git a/fs/read_write.c b/fs/read_write.c
60776 index e3cd280..a378473 100644
60777 --- a/fs/read_write.c
60778 +++ b/fs/read_write.c
60779 @@ -438,7 +438,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60780
60781 old_fs = get_fs();
60782 set_fs(get_ds());
60783 - p = (__force const char __user *)buf;
60784 + p = (const char __force_user *)buf;
60785 if (count > MAX_RW_COUNT)
60786 count = MAX_RW_COUNT;
60787 if (file->f_op->write)
60788 diff --git a/fs/readdir.c b/fs/readdir.c
60789 index 93d71e5..6a14be8 100644
60790 --- a/fs/readdir.c
60791 +++ b/fs/readdir.c
60792 @@ -17,6 +17,7 @@
60793 #include <linux/security.h>
60794 #include <linux/syscalls.h>
60795 #include <linux/unistd.h>
60796 +#include <linux/namei.h>
60797
60798 #include <asm/uaccess.h>
60799
60800 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60801 struct readdir_callback {
60802 struct dir_context ctx;
60803 struct old_linux_dirent __user * dirent;
60804 + struct file * file;
60805 int result;
60806 };
60807
60808 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60809 buf->result = -EOVERFLOW;
60810 return -EOVERFLOW;
60811 }
60812 +
60813 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60814 + return 0;
60815 +
60816 buf->result++;
60817 dirent = buf->dirent;
60818 if (!access_ok(VERIFY_WRITE, dirent,
60819 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60820 if (!f.file)
60821 return -EBADF;
60822
60823 + buf.file = f.file;
60824 error = iterate_dir(f.file, &buf.ctx);
60825 if (buf.result)
60826 error = buf.result;
60827 @@ -142,6 +149,7 @@ struct getdents_callback {
60828 struct dir_context ctx;
60829 struct linux_dirent __user * current_dir;
60830 struct linux_dirent __user * previous;
60831 + struct file * file;
60832 int count;
60833 int error;
60834 };
60835 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60836 buf->error = -EOVERFLOW;
60837 return -EOVERFLOW;
60838 }
60839 +
60840 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60841 + return 0;
60842 +
60843 dirent = buf->previous;
60844 if (dirent) {
60845 if (__put_user(offset, &dirent->d_off))
60846 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60847 if (!f.file)
60848 return -EBADF;
60849
60850 + buf.file = f.file;
60851 error = iterate_dir(f.file, &buf.ctx);
60852 if (error >= 0)
60853 error = buf.error;
60854 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60855 struct dir_context ctx;
60856 struct linux_dirent64 __user * current_dir;
60857 struct linux_dirent64 __user * previous;
60858 + struct file *file;
60859 int count;
60860 int error;
60861 };
60862 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60863 buf->error = -EINVAL; /* only used if we fail.. */
60864 if (reclen > buf->count)
60865 return -EINVAL;
60866 +
60867 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60868 + return 0;
60869 +
60870 dirent = buf->previous;
60871 if (dirent) {
60872 if (__put_user(offset, &dirent->d_off))
60873 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60874 if (!f.file)
60875 return -EBADF;
60876
60877 + buf.file = f.file;
60878 error = iterate_dir(f.file, &buf.ctx);
60879 if (error >= 0)
60880 error = buf.error;
60881 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60882 index 2b7882b..1c5ef48 100644
60883 --- a/fs/reiserfs/do_balan.c
60884 +++ b/fs/reiserfs/do_balan.c
60885 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60886 return;
60887 }
60888
60889 - atomic_inc(&(fs_generation(tb->tb_sb)));
60890 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60891 do_balance_starts(tb);
60892
60893 /* balance leaf returns 0 except if combining L R and S into
60894 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60895 index a958444..42b2323 100644
60896 --- a/fs/reiserfs/procfs.c
60897 +++ b/fs/reiserfs/procfs.c
60898 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60899 "SMALL_TAILS " : "NO_TAILS ",
60900 replay_only(sb) ? "REPLAY_ONLY " : "",
60901 convert_reiserfs(sb) ? "CONV " : "",
60902 - atomic_read(&r->s_generation_counter),
60903 + atomic_read_unchecked(&r->s_generation_counter),
60904 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60905 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60906 SF(s_good_search_by_key_reada), SF(s_bmaps),
60907 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60908 index f8adaee..0eeeeca 100644
60909 --- a/fs/reiserfs/reiserfs.h
60910 +++ b/fs/reiserfs/reiserfs.h
60911 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60912 /* Comment? -Hans */
60913 wait_queue_head_t s_wait;
60914 /* To be obsoleted soon by per buffer seals.. -Hans */
60915 - atomic_t s_generation_counter; // increased by one every time the
60916 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60917 // tree gets re-balanced
60918 unsigned long s_properties; /* File system properties. Currently holds
60919 on-disk FS format */
60920 @@ -1982,7 +1982,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60921 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60922
60923 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60924 -#define get_generation(s) atomic_read (&fs_generation(s))
60925 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60926 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60927 #define __fs_changed(gen,s) (gen != get_generation (s))
60928 #define fs_changed(gen,s) \
60929 diff --git a/fs/select.c b/fs/select.c
60930 index dfd5cb1..1754d57 100644
60931 --- a/fs/select.c
60932 +++ b/fs/select.c
60933 @@ -20,6 +20,7 @@
60934 #include <linux/export.h>
60935 #include <linux/slab.h>
60936 #include <linux/poll.h>
60937 +#include <linux/security.h>
60938 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60939 #include <linux/file.h>
60940 #include <linux/fdtable.h>
60941 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60942 struct poll_list *walk = head;
60943 unsigned long todo = nfds;
60944
60945 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60946 if (nfds > rlimit(RLIMIT_NOFILE))
60947 return -EINVAL;
60948
60949 diff --git a/fs/seq_file.c b/fs/seq_file.c
60950 index a290157..ec3211a 100644
60951 --- a/fs/seq_file.c
60952 +++ b/fs/seq_file.c
60953 @@ -10,6 +10,7 @@
60954 #include <linux/seq_file.h>
60955 #include <linux/slab.h>
60956 #include <linux/cred.h>
60957 +#include <linux/sched.h>
60958
60959 #include <asm/uaccess.h>
60960 #include <asm/page.h>
60961 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60962 #ifdef CONFIG_USER_NS
60963 p->user_ns = file->f_cred->user_ns;
60964 #endif
60965 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60966 + p->exec_id = current->exec_id;
60967 +#endif
60968
60969 /*
60970 * Wrappers around seq_open(e.g. swaps_open) need to be
60971 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60972 return 0;
60973 }
60974 if (!m->buf) {
60975 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60976 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60977 if (!m->buf)
60978 return -ENOMEM;
60979 }
60980 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60981 Eoverflow:
60982 m->op->stop(m, p);
60983 kfree(m->buf);
60984 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60985 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60986 return !m->buf ? -ENOMEM : -EAGAIN;
60987 }
60988
60989 @@ -152,7 +156,7 @@ Eoverflow:
60990 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60991 {
60992 struct seq_file *m = file->private_data;
60993 - size_t copied = 0;
60994 + ssize_t copied = 0;
60995 loff_t pos;
60996 size_t n;
60997 void *p;
60998 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60999
61000 /* grab buffer if we didn't have one */
61001 if (!m->buf) {
61002 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61003 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61004 if (!m->buf)
61005 goto Enomem;
61006 }
61007 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61008 goto Fill;
61009 m->op->stop(m, p);
61010 kfree(m->buf);
61011 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61012 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61013 if (!m->buf)
61014 goto Enomem;
61015 m->count = 0;
61016 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
61017 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
61018 void *data)
61019 {
61020 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
61021 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
61022 int res = -ENOMEM;
61023
61024 if (op) {
61025 diff --git a/fs/splice.c b/fs/splice.c
61026 index 3b7ee65..87fc2e4 100644
61027 --- a/fs/splice.c
61028 +++ b/fs/splice.c
61029 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61030 pipe_lock(pipe);
61031
61032 for (;;) {
61033 - if (!pipe->readers) {
61034 + if (!atomic_read(&pipe->readers)) {
61035 send_sig(SIGPIPE, current, 0);
61036 if (!ret)
61037 ret = -EPIPE;
61038 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61039 page_nr++;
61040 ret += buf->len;
61041
61042 - if (pipe->files)
61043 + if (atomic_read(&pipe->files))
61044 do_wakeup = 1;
61045
61046 if (!--spd->nr_pages)
61047 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61048 do_wakeup = 0;
61049 }
61050
61051 - pipe->waiting_writers++;
61052 + atomic_inc(&pipe->waiting_writers);
61053 pipe_wait(pipe);
61054 - pipe->waiting_writers--;
61055 + atomic_dec(&pipe->waiting_writers);
61056 }
61057
61058 pipe_unlock(pipe);
61059 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61060 old_fs = get_fs();
61061 set_fs(get_ds());
61062 /* The cast to a user pointer is valid due to the set_fs() */
61063 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61064 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61065 set_fs(old_fs);
61066
61067 return res;
61068 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61069 old_fs = get_fs();
61070 set_fs(get_ds());
61071 /* The cast to a user pointer is valid due to the set_fs() */
61072 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61073 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61074 set_fs(old_fs);
61075
61076 return res;
61077 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61078 goto err;
61079
61080 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61081 - vec[i].iov_base = (void __user *) page_address(page);
61082 + vec[i].iov_base = (void __force_user *) page_address(page);
61083 vec[i].iov_len = this_len;
61084 spd.pages[i] = page;
61085 spd.nr_pages++;
61086 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61087 ops->release(pipe, buf);
61088 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61089 pipe->nrbufs--;
61090 - if (pipe->files)
61091 + if (atomic_read(&pipe->files))
61092 sd->need_wakeup = true;
61093 }
61094
61095 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61096 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61097 {
61098 while (!pipe->nrbufs) {
61099 - if (!pipe->writers)
61100 + if (!atomic_read(&pipe->writers))
61101 return 0;
61102
61103 - if (!pipe->waiting_writers && sd->num_spliced)
61104 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61105 return 0;
61106
61107 if (sd->flags & SPLICE_F_NONBLOCK)
61108 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61109 * out of the pipe right after the splice_to_pipe(). So set
61110 * PIPE_READERS appropriately.
61111 */
61112 - pipe->readers = 1;
61113 + atomic_set(&pipe->readers, 1);
61114
61115 current->splice_pipe = pipe;
61116 }
61117 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
61118
61119 partial[buffers].offset = off;
61120 partial[buffers].len = plen;
61121 + partial[buffers].private = 0;
61122
61123 off = 0;
61124 len -= plen;
61125 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61126 ret = -ERESTARTSYS;
61127 break;
61128 }
61129 - if (!pipe->writers)
61130 + if (!atomic_read(&pipe->writers))
61131 break;
61132 - if (!pipe->waiting_writers) {
61133 + if (!atomic_read(&pipe->waiting_writers)) {
61134 if (flags & SPLICE_F_NONBLOCK) {
61135 ret = -EAGAIN;
61136 break;
61137 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61138 pipe_lock(pipe);
61139
61140 while (pipe->nrbufs >= pipe->buffers) {
61141 - if (!pipe->readers) {
61142 + if (!atomic_read(&pipe->readers)) {
61143 send_sig(SIGPIPE, current, 0);
61144 ret = -EPIPE;
61145 break;
61146 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61147 ret = -ERESTARTSYS;
61148 break;
61149 }
61150 - pipe->waiting_writers++;
61151 + atomic_inc(&pipe->waiting_writers);
61152 pipe_wait(pipe);
61153 - pipe->waiting_writers--;
61154 + atomic_dec(&pipe->waiting_writers);
61155 }
61156
61157 pipe_unlock(pipe);
61158 @@ -1862,14 +1863,14 @@ retry:
61159 pipe_double_lock(ipipe, opipe);
61160
61161 do {
61162 - if (!opipe->readers) {
61163 + if (!atomic_read(&opipe->readers)) {
61164 send_sig(SIGPIPE, current, 0);
61165 if (!ret)
61166 ret = -EPIPE;
61167 break;
61168 }
61169
61170 - if (!ipipe->nrbufs && !ipipe->writers)
61171 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
61172 break;
61173
61174 /*
61175 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61176 pipe_double_lock(ipipe, opipe);
61177
61178 do {
61179 - if (!opipe->readers) {
61180 + if (!atomic_read(&opipe->readers)) {
61181 send_sig(SIGPIPE, current, 0);
61182 if (!ret)
61183 ret = -EPIPE;
61184 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61185 * return EAGAIN if we have the potential of some data in the
61186 * future, otherwise just return 0
61187 */
61188 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
61189 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
61190 ret = -EAGAIN;
61191
61192 pipe_unlock(ipipe);
61193 diff --git a/fs/stat.c b/fs/stat.c
61194 index d0ea7ef..f463f9d 100644
61195 --- a/fs/stat.c
61196 +++ b/fs/stat.c
61197 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
61198 stat->gid = inode->i_gid;
61199 stat->rdev = inode->i_rdev;
61200 stat->size = i_size_read(inode);
61201 - stat->atime = inode->i_atime;
61202 - stat->mtime = inode->i_mtime;
61203 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61204 + stat->atime = inode->i_ctime;
61205 + stat->mtime = inode->i_ctime;
61206 + } else {
61207 + stat->atime = inode->i_atime;
61208 + stat->mtime = inode->i_mtime;
61209 + }
61210 stat->ctime = inode->i_ctime;
61211 stat->blksize = (1 << inode->i_blkbits);
61212 stat->blocks = inode->i_blocks;
61213 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
61214 if (retval)
61215 return retval;
61216
61217 - if (inode->i_op->getattr)
61218 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
61219 + if (inode->i_op->getattr) {
61220 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
61221 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61222 + stat->atime = stat->ctime;
61223 + stat->mtime = stat->ctime;
61224 + }
61225 + return retval;
61226 + }
61227
61228 generic_fillattr(inode, stat);
61229 return 0;
61230 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
61231 index c590cab..6dfd6fc 100644
61232 --- a/fs/sysfs/bin.c
61233 +++ b/fs/sysfs/bin.c
61234 @@ -234,13 +234,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
61235 return ret;
61236 }
61237
61238 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
61239 - void *buf, int len, int write)
61240 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
61241 + void *buf, size_t len, int write)
61242 {
61243 struct file *file = vma->vm_file;
61244 struct bin_buffer *bb = file->private_data;
61245 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
61246 - int ret;
61247 + ssize_t ret;
61248
61249 if (!bb->vm_ops)
61250 return -EINVAL;
61251 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
61252 index 4d83ced..049dc45 100644
61253 --- a/fs/sysfs/dir.c
61254 +++ b/fs/sysfs/dir.c
61255 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
61256 *
61257 * Returns 31 bit hash of ns + name (so it fits in an off_t )
61258 */
61259 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
61260 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
61261 {
61262 unsigned long hash = init_name_hash();
61263 unsigned int len = strlen(name);
61264 @@ -675,6 +675,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
61265 struct sysfs_dirent *sd;
61266 int rc;
61267
61268 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
61269 + const char *parent_name = parent_sd->s_name;
61270 +
61271 + mode = S_IFDIR | S_IRWXU;
61272 +
61273 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
61274 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
61275 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
61276 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
61277 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
61278 +#endif
61279 +
61280 /* allocate */
61281 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
61282 if (!sd)
61283 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
61284 index 15ef5eb..e474372 100644
61285 --- a/fs/sysfs/file.c
61286 +++ b/fs/sysfs/file.c
61287 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
61288
61289 struct sysfs_open_dirent {
61290 atomic_t refcnt;
61291 - atomic_t event;
61292 + atomic_unchecked_t event;
61293 wait_queue_head_t poll;
61294 struct list_head buffers; /* goes through sysfs_buffer.list */
61295 };
61296 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry *dentry, struct sysfs_buffer *buffer)
61297 if (!sysfs_get_active(attr_sd))
61298 return -ENODEV;
61299
61300 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
61301 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
61302 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
61303
61304 sysfs_put_active(attr_sd);
61305 @@ -284,7 +284,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
61306 return -ENOMEM;
61307
61308 atomic_set(&new_od->refcnt, 0);
61309 - atomic_set(&new_od->event, 1);
61310 + atomic_set_unchecked(&new_od->event, 1);
61311 init_waitqueue_head(&new_od->poll);
61312 INIT_LIST_HEAD(&new_od->buffers);
61313 goto retry;
61314 @@ -430,7 +430,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
61315
61316 sysfs_put_active(attr_sd);
61317
61318 - if (buffer->event != atomic_read(&od->event))
61319 + if (buffer->event != atomic_read_unchecked(&od->event))
61320 goto trigger;
61321
61322 return DEFAULT_POLLMASK;
61323 @@ -450,7 +450,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
61324 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
61325 od = sd->s_attr.open;
61326 if (od) {
61327 - atomic_inc(&od->event);
61328 + atomic_inc_unchecked(&od->event);
61329 wake_up_interruptible(&od->poll);
61330 }
61331 }
61332 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
61333 index 2dd4507..62a215a 100644
61334 --- a/fs/sysfs/symlink.c
61335 +++ b/fs/sysfs/symlink.c
61336 @@ -308,7 +308,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
61337 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
61338 void *cookie)
61339 {
61340 - char *page = nd_get_link(nd);
61341 + const char *page = nd_get_link(nd);
61342 if (!IS_ERR(page))
61343 free_page((unsigned long)page);
61344 }
61345 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
61346 index 69d4889..a810bd4 100644
61347 --- a/fs/sysv/sysv.h
61348 +++ b/fs/sysv/sysv.h
61349 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
61350 #endif
61351 }
61352
61353 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
61354 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
61355 {
61356 if (sbi->s_bytesex == BYTESEX_PDP)
61357 return PDP_swab((__force __u32)n);
61358 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
61359 index e18b988..f1d4ad0f 100644
61360 --- a/fs/ubifs/io.c
61361 +++ b/fs/ubifs/io.c
61362 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
61363 return err;
61364 }
61365
61366 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
61367 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
61368 {
61369 int err;
61370
61371 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
61372 index c175b4d..8f36a16 100644
61373 --- a/fs/udf/misc.c
61374 +++ b/fs/udf/misc.c
61375 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
61376
61377 u8 udf_tag_checksum(const struct tag *t)
61378 {
61379 - u8 *data = (u8 *)t;
61380 + const u8 *data = (const u8 *)t;
61381 u8 checksum = 0;
61382 int i;
61383 for (i = 0; i < sizeof(struct tag); ++i)
61384 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
61385 index 8d974c4..b82f6ec 100644
61386 --- a/fs/ufs/swab.h
61387 +++ b/fs/ufs/swab.h
61388 @@ -22,7 +22,7 @@ enum {
61389 BYTESEX_BE
61390 };
61391
61392 -static inline u64
61393 +static inline u64 __intentional_overflow(-1)
61394 fs64_to_cpu(struct super_block *sbp, __fs64 n)
61395 {
61396 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61397 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
61398 return (__force __fs64)cpu_to_be64(n);
61399 }
61400
61401 -static inline u32
61402 +static inline u32 __intentional_overflow(-1)
61403 fs32_to_cpu(struct super_block *sbp, __fs32 n)
61404 {
61405 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61406 diff --git a/fs/utimes.c b/fs/utimes.c
61407 index f4fb7ec..3fe03c0 100644
61408 --- a/fs/utimes.c
61409 +++ b/fs/utimes.c
61410 @@ -1,6 +1,7 @@
61411 #include <linux/compiler.h>
61412 #include <linux/file.h>
61413 #include <linux/fs.h>
61414 +#include <linux/security.h>
61415 #include <linux/linkage.h>
61416 #include <linux/mount.h>
61417 #include <linux/namei.h>
61418 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
61419 goto mnt_drop_write_and_out;
61420 }
61421 }
61422 +
61423 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
61424 + error = -EACCES;
61425 + goto mnt_drop_write_and_out;
61426 + }
61427 +
61428 mutex_lock(&inode->i_mutex);
61429 error = notify_change(path->dentry, &newattrs);
61430 mutex_unlock(&inode->i_mutex);
61431 diff --git a/fs/xattr.c b/fs/xattr.c
61432 index 3377dff..4d074d9 100644
61433 --- a/fs/xattr.c
61434 +++ b/fs/xattr.c
61435 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
61436 return rc;
61437 }
61438
61439 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
61440 +ssize_t
61441 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
61442 +{
61443 + struct inode *inode = dentry->d_inode;
61444 + ssize_t error;
61445 +
61446 + error = inode_permission(inode, MAY_EXEC);
61447 + if (error)
61448 + return error;
61449 +
61450 + if (inode->i_op->getxattr)
61451 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
61452 + else
61453 + error = -EOPNOTSUPP;
61454 +
61455 + return error;
61456 +}
61457 +EXPORT_SYMBOL(pax_getxattr);
61458 +#endif
61459 +
61460 ssize_t
61461 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
61462 {
61463 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
61464 * Extended attribute SET operations
61465 */
61466 static long
61467 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
61468 +setxattr(struct path *path, const char __user *name, const void __user *value,
61469 size_t size, int flags)
61470 {
61471 int error;
61472 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
61473 posix_acl_fix_xattr_from_user(kvalue, size);
61474 }
61475
61476 - error = vfs_setxattr(d, kname, kvalue, size, flags);
61477 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
61478 + error = -EACCES;
61479 + goto out;
61480 + }
61481 +
61482 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
61483 out:
61484 if (vvalue)
61485 vfree(vvalue);
61486 @@ -377,7 +403,7 @@ retry:
61487 return error;
61488 error = mnt_want_write(path.mnt);
61489 if (!error) {
61490 - error = setxattr(path.dentry, name, value, size, flags);
61491 + error = setxattr(&path, name, value, size, flags);
61492 mnt_drop_write(path.mnt);
61493 }
61494 path_put(&path);
61495 @@ -401,7 +427,7 @@ retry:
61496 return error;
61497 error = mnt_want_write(path.mnt);
61498 if (!error) {
61499 - error = setxattr(path.dentry, name, value, size, flags);
61500 + error = setxattr(&path, name, value, size, flags);
61501 mnt_drop_write(path.mnt);
61502 }
61503 path_put(&path);
61504 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
61505 const void __user *,value, size_t, size, int, flags)
61506 {
61507 struct fd f = fdget(fd);
61508 - struct dentry *dentry;
61509 int error = -EBADF;
61510
61511 if (!f.file)
61512 return error;
61513 - dentry = f.file->f_path.dentry;
61514 - audit_inode(NULL, dentry, 0);
61515 + audit_inode(NULL, f.file->f_path.dentry, 0);
61516 error = mnt_want_write_file(f.file);
61517 if (!error) {
61518 - error = setxattr(dentry, name, value, size, flags);
61519 + error = setxattr(&f.file->f_path, name, value, size, flags);
61520 mnt_drop_write_file(f.file);
61521 }
61522 fdput(f);
61523 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
61524 index 9fbea87..6b19972 100644
61525 --- a/fs/xattr_acl.c
61526 +++ b/fs/xattr_acl.c
61527 @@ -76,8 +76,8 @@ struct posix_acl *
61528 posix_acl_from_xattr(struct user_namespace *user_ns,
61529 const void *value, size_t size)
61530 {
61531 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
61532 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
61533 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
61534 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
61535 int count;
61536 struct posix_acl *acl;
61537 struct posix_acl_entry *acl_e;
61538 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61539 index f47e65c..e7125d9 100644
61540 --- a/fs/xfs/xfs_bmap.c
61541 +++ b/fs/xfs/xfs_bmap.c
61542 @@ -586,7 +586,7 @@ xfs_bmap_validate_ret(
61543
61544 #else
61545 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61546 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61547 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61548 #endif /* DEBUG */
61549
61550 /*
61551 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
61552 index 8f84153..7ce60d0 100644
61553 --- a/fs/xfs/xfs_dir2_readdir.c
61554 +++ b/fs/xfs/xfs_dir2_readdir.c
61555 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
61556 ino = xfs_dir3_sfe_get_ino(mp, sfp, sfep);
61557 filetype = xfs_dir3_sfe_get_ftype(mp, sfp, sfep);
61558 ctx->pos = off & 0x7fffffff;
61559 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
61560 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61561 + char name[sfep->namelen];
61562 + memcpy(name, sfep->name, sfep->namelen);
61563 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
61564 + return 0;
61565 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
61566 xfs_dir3_get_dtype(mp, filetype)))
61567 return 0;
61568 sfep = xfs_dir3_sf_nextentry(mp, sfp, sfep);
61569 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61570 index 668e8f4..9d38104 100644
61571 --- a/fs/xfs/xfs_ioctl.c
61572 +++ b/fs/xfs/xfs_ioctl.c
61573 @@ -127,7 +127,7 @@ xfs_find_handle(
61574 }
61575
61576 error = -EFAULT;
61577 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61578 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61579 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61580 goto out_put;
61581
61582 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61583 index 2b8952d..a60c6be 100644
61584 --- a/fs/xfs/xfs_iops.c
61585 +++ b/fs/xfs/xfs_iops.c
61586 @@ -401,7 +401,7 @@ xfs_vn_put_link(
61587 struct nameidata *nd,
61588 void *p)
61589 {
61590 - char *s = nd_get_link(nd);
61591 + const char *s = nd_get_link(nd);
61592
61593 if (!IS_ERR(s))
61594 kfree(s);
61595 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61596 new file mode 100644
61597 index 0000000..6d22fbe
61598 --- /dev/null
61599 +++ b/grsecurity/Kconfig
61600 @@ -0,0 +1,1112 @@
61601 +#
61602 +# grecurity configuration
61603 +#
61604 +menu "Memory Protections"
61605 +depends on GRKERNSEC
61606 +
61607 +config GRKERNSEC_KMEM
61608 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61609 + default y if GRKERNSEC_CONFIG_AUTO
61610 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61611 + help
61612 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61613 + be written to or read from to modify or leak the contents of the running
61614 + kernel. /dev/port will also not be allowed to be opened and support
61615 + for /dev/cpu/*/msr will be removed. If you have module
61616 + support disabled, enabling this will close up five ways that are
61617 + currently used to insert malicious code into the running kernel.
61618 +
61619 + Even with all these features enabled, we still highly recommend that
61620 + you use the RBAC system, as it is still possible for an attacker to
61621 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61622 +
61623 + If you are not using XFree86, you may be able to stop this additional
61624 + case by enabling the 'Disable privileged I/O' option. Though nothing
61625 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61626 + but only to video memory, which is the only writing we allow in this
61627 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61628 + not be allowed to mprotect it with PROT_WRITE later.
61629 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61630 + from working.
61631 +
61632 + It is highly recommended that you say Y here if you meet all the
61633 + conditions above.
61634 +
61635 +config GRKERNSEC_VM86
61636 + bool "Restrict VM86 mode"
61637 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61638 + depends on X86_32
61639 +
61640 + help
61641 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61642 + make use of a special execution mode on 32bit x86 processors called
61643 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61644 + video cards and will still work with this option enabled. The purpose
61645 + of the option is to prevent exploitation of emulation errors in
61646 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61647 + Nearly all users should be able to enable this option.
61648 +
61649 +config GRKERNSEC_IO
61650 + bool "Disable privileged I/O"
61651 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61652 + depends on X86
61653 + select RTC_CLASS
61654 + select RTC_INTF_DEV
61655 + select RTC_DRV_CMOS
61656 +
61657 + help
61658 + If you say Y here, all ioperm and iopl calls will return an error.
61659 + Ioperm and iopl can be used to modify the running kernel.
61660 + Unfortunately, some programs need this access to operate properly,
61661 + the most notable of which are XFree86 and hwclock. hwclock can be
61662 + remedied by having RTC support in the kernel, so real-time
61663 + clock support is enabled if this option is enabled, to ensure
61664 + that hwclock operates correctly. XFree86 still will not
61665 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61666 + IF YOU USE XFree86. If you use XFree86 and you still want to
61667 + protect your kernel against modification, use the RBAC system.
61668 +
61669 +config GRKERNSEC_JIT_HARDEN
61670 + bool "Harden BPF JIT against spray attacks"
61671 + default y if GRKERNSEC_CONFIG_AUTO
61672 + depends on BPF_JIT
61673 + help
61674 + If you say Y here, the native code generated by the kernel's Berkeley
61675 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61676 + attacks that attempt to fit attacker-beneficial instructions in
61677 + 32bit immediate fields of JIT-generated native instructions. The
61678 + attacker will generally aim to cause an unintended instruction sequence
61679 + of JIT-generated native code to execute by jumping into the middle of
61680 + a generated instruction. This feature effectively randomizes the 32bit
61681 + immediate constants present in the generated code to thwart such attacks.
61682 +
61683 + If you're using KERNEXEC, it's recommended that you enable this option
61684 + to supplement the hardening of the kernel.
61685 +
61686 +config GRKERNSEC_PERF_HARDEN
61687 + bool "Disable unprivileged PERF_EVENTS usage by default"
61688 + default y if GRKERNSEC_CONFIG_AUTO
61689 + depends on PERF_EVENTS
61690 + help
61691 + If you say Y here, the range of acceptable values for the
61692 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61693 + default to a new value: 3. When the sysctl is set to this value, no
61694 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61695 +
61696 + Though PERF_EVENTS can be used legitimately for performance monitoring
61697 + and low-level application profiling, it is forced on regardless of
61698 + configuration, has been at fault for several vulnerabilities, and
61699 + creates new opportunities for side channels and other information leaks.
61700 +
61701 + This feature puts PERF_EVENTS into a secure default state and permits
61702 + the administrator to change out of it temporarily if unprivileged
61703 + application profiling is needed.
61704 +
61705 +config GRKERNSEC_RAND_THREADSTACK
61706 + bool "Insert random gaps between thread stacks"
61707 + default y if GRKERNSEC_CONFIG_AUTO
61708 + depends on PAX_RANDMMAP && !PPC
61709 + help
61710 + If you say Y here, a random-sized gap will be enforced between allocated
61711 + thread stacks. Glibc's NPTL and other threading libraries that
61712 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61713 + The implementation currently provides 8 bits of entropy for the gap.
61714 +
61715 + Many distributions do not compile threaded remote services with the
61716 + -fstack-check argument to GCC, causing the variable-sized stack-based
61717 + allocator, alloca(), to not probe the stack on allocation. This
61718 + permits an unbounded alloca() to skip over any guard page and potentially
61719 + modify another thread's stack reliably. An enforced random gap
61720 + reduces the reliability of such an attack and increases the chance
61721 + that such a read/write to another thread's stack instead lands in
61722 + an unmapped area, causing a crash and triggering grsecurity's
61723 + anti-bruteforcing logic.
61724 +
61725 +config GRKERNSEC_PROC_MEMMAP
61726 + bool "Harden ASLR against information leaks and entropy reduction"
61727 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61728 + depends on PAX_NOEXEC || PAX_ASLR
61729 + help
61730 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61731 + give no information about the addresses of its mappings if
61732 + PaX features that rely on random addresses are enabled on the task.
61733 + In addition to sanitizing this information and disabling other
61734 + dangerous sources of information, this option causes reads of sensitive
61735 + /proc/<pid> entries where the file descriptor was opened in a different
61736 + task than the one performing the read. Such attempts are logged.
61737 + This option also limits argv/env strings for suid/sgid binaries
61738 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61739 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61740 + binaries to prevent alternative mmap layouts from being abused.
61741 +
61742 + If you use PaX it is essential that you say Y here as it closes up
61743 + several holes that make full ASLR useless locally.
61744 +
61745 +config GRKERNSEC_BRUTE
61746 + bool "Deter exploit bruteforcing"
61747 + default y if GRKERNSEC_CONFIG_AUTO
61748 + help
61749 + If you say Y here, attempts to bruteforce exploits against forking
61750 + daemons such as apache or sshd, as well as against suid/sgid binaries
61751 + will be deterred. When a child of a forking daemon is killed by PaX
61752 + or crashes due to an illegal instruction or other suspicious signal,
61753 + the parent process will be delayed 30 seconds upon every subsequent
61754 + fork until the administrator is able to assess the situation and
61755 + restart the daemon.
61756 + In the suid/sgid case, the attempt is logged, the user has all their
61757 + existing instances of the suid/sgid binary terminated and will
61758 + be unable to execute any suid/sgid binaries for 15 minutes.
61759 +
61760 + It is recommended that you also enable signal logging in the auditing
61761 + section so that logs are generated when a process triggers a suspicious
61762 + signal.
61763 + If the sysctl option is enabled, a sysctl option with name
61764 + "deter_bruteforce" is created.
61765 +
61766 +
61767 +config GRKERNSEC_MODHARDEN
61768 + bool "Harden module auto-loading"
61769 + default y if GRKERNSEC_CONFIG_AUTO
61770 + depends on MODULES
61771 + help
61772 + If you say Y here, module auto-loading in response to use of some
61773 + feature implemented by an unloaded module will be restricted to
61774 + root users. Enabling this option helps defend against attacks
61775 + by unprivileged users who abuse the auto-loading behavior to
61776 + cause a vulnerable module to load that is then exploited.
61777 +
61778 + If this option prevents a legitimate use of auto-loading for a
61779 + non-root user, the administrator can execute modprobe manually
61780 + with the exact name of the module mentioned in the alert log.
61781 + Alternatively, the administrator can add the module to the list
61782 + of modules loaded at boot by modifying init scripts.
61783 +
61784 + Modification of init scripts will most likely be needed on
61785 + Ubuntu servers with encrypted home directory support enabled,
61786 + as the first non-root user logging in will cause the ecb(aes),
61787 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61788 +
61789 +config GRKERNSEC_HIDESYM
61790 + bool "Hide kernel symbols"
61791 + default y if GRKERNSEC_CONFIG_AUTO
61792 + select PAX_USERCOPY_SLABS
61793 + help
61794 + If you say Y here, getting information on loaded modules, and
61795 + displaying all kernel symbols through a syscall will be restricted
61796 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61797 + /proc/kallsyms will be restricted to the root user. The RBAC
61798 + system can hide that entry even from root.
61799 +
61800 + This option also prevents leaking of kernel addresses through
61801 + several /proc entries.
61802 +
61803 + Note that this option is only effective provided the following
61804 + conditions are met:
61805 + 1) The kernel using grsecurity is not precompiled by some distribution
61806 + 2) You have also enabled GRKERNSEC_DMESG
61807 + 3) You are using the RBAC system and hiding other files such as your
61808 + kernel image and System.map. Alternatively, enabling this option
61809 + causes the permissions on /boot, /lib/modules, and the kernel
61810 + source directory to change at compile time to prevent
61811 + reading by non-root users.
61812 + If the above conditions are met, this option will aid in providing a
61813 + useful protection against local kernel exploitation of overflows
61814 + and arbitrary read/write vulnerabilities.
61815 +
61816 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61817 + in addition to this feature.
61818 +
61819 +config GRKERNSEC_KERN_LOCKOUT
61820 + bool "Active kernel exploit response"
61821 + default y if GRKERNSEC_CONFIG_AUTO
61822 + depends on X86 || ARM || PPC || SPARC
61823 + help
61824 + If you say Y here, when a PaX alert is triggered due to suspicious
61825 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61826 + or an OOPS occurs due to bad memory accesses, instead of just
61827 + terminating the offending process (and potentially allowing
61828 + a subsequent exploit from the same user), we will take one of two
61829 + actions:
61830 + If the user was root, we will panic the system
61831 + If the user was non-root, we will log the attempt, terminate
61832 + all processes owned by the user, then prevent them from creating
61833 + any new processes until the system is restarted
61834 + This deters repeated kernel exploitation/bruteforcing attempts
61835 + and is useful for later forensics.
61836 +
61837 +config GRKERNSEC_OLD_ARM_USERLAND
61838 + bool "Old ARM userland compatibility"
61839 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
61840 + help
61841 + If you say Y here, stubs of executable code to perform such operations
61842 + as "compare-exchange" will be placed at fixed locations in the ARM vector
61843 + table. This is unfortunately needed for old ARM userland meant to run
61844 + across a wide range of processors. Without this option enabled,
61845 + the get_tls and data memory barrier stubs will be emulated by the kernel,
61846 + which is enough for Linaro userlands or other userlands designed for v6
61847 + and newer ARM CPUs. It's recommended that you try without this option enabled
61848 + first, and only enable it if your userland does not boot (it will likely fail
61849 + at init time).
61850 +
61851 +endmenu
61852 +menu "Role Based Access Control Options"
61853 +depends on GRKERNSEC
61854 +
61855 +config GRKERNSEC_RBAC_DEBUG
61856 + bool
61857 +
61858 +config GRKERNSEC_NO_RBAC
61859 + bool "Disable RBAC system"
61860 + help
61861 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61862 + preventing the RBAC system from being enabled. You should only say Y
61863 + here if you have no intention of using the RBAC system, so as to prevent
61864 + an attacker with root access from misusing the RBAC system to hide files
61865 + and processes when loadable module support and /dev/[k]mem have been
61866 + locked down.
61867 +
61868 +config GRKERNSEC_ACL_HIDEKERN
61869 + bool "Hide kernel processes"
61870 + help
61871 + If you say Y here, all kernel threads will be hidden to all
61872 + processes but those whose subject has the "view hidden processes"
61873 + flag.
61874 +
61875 +config GRKERNSEC_ACL_MAXTRIES
61876 + int "Maximum tries before password lockout"
61877 + default 3
61878 + help
61879 + This option enforces the maximum number of times a user can attempt
61880 + to authorize themselves with the grsecurity RBAC system before being
61881 + denied the ability to attempt authorization again for a specified time.
61882 + The lower the number, the harder it will be to brute-force a password.
61883 +
61884 +config GRKERNSEC_ACL_TIMEOUT
61885 + int "Time to wait after max password tries, in seconds"
61886 + default 30
61887 + help
61888 + This option specifies the time the user must wait after attempting to
61889 + authorize to the RBAC system with the maximum number of invalid
61890 + passwords. The higher the number, the harder it will be to brute-force
61891 + a password.
61892 +
61893 +endmenu
61894 +menu "Filesystem Protections"
61895 +depends on GRKERNSEC
61896 +
61897 +config GRKERNSEC_PROC
61898 + bool "Proc restrictions"
61899 + default y if GRKERNSEC_CONFIG_AUTO
61900 + help
61901 + If you say Y here, the permissions of the /proc filesystem
61902 + will be altered to enhance system security and privacy. You MUST
61903 + choose either a user only restriction or a user and group restriction.
61904 + Depending upon the option you choose, you can either restrict users to
61905 + see only the processes they themselves run, or choose a group that can
61906 + view all processes and files normally restricted to root if you choose
61907 + the "restrict to user only" option. NOTE: If you're running identd or
61908 + ntpd as a non-root user, you will have to run it as the group you
61909 + specify here.
61910 +
61911 +config GRKERNSEC_PROC_USER
61912 + bool "Restrict /proc to user only"
61913 + depends on GRKERNSEC_PROC
61914 + help
61915 + If you say Y here, non-root users will only be able to view their own
61916 + processes, and restricts them from viewing network-related information,
61917 + and viewing kernel symbol and module information.
61918 +
61919 +config GRKERNSEC_PROC_USERGROUP
61920 + bool "Allow special group"
61921 + default y if GRKERNSEC_CONFIG_AUTO
61922 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61923 + help
61924 + If you say Y here, you will be able to select a group that will be
61925 + able to view all processes and network-related information. If you've
61926 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61927 + remain hidden. This option is useful if you want to run identd as
61928 + a non-root user. The group you select may also be chosen at boot time
61929 + via "grsec_proc_gid=" on the kernel commandline.
61930 +
61931 +config GRKERNSEC_PROC_GID
61932 + int "GID for special group"
61933 + depends on GRKERNSEC_PROC_USERGROUP
61934 + default 1001
61935 +
61936 +config GRKERNSEC_PROC_ADD
61937 + bool "Additional restrictions"
61938 + default y if GRKERNSEC_CONFIG_AUTO
61939 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61940 + help
61941 + If you say Y here, additional restrictions will be placed on
61942 + /proc that keep normal users from viewing device information and
61943 + slabinfo information that could be useful for exploits.
61944 +
61945 +config GRKERNSEC_LINK
61946 + bool "Linking restrictions"
61947 + default y if GRKERNSEC_CONFIG_AUTO
61948 + help
61949 + If you say Y here, /tmp race exploits will be prevented, since users
61950 + will no longer be able to follow symlinks owned by other users in
61951 + world-writable +t directories (e.g. /tmp), unless the owner of the
61952 + symlink is the owner of the directory. users will also not be
61953 + able to hardlink to files they do not own. If the sysctl option is
61954 + enabled, a sysctl option with name "linking_restrictions" is created.
61955 +
61956 +config GRKERNSEC_SYMLINKOWN
61957 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61958 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61959 + help
61960 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61961 + that prevents it from being used as a security feature. As Apache
61962 + verifies the symlink by performing a stat() against the target of
61963 + the symlink before it is followed, an attacker can setup a symlink
61964 + to point to a same-owned file, then replace the symlink with one
61965 + that targets another user's file just after Apache "validates" the
61966 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61967 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61968 + will be in place for the group you specify. If the sysctl option
61969 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61970 + created.
61971 +
61972 +config GRKERNSEC_SYMLINKOWN_GID
61973 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61974 + depends on GRKERNSEC_SYMLINKOWN
61975 + default 1006
61976 + help
61977 + Setting this GID determines what group kernel-enforced
61978 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61979 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61980 +
61981 +config GRKERNSEC_FIFO
61982 + bool "FIFO restrictions"
61983 + default y if GRKERNSEC_CONFIG_AUTO
61984 + help
61985 + If you say Y here, users will not be able to write to FIFOs they don't
61986 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61987 + the FIFO is the same owner of the directory it's held in. If the sysctl
61988 + option is enabled, a sysctl option with name "fifo_restrictions" is
61989 + created.
61990 +
61991 +config GRKERNSEC_SYSFS_RESTRICT
61992 + bool "Sysfs/debugfs restriction"
61993 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61994 + depends on SYSFS
61995 + help
61996 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61997 + any filesystem normally mounted under it (e.g. debugfs) will be
61998 + mostly accessible only by root. These filesystems generally provide access
61999 + to hardware and debug information that isn't appropriate for unprivileged
62000 + users of the system. Sysfs and debugfs have also become a large source
62001 + of new vulnerabilities, ranging from infoleaks to local compromise.
62002 + There has been very little oversight with an eye toward security involved
62003 + in adding new exporters of information to these filesystems, so their
62004 + use is discouraged.
62005 + For reasons of compatibility, a few directories have been whitelisted
62006 + for access by non-root users:
62007 + /sys/fs/selinux
62008 + /sys/fs/fuse
62009 + /sys/devices/system/cpu
62010 +
62011 +config GRKERNSEC_ROFS
62012 + bool "Runtime read-only mount protection"
62013 + depends on SYSCTL
62014 + help
62015 + If you say Y here, a sysctl option with name "romount_protect" will
62016 + be created. By setting this option to 1 at runtime, filesystems
62017 + will be protected in the following ways:
62018 + * No new writable mounts will be allowed
62019 + * Existing read-only mounts won't be able to be remounted read/write
62020 + * Write operations will be denied on all block devices
62021 + This option acts independently of grsec_lock: once it is set to 1,
62022 + it cannot be turned off. Therefore, please be mindful of the resulting
62023 + behavior if this option is enabled in an init script on a read-only
62024 + filesystem. This feature is mainly intended for secure embedded systems.
62025 +
62026 +config GRKERNSEC_DEVICE_SIDECHANNEL
62027 + bool "Eliminate stat/notify-based device sidechannels"
62028 + default y if GRKERNSEC_CONFIG_AUTO
62029 + help
62030 + If you say Y here, timing analyses on block or character
62031 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
62032 + will be thwarted for unprivileged users. If a process without
62033 + CAP_MKNOD stats such a device, the last access and last modify times
62034 + will match the device's create time. No access or modify events
62035 + will be triggered through inotify/dnotify/fanotify for such devices.
62036 + This feature will prevent attacks that may at a minimum
62037 + allow an attacker to determine the administrator's password length.
62038 +
62039 +config GRKERNSEC_CHROOT
62040 + bool "Chroot jail restrictions"
62041 + default y if GRKERNSEC_CONFIG_AUTO
62042 + help
62043 + If you say Y here, you will be able to choose several options that will
62044 + make breaking out of a chrooted jail much more difficult. If you
62045 + encounter no software incompatibilities with the following options, it
62046 + is recommended that you enable each one.
62047 +
62048 +config GRKERNSEC_CHROOT_MOUNT
62049 + bool "Deny mounts"
62050 + default y if GRKERNSEC_CONFIG_AUTO
62051 + depends on GRKERNSEC_CHROOT
62052 + help
62053 + If you say Y here, processes inside a chroot will not be able to
62054 + mount or remount filesystems. If the sysctl option is enabled, a
62055 + sysctl option with name "chroot_deny_mount" is created.
62056 +
62057 +config GRKERNSEC_CHROOT_DOUBLE
62058 + bool "Deny double-chroots"
62059 + default y if GRKERNSEC_CONFIG_AUTO
62060 + depends on GRKERNSEC_CHROOT
62061 + help
62062 + If you say Y here, processes inside a chroot will not be able to chroot
62063 + again outside the chroot. This is a widely used method of breaking
62064 + out of a chroot jail and should not be allowed. If the sysctl
62065 + option is enabled, a sysctl option with name
62066 + "chroot_deny_chroot" is created.
62067 +
62068 +config GRKERNSEC_CHROOT_PIVOT
62069 + bool "Deny pivot_root in chroot"
62070 + default y if GRKERNSEC_CONFIG_AUTO
62071 + depends on GRKERNSEC_CHROOT
62072 + help
62073 + If you say Y here, processes inside a chroot will not be able to use
62074 + a function called pivot_root() that was introduced in Linux 2.3.41. It
62075 + works similar to chroot in that it changes the root filesystem. This
62076 + function could be misused in a chrooted process to attempt to break out
62077 + of the chroot, and therefore should not be allowed. If the sysctl
62078 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
62079 + created.
62080 +
62081 +config GRKERNSEC_CHROOT_CHDIR
62082 + bool "Enforce chdir(\"/\") on all chroots"
62083 + default y if GRKERNSEC_CONFIG_AUTO
62084 + depends on GRKERNSEC_CHROOT
62085 + help
62086 + If you say Y here, the current working directory of all newly-chrooted
62087 + applications will be set to the the root directory of the chroot.
62088 + The man page on chroot(2) states:
62089 + Note that this call does not change the current working
62090 + directory, so that `.' can be outside the tree rooted at
62091 + `/'. In particular, the super-user can escape from a
62092 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
62093 +
62094 + It is recommended that you say Y here, since it's not known to break
62095 + any software. If the sysctl option is enabled, a sysctl option with
62096 + name "chroot_enforce_chdir" is created.
62097 +
62098 +config GRKERNSEC_CHROOT_CHMOD
62099 + bool "Deny (f)chmod +s"
62100 + default y if GRKERNSEC_CONFIG_AUTO
62101 + depends on GRKERNSEC_CHROOT
62102 + help
62103 + If you say Y here, processes inside a chroot will not be able to chmod
62104 + or fchmod files to make them have suid or sgid bits. This protects
62105 + against another published method of breaking a chroot. If the sysctl
62106 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
62107 + created.
62108 +
62109 +config GRKERNSEC_CHROOT_FCHDIR
62110 + bool "Deny fchdir out of chroot"
62111 + default y if GRKERNSEC_CONFIG_AUTO
62112 + depends on GRKERNSEC_CHROOT
62113 + help
62114 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
62115 + to a file descriptor of the chrooting process that points to a directory
62116 + outside the filesystem will be stopped. If the sysctl option
62117 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
62118 +
62119 +config GRKERNSEC_CHROOT_MKNOD
62120 + bool "Deny mknod"
62121 + default y if GRKERNSEC_CONFIG_AUTO
62122 + depends on GRKERNSEC_CHROOT
62123 + help
62124 + If you say Y here, processes inside a chroot will not be allowed to
62125 + mknod. The problem with using mknod inside a chroot is that it
62126 + would allow an attacker to create a device entry that is the same
62127 + as one on the physical root of your system, which could range from
62128 + anything from the console device to a device for your harddrive (which
62129 + they could then use to wipe the drive or steal data). It is recommended
62130 + that you say Y here, unless you run into software incompatibilities.
62131 + If the sysctl option is enabled, a sysctl option with name
62132 + "chroot_deny_mknod" is created.
62133 +
62134 +config GRKERNSEC_CHROOT_SHMAT
62135 + bool "Deny shmat() out of chroot"
62136 + default y if GRKERNSEC_CONFIG_AUTO
62137 + depends on GRKERNSEC_CHROOT
62138 + help
62139 + If you say Y here, processes inside a chroot will not be able to attach
62140 + to shared memory segments that were created outside of the chroot jail.
62141 + It is recommended that you say Y here. If the sysctl option is enabled,
62142 + a sysctl option with name "chroot_deny_shmat" is created.
62143 +
62144 +config GRKERNSEC_CHROOT_UNIX
62145 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
62146 + default y if GRKERNSEC_CONFIG_AUTO
62147 + depends on GRKERNSEC_CHROOT
62148 + help
62149 + If you say Y here, processes inside a chroot will not be able to
62150 + connect to abstract (meaning not belonging to a filesystem) Unix
62151 + domain sockets that were bound outside of a chroot. It is recommended
62152 + that you say Y here. If the sysctl option is enabled, a sysctl option
62153 + with name "chroot_deny_unix" is created.
62154 +
62155 +config GRKERNSEC_CHROOT_FINDTASK
62156 + bool "Protect outside processes"
62157 + default y if GRKERNSEC_CONFIG_AUTO
62158 + depends on GRKERNSEC_CHROOT
62159 + help
62160 + If you say Y here, processes inside a chroot will not be able to
62161 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
62162 + getsid, or view any process outside of the chroot. If the sysctl
62163 + option is enabled, a sysctl option with name "chroot_findtask" is
62164 + created.
62165 +
62166 +config GRKERNSEC_CHROOT_NICE
62167 + bool "Restrict priority changes"
62168 + default y if GRKERNSEC_CONFIG_AUTO
62169 + depends on GRKERNSEC_CHROOT
62170 + help
62171 + If you say Y here, processes inside a chroot will not be able to raise
62172 + the priority of processes in the chroot, or alter the priority of
62173 + processes outside the chroot. This provides more security than simply
62174 + removing CAP_SYS_NICE from the process' capability set. If the
62175 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
62176 + is created.
62177 +
62178 +config GRKERNSEC_CHROOT_SYSCTL
62179 + bool "Deny sysctl writes"
62180 + default y if GRKERNSEC_CONFIG_AUTO
62181 + depends on GRKERNSEC_CHROOT
62182 + help
62183 + If you say Y here, an attacker in a chroot will not be able to
62184 + write to sysctl entries, either by sysctl(2) or through a /proc
62185 + interface. It is strongly recommended that you say Y here. If the
62186 + sysctl option is enabled, a sysctl option with name
62187 + "chroot_deny_sysctl" is created.
62188 +
62189 +config GRKERNSEC_CHROOT_CAPS
62190 + bool "Capability restrictions"
62191 + default y if GRKERNSEC_CONFIG_AUTO
62192 + depends on GRKERNSEC_CHROOT
62193 + help
62194 + If you say Y here, the capabilities on all processes within a
62195 + chroot jail will be lowered to stop module insertion, raw i/o,
62196 + system and net admin tasks, rebooting the system, modifying immutable
62197 + files, modifying IPC owned by another, and changing the system time.
62198 + This is left an option because it can break some apps. Disable this
62199 + if your chrooted apps are having problems performing those kinds of
62200 + tasks. If the sysctl option is enabled, a sysctl option with
62201 + name "chroot_caps" is created.
62202 +
62203 +config GRKERNSEC_CHROOT_INITRD
62204 + bool "Exempt initrd tasks from restrictions"
62205 + default y if GRKERNSEC_CONFIG_AUTO
62206 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
62207 + help
62208 + If you say Y here, tasks started prior to init will be exempted from
62209 + grsecurity's chroot restrictions. This option is mainly meant to
62210 + resolve Plymouth's performing privileged operations unnecessarily
62211 + in a chroot.
62212 +
62213 +endmenu
62214 +menu "Kernel Auditing"
62215 +depends on GRKERNSEC
62216 +
62217 +config GRKERNSEC_AUDIT_GROUP
62218 + bool "Single group for auditing"
62219 + help
62220 + If you say Y here, the exec and chdir logging features will only operate
62221 + on a group you specify. This option is recommended if you only want to
62222 + watch certain users instead of having a large amount of logs from the
62223 + entire system. If the sysctl option is enabled, a sysctl option with
62224 + name "audit_group" is created.
62225 +
62226 +config GRKERNSEC_AUDIT_GID
62227 + int "GID for auditing"
62228 + depends on GRKERNSEC_AUDIT_GROUP
62229 + default 1007
62230 +
62231 +config GRKERNSEC_EXECLOG
62232 + bool "Exec logging"
62233 + help
62234 + If you say Y here, all execve() calls will be logged (since the
62235 + other exec*() calls are frontends to execve(), all execution
62236 + will be logged). Useful for shell-servers that like to keep track
62237 + of their users. If the sysctl option is enabled, a sysctl option with
62238 + name "exec_logging" is created.
62239 + WARNING: This option when enabled will produce a LOT of logs, especially
62240 + on an active system.
62241 +
62242 +config GRKERNSEC_RESLOG
62243 + bool "Resource logging"
62244 + default y if GRKERNSEC_CONFIG_AUTO
62245 + help
62246 + If you say Y here, all attempts to overstep resource limits will
62247 + be logged with the resource name, the requested size, and the current
62248 + limit. It is highly recommended that you say Y here. If the sysctl
62249 + option is enabled, a sysctl option with name "resource_logging" is
62250 + created. If the RBAC system is enabled, the sysctl value is ignored.
62251 +
62252 +config GRKERNSEC_CHROOT_EXECLOG
62253 + bool "Log execs within chroot"
62254 + help
62255 + If you say Y here, all executions inside a chroot jail will be logged
62256 + to syslog. This can cause a large amount of logs if certain
62257 + applications (eg. djb's daemontools) are installed on the system, and
62258 + is therefore left as an option. If the sysctl option is enabled, a
62259 + sysctl option with name "chroot_execlog" is created.
62260 +
62261 +config GRKERNSEC_AUDIT_PTRACE
62262 + bool "Ptrace logging"
62263 + help
62264 + If you say Y here, all attempts to attach to a process via ptrace
62265 + will be logged. If the sysctl option is enabled, a sysctl option
62266 + with name "audit_ptrace" is created.
62267 +
62268 +config GRKERNSEC_AUDIT_CHDIR
62269 + bool "Chdir logging"
62270 + help
62271 + If you say Y here, all chdir() calls will be logged. If the sysctl
62272 + option is enabled, a sysctl option with name "audit_chdir" is created.
62273 +
62274 +config GRKERNSEC_AUDIT_MOUNT
62275 + bool "(Un)Mount logging"
62276 + help
62277 + If you say Y here, all mounts and unmounts will be logged. If the
62278 + sysctl option is enabled, a sysctl option with name "audit_mount" is
62279 + created.
62280 +
62281 +config GRKERNSEC_SIGNAL
62282 + bool "Signal logging"
62283 + default y if GRKERNSEC_CONFIG_AUTO
62284 + help
62285 + If you say Y here, certain important signals will be logged, such as
62286 + SIGSEGV, which will as a result inform you of when a error in a program
62287 + occurred, which in some cases could mean a possible exploit attempt.
62288 + If the sysctl option is enabled, a sysctl option with name
62289 + "signal_logging" is created.
62290 +
62291 +config GRKERNSEC_FORKFAIL
62292 + bool "Fork failure logging"
62293 + help
62294 + If you say Y here, all failed fork() attempts will be logged.
62295 + This could suggest a fork bomb, or someone attempting to overstep
62296 + their process limit. If the sysctl option is enabled, a sysctl option
62297 + with name "forkfail_logging" is created.
62298 +
62299 +config GRKERNSEC_TIME
62300 + bool "Time change logging"
62301 + default y if GRKERNSEC_CONFIG_AUTO
62302 + help
62303 + If you say Y here, any changes of the system clock will be logged.
62304 + If the sysctl option is enabled, a sysctl option with name
62305 + "timechange_logging" is created.
62306 +
62307 +config GRKERNSEC_PROC_IPADDR
62308 + bool "/proc/<pid>/ipaddr support"
62309 + default y if GRKERNSEC_CONFIG_AUTO
62310 + help
62311 + If you say Y here, a new entry will be added to each /proc/<pid>
62312 + directory that contains the IP address of the person using the task.
62313 + The IP is carried across local TCP and AF_UNIX stream sockets.
62314 + This information can be useful for IDS/IPSes to perform remote response
62315 + to a local attack. The entry is readable by only the owner of the
62316 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
62317 + the RBAC system), and thus does not create privacy concerns.
62318 +
62319 +config GRKERNSEC_RWXMAP_LOG
62320 + bool 'Denied RWX mmap/mprotect logging'
62321 + default y if GRKERNSEC_CONFIG_AUTO
62322 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
62323 + help
62324 + If you say Y here, calls to mmap() and mprotect() with explicit
62325 + usage of PROT_WRITE and PROT_EXEC together will be logged when
62326 + denied by the PAX_MPROTECT feature. This feature will also
62327 + log other problematic scenarios that can occur when PAX_MPROTECT
62328 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
62329 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
62330 + is created.
62331 +
62332 +endmenu
62333 +
62334 +menu "Executable Protections"
62335 +depends on GRKERNSEC
62336 +
62337 +config GRKERNSEC_DMESG
62338 + bool "Dmesg(8) restriction"
62339 + default y if GRKERNSEC_CONFIG_AUTO
62340 + help
62341 + If you say Y here, non-root users will not be able to use dmesg(8)
62342 + to view the contents of the kernel's circular log buffer.
62343 + The kernel's log buffer often contains kernel addresses and other
62344 + identifying information useful to an attacker in fingerprinting a
62345 + system for a targeted exploit.
62346 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
62347 + created.
62348 +
62349 +config GRKERNSEC_HARDEN_PTRACE
62350 + bool "Deter ptrace-based process snooping"
62351 + default y if GRKERNSEC_CONFIG_AUTO
62352 + help
62353 + If you say Y here, TTY sniffers and other malicious monitoring
62354 + programs implemented through ptrace will be defeated. If you
62355 + have been using the RBAC system, this option has already been
62356 + enabled for several years for all users, with the ability to make
62357 + fine-grained exceptions.
62358 +
62359 + This option only affects the ability of non-root users to ptrace
62360 + processes that are not a descendent of the ptracing process.
62361 + This means that strace ./binary and gdb ./binary will still work,
62362 + but attaching to arbitrary processes will not. If the sysctl
62363 + option is enabled, a sysctl option with name "harden_ptrace" is
62364 + created.
62365 +
62366 +config GRKERNSEC_PTRACE_READEXEC
62367 + bool "Require read access to ptrace sensitive binaries"
62368 + default y if GRKERNSEC_CONFIG_AUTO
62369 + help
62370 + If you say Y here, unprivileged users will not be able to ptrace unreadable
62371 + binaries. This option is useful in environments that
62372 + remove the read bits (e.g. file mode 4711) from suid binaries to
62373 + prevent infoleaking of their contents. This option adds
62374 + consistency to the use of that file mode, as the binary could normally
62375 + be read out when run without privileges while ptracing.
62376 +
62377 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
62378 + is created.
62379 +
62380 +config GRKERNSEC_SETXID
62381 + bool "Enforce consistent multithreaded privileges"
62382 + default y if GRKERNSEC_CONFIG_AUTO
62383 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
62384 + help
62385 + If you say Y here, a change from a root uid to a non-root uid
62386 + in a multithreaded application will cause the resulting uids,
62387 + gids, supplementary groups, and capabilities in that thread
62388 + to be propagated to the other threads of the process. In most
62389 + cases this is unnecessary, as glibc will emulate this behavior
62390 + on behalf of the application. Other libcs do not act in the
62391 + same way, allowing the other threads of the process to continue
62392 + running with root privileges. If the sysctl option is enabled,
62393 + a sysctl option with name "consistent_setxid" is created.
62394 +
62395 +config GRKERNSEC_HARDEN_IPC
62396 + bool "Disallow access to world-accessible IPC objects"
62397 + default y if GRKERNSEC_CONFIG_AUTO
62398 + depends on SYSVIPC
62399 + help
62400 + If you say Y here, access to overly-permissive IPC (shared memory,
62401 + message queues, and semaphores) will be denied for processes whose
62402 + effective user or group would not grant them permission. It's a
62403 + common error to grant too much permission to these objects, with
62404 + impact ranging from denial of service and information leaking to
62405 + privilege escalation. This feature was developed in response to
62406 + research by Tim Brown:
62407 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
62408 + who found hundreds of such insecure usages. Processes with
62409 + CAP_IPC_OWNER are still permitted to access these IPC objects.
62410 + If the sysctl option is enabled, a sysctl option with name
62411 + "harden_ipc" is created.
62412 +
62413 +config GRKERNSEC_TPE
62414 + bool "Trusted Path Execution (TPE)"
62415 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62416 + help
62417 + If you say Y here, you will be able to choose a gid to add to the
62418 + supplementary groups of users you want to mark as "untrusted."
62419 + These users will not be able to execute any files that are not in
62420 + root-owned directories writable only by root. If the sysctl option
62421 + is enabled, a sysctl option with name "tpe" is created.
62422 +
62423 +config GRKERNSEC_TPE_ALL
62424 + bool "Partially restrict all non-root users"
62425 + depends on GRKERNSEC_TPE
62426 + help
62427 + If you say Y here, all non-root users will be covered under
62428 + a weaker TPE restriction. This is separate from, and in addition to,
62429 + the main TPE options that you have selected elsewhere. Thus, if a
62430 + "trusted" GID is chosen, this restriction applies to even that GID.
62431 + Under this restriction, all non-root users will only be allowed to
62432 + execute files in directories they own that are not group or
62433 + world-writable, or in directories owned by root and writable only by
62434 + root. If the sysctl option is enabled, a sysctl option with name
62435 + "tpe_restrict_all" is created.
62436 +
62437 +config GRKERNSEC_TPE_INVERT
62438 + bool "Invert GID option"
62439 + depends on GRKERNSEC_TPE
62440 + help
62441 + If you say Y here, the group you specify in the TPE configuration will
62442 + decide what group TPE restrictions will be *disabled* for. This
62443 + option is useful if you want TPE restrictions to be applied to most
62444 + users on the system. If the sysctl option is enabled, a sysctl option
62445 + with name "tpe_invert" is created. Unlike other sysctl options, this
62446 + entry will default to on for backward-compatibility.
62447 +
62448 +config GRKERNSEC_TPE_GID
62449 + int
62450 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
62451 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
62452 +
62453 +config GRKERNSEC_TPE_UNTRUSTED_GID
62454 + int "GID for TPE-untrusted users"
62455 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
62456 + default 1005
62457 + help
62458 + Setting this GID determines what group TPE restrictions will be
62459 + *enabled* for. If the sysctl option is enabled, a sysctl option
62460 + with name "tpe_gid" is created.
62461 +
62462 +config GRKERNSEC_TPE_TRUSTED_GID
62463 + int "GID for TPE-trusted users"
62464 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
62465 + default 1005
62466 + help
62467 + Setting this GID determines what group TPE restrictions will be
62468 + *disabled* for. If the sysctl option is enabled, a sysctl option
62469 + with name "tpe_gid" is created.
62470 +
62471 +endmenu
62472 +menu "Network Protections"
62473 +depends on GRKERNSEC
62474 +
62475 +config GRKERNSEC_RANDNET
62476 + bool "Larger entropy pools"
62477 + default y if GRKERNSEC_CONFIG_AUTO
62478 + help
62479 + If you say Y here, the entropy pools used for many features of Linux
62480 + and grsecurity will be doubled in size. Since several grsecurity
62481 + features use additional randomness, it is recommended that you say Y
62482 + here. Saying Y here has a similar effect as modifying
62483 + /proc/sys/kernel/random/poolsize.
62484 +
62485 +config GRKERNSEC_BLACKHOLE
62486 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
62487 + default y if GRKERNSEC_CONFIG_AUTO
62488 + depends on NET
62489 + help
62490 + If you say Y here, neither TCP resets nor ICMP
62491 + destination-unreachable packets will be sent in response to packets
62492 + sent to ports for which no associated listening process exists.
62493 + This feature supports both IPV4 and IPV6 and exempts the
62494 + loopback interface from blackholing. Enabling this feature
62495 + makes a host more resilient to DoS attacks and reduces network
62496 + visibility against scanners.
62497 +
62498 + The blackhole feature as-implemented is equivalent to the FreeBSD
62499 + blackhole feature, as it prevents RST responses to all packets, not
62500 + just SYNs. Under most application behavior this causes no
62501 + problems, but applications (like haproxy) may not close certain
62502 + connections in a way that cleanly terminates them on the remote
62503 + end, leaving the remote host in LAST_ACK state. Because of this
62504 + side-effect and to prevent intentional LAST_ACK DoSes, this
62505 + feature also adds automatic mitigation against such attacks.
62506 + The mitigation drastically reduces the amount of time a socket
62507 + can spend in LAST_ACK state. If you're using haproxy and not
62508 + all servers it connects to have this option enabled, consider
62509 + disabling this feature on the haproxy host.
62510 +
62511 + If the sysctl option is enabled, two sysctl options with names
62512 + "ip_blackhole" and "lastack_retries" will be created.
62513 + While "ip_blackhole" takes the standard zero/non-zero on/off
62514 + toggle, "lastack_retries" uses the same kinds of values as
62515 + "tcp_retries1" and "tcp_retries2". The default value of 4
62516 + prevents a socket from lasting more than 45 seconds in LAST_ACK
62517 + state.
62518 +
62519 +config GRKERNSEC_NO_SIMULT_CONNECT
62520 + bool "Disable TCP Simultaneous Connect"
62521 + default y if GRKERNSEC_CONFIG_AUTO
62522 + depends on NET
62523 + help
62524 + If you say Y here, a feature by Willy Tarreau will be enabled that
62525 + removes a weakness in Linux's strict implementation of TCP that
62526 + allows two clients to connect to each other without either entering
62527 + a listening state. The weakness allows an attacker to easily prevent
62528 + a client from connecting to a known server provided the source port
62529 + for the connection is guessed correctly.
62530 +
62531 + As the weakness could be used to prevent an antivirus or IPS from
62532 + fetching updates, or prevent an SSL gateway from fetching a CRL,
62533 + it should be eliminated by enabling this option. Though Linux is
62534 + one of few operating systems supporting simultaneous connect, it
62535 + has no legitimate use in practice and is rarely supported by firewalls.
62536 +
62537 +config GRKERNSEC_SOCKET
62538 + bool "Socket restrictions"
62539 + depends on NET
62540 + help
62541 + If you say Y here, you will be able to choose from several options.
62542 + If you assign a GID on your system and add it to the supplementary
62543 + groups of users you want to restrict socket access to, this patch
62544 + will perform up to three things, based on the option(s) you choose.
62545 +
62546 +config GRKERNSEC_SOCKET_ALL
62547 + bool "Deny any sockets to group"
62548 + depends on GRKERNSEC_SOCKET
62549 + help
62550 + If you say Y here, you will be able to choose a GID of whose users will
62551 + be unable to connect to other hosts from your machine or run server
62552 + applications from your machine. If the sysctl option is enabled, a
62553 + sysctl option with name "socket_all" is created.
62554 +
62555 +config GRKERNSEC_SOCKET_ALL_GID
62556 + int "GID to deny all sockets for"
62557 + depends on GRKERNSEC_SOCKET_ALL
62558 + default 1004
62559 + help
62560 + Here you can choose the GID to disable socket access for. Remember to
62561 + add the users you want socket access disabled for to the GID
62562 + specified here. If the sysctl option is enabled, a sysctl option
62563 + with name "socket_all_gid" is created.
62564 +
62565 +config GRKERNSEC_SOCKET_CLIENT
62566 + bool "Deny client sockets to group"
62567 + depends on GRKERNSEC_SOCKET
62568 + help
62569 + If you say Y here, you will be able to choose a GID of whose users will
62570 + be unable to connect to other hosts from your machine, but will be
62571 + able to run servers. If this option is enabled, all users in the group
62572 + you specify will have to use passive mode when initiating ftp transfers
62573 + from the shell on your machine. If the sysctl option is enabled, a
62574 + sysctl option with name "socket_client" is created.
62575 +
62576 +config GRKERNSEC_SOCKET_CLIENT_GID
62577 + int "GID to deny client sockets for"
62578 + depends on GRKERNSEC_SOCKET_CLIENT
62579 + default 1003
62580 + help
62581 + Here you can choose the GID to disable client socket access for.
62582 + Remember to add the users you want client socket access disabled for to
62583 + the GID specified here. If the sysctl option is enabled, a sysctl
62584 + option with name "socket_client_gid" is created.
62585 +
62586 +config GRKERNSEC_SOCKET_SERVER
62587 + bool "Deny server sockets to group"
62588 + depends on GRKERNSEC_SOCKET
62589 + help
62590 + If you say Y here, you will be able to choose a GID of whose users will
62591 + be unable to run server applications from your machine. If the sysctl
62592 + option is enabled, a sysctl option with name "socket_server" is created.
62593 +
62594 +config GRKERNSEC_SOCKET_SERVER_GID
62595 + int "GID to deny server sockets for"
62596 + depends on GRKERNSEC_SOCKET_SERVER
62597 + default 1002
62598 + help
62599 + Here you can choose the GID to disable server socket access for.
62600 + Remember to add the users you want server socket access disabled for to
62601 + the GID specified here. If the sysctl option is enabled, a sysctl
62602 + option with name "socket_server_gid" is created.
62603 +
62604 +endmenu
62605 +
62606 +menu "Physical Protections"
62607 +depends on GRKERNSEC
62608 +
62609 +config GRKERNSEC_DENYUSB
62610 + bool "Deny new USB connections after toggle"
62611 + default y if GRKERNSEC_CONFIG_AUTO
62612 + depends on SYSCTL && USB_SUPPORT
62613 + help
62614 + If you say Y here, a new sysctl option with name "deny_new_usb"
62615 + will be created. Setting its value to 1 will prevent any new
62616 + USB devices from being recognized by the OS. Any attempted USB
62617 + device insertion will be logged. This option is intended to be
62618 + used against custom USB devices designed to exploit vulnerabilities
62619 + in various USB device drivers.
62620 +
62621 + For greatest effectiveness, this sysctl should be set after any
62622 + relevant init scripts. This option is safe to enable in distros
62623 + as each user can choose whether or not to toggle the sysctl.
62624 +
62625 +config GRKERNSEC_DENYUSB_FORCE
62626 + bool "Reject all USB devices not connected at boot"
62627 + select USB
62628 + depends on GRKERNSEC_DENYUSB
62629 + help
62630 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62631 + that doesn't involve a sysctl entry. This option should only be
62632 + enabled if you're sure you want to deny all new USB connections
62633 + at runtime and don't want to modify init scripts. This should not
62634 + be enabled by distros. It forces the core USB code to be built
62635 + into the kernel image so that all devices connected at boot time
62636 + can be recognized and new USB device connections can be prevented
62637 + prior to init running.
62638 +
62639 +endmenu
62640 +
62641 +menu "Sysctl Support"
62642 +depends on GRKERNSEC && SYSCTL
62643 +
62644 +config GRKERNSEC_SYSCTL
62645 + bool "Sysctl support"
62646 + default y if GRKERNSEC_CONFIG_AUTO
62647 + help
62648 + If you say Y here, you will be able to change the options that
62649 + grsecurity runs with at bootup, without having to recompile your
62650 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62651 + to enable (1) or disable (0) various features. All the sysctl entries
62652 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62653 + All features enabled in the kernel configuration are disabled at boot
62654 + if you do not say Y to the "Turn on features by default" option.
62655 + All options should be set at startup, and the grsec_lock entry should
62656 + be set to a non-zero value after all the options are set.
62657 + *THIS IS EXTREMELY IMPORTANT*
62658 +
62659 +config GRKERNSEC_SYSCTL_DISTRO
62660 + bool "Extra sysctl support for distro makers (READ HELP)"
62661 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62662 + help
62663 + If you say Y here, additional sysctl options will be created
62664 + for features that affect processes running as root. Therefore,
62665 + it is critical when using this option that the grsec_lock entry be
62666 + enabled after boot. Only distros with prebuilt kernel packages
62667 + with this option enabled that can ensure grsec_lock is enabled
62668 + after boot should use this option.
62669 + *Failure to set grsec_lock after boot makes all grsec features
62670 + this option covers useless*
62671 +
62672 + Currently this option creates the following sysctl entries:
62673 + "Disable Privileged I/O": "disable_priv_io"
62674 +
62675 +config GRKERNSEC_SYSCTL_ON
62676 + bool "Turn on features by default"
62677 + default y if GRKERNSEC_CONFIG_AUTO
62678 + depends on GRKERNSEC_SYSCTL
62679 + help
62680 + If you say Y here, instead of having all features enabled in the
62681 + kernel configuration disabled at boot time, the features will be
62682 + enabled at boot time. It is recommended you say Y here unless
62683 + there is some reason you would want all sysctl-tunable features to
62684 + be disabled by default. As mentioned elsewhere, it is important
62685 + to enable the grsec_lock entry once you have finished modifying
62686 + the sysctl entries.
62687 +
62688 +endmenu
62689 +menu "Logging Options"
62690 +depends on GRKERNSEC
62691 +
62692 +config GRKERNSEC_FLOODTIME
62693 + int "Seconds in between log messages (minimum)"
62694 + default 10
62695 + help
62696 + This option allows you to enforce the number of seconds between
62697 + grsecurity log messages. The default should be suitable for most
62698 + people, however, if you choose to change it, choose a value small enough
62699 + to allow informative logs to be produced, but large enough to
62700 + prevent flooding.
62701 +
62702 +config GRKERNSEC_FLOODBURST
62703 + int "Number of messages in a burst (maximum)"
62704 + default 6
62705 + help
62706 + This option allows you to choose the maximum number of messages allowed
62707 + within the flood time interval you chose in a separate option. The
62708 + default should be suitable for most people, however if you find that
62709 + many of your logs are being interpreted as flooding, you may want to
62710 + raise this value.
62711 +
62712 +endmenu
62713 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62714 new file mode 100644
62715 index 0000000..85beb79
62716 --- /dev/null
62717 +++ b/grsecurity/Makefile
62718 @@ -0,0 +1,43 @@
62719 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62720 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62721 +# into an RBAC system
62722 +#
62723 +# All code in this directory and various hooks inserted throughout the kernel
62724 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62725 +# under the GPL v2 or higher
62726 +
62727 +KBUILD_CFLAGS += -Werror
62728 +
62729 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62730 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62731 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62732 + grsec_usb.o grsec_ipc.o
62733 +
62734 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62735 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62736 + gracl_learn.o grsec_log.o gracl_policy.o
62737 +ifdef CONFIG_COMPAT
62738 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62739 +endif
62740 +
62741 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62742 +
62743 +ifdef CONFIG_NET
62744 +obj-y += grsec_sock.o
62745 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62746 +endif
62747 +
62748 +ifndef CONFIG_GRKERNSEC
62749 +obj-y += grsec_disabled.o
62750 +endif
62751 +
62752 +ifdef CONFIG_GRKERNSEC_HIDESYM
62753 +extra-y := grsec_hidesym.o
62754 +$(obj)/grsec_hidesym.o:
62755 + @-chmod -f 500 /boot
62756 + @-chmod -f 500 /lib/modules
62757 + @-chmod -f 500 /lib64/modules
62758 + @-chmod -f 500 /lib32/modules
62759 + @-chmod -f 700 .
62760 + @echo ' grsec: protected kernel image paths'
62761 +endif
62762 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62763 new file mode 100644
62764 index 0000000..857c960
62765 --- /dev/null
62766 +++ b/grsecurity/gracl.c
62767 @@ -0,0 +1,2623 @@
62768 +#include <linux/kernel.h>
62769 +#include <linux/module.h>
62770 +#include <linux/sched.h>
62771 +#include <linux/mm.h>
62772 +#include <linux/file.h>
62773 +#include <linux/fs.h>
62774 +#include <linux/namei.h>
62775 +#include <linux/mount.h>
62776 +#include <linux/tty.h>
62777 +#include <linux/proc_fs.h>
62778 +#include <linux/lglock.h>
62779 +#include <linux/slab.h>
62780 +#include <linux/vmalloc.h>
62781 +#include <linux/types.h>
62782 +#include <linux/sysctl.h>
62783 +#include <linux/netdevice.h>
62784 +#include <linux/ptrace.h>
62785 +#include <linux/gracl.h>
62786 +#include <linux/gralloc.h>
62787 +#include <linux/security.h>
62788 +#include <linux/grinternal.h>
62789 +#include <linux/pid_namespace.h>
62790 +#include <linux/stop_machine.h>
62791 +#include <linux/fdtable.h>
62792 +#include <linux/percpu.h>
62793 +#include <linux/lglock.h>
62794 +#include <linux/hugetlb.h>
62795 +#include <linux/posix-timers.h>
62796 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62797 +#include <linux/magic.h>
62798 +#include <linux/pagemap.h>
62799 +#include "../fs/btrfs/async-thread.h"
62800 +#include "../fs/btrfs/ctree.h"
62801 +#include "../fs/btrfs/btrfs_inode.h"
62802 +#endif
62803 +#include "../fs/mount.h"
62804 +
62805 +#include <asm/uaccess.h>
62806 +#include <asm/errno.h>
62807 +#include <asm/mman.h>
62808 +
62809 +#define FOR_EACH_ROLE_START(role) \
62810 + role = running_polstate.role_list; \
62811 + while (role) {
62812 +
62813 +#define FOR_EACH_ROLE_END(role) \
62814 + role = role->prev; \
62815 + }
62816 +
62817 +extern struct lglock vfsmount_lock;
62818 +
62819 +extern struct path gr_real_root;
62820 +
62821 +static struct gr_policy_state running_polstate;
62822 +struct gr_policy_state *polstate = &running_polstate;
62823 +extern struct gr_alloc_state *current_alloc_state;
62824 +
62825 +extern char *gr_shared_page[4];
62826 +DEFINE_RWLOCK(gr_inode_lock);
62827 +
62828 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62829 +
62830 +#ifdef CONFIG_NET
62831 +extern struct vfsmount *sock_mnt;
62832 +#endif
62833 +
62834 +extern struct vfsmount *pipe_mnt;
62835 +extern struct vfsmount *shm_mnt;
62836 +
62837 +#ifdef CONFIG_HUGETLBFS
62838 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62839 +#endif
62840 +
62841 +extern u16 acl_sp_role_value;
62842 +extern struct acl_object_label *fakefs_obj_rw;
62843 +extern struct acl_object_label *fakefs_obj_rwx;
62844 +
62845 +int gr_acl_is_enabled(void)
62846 +{
62847 + return (gr_status & GR_READY);
62848 +}
62849 +
62850 +void gr_enable_rbac_system(void)
62851 +{
62852 + pax_open_kernel();
62853 + gr_status |= GR_READY;
62854 + pax_close_kernel();
62855 +}
62856 +
62857 +int gr_rbac_disable(void *unused)
62858 +{
62859 + pax_open_kernel();
62860 + gr_status &= ~GR_READY;
62861 + pax_close_kernel();
62862 +
62863 + return 0;
62864 +}
62865 +
62866 +static inline dev_t __get_dev(const struct dentry *dentry)
62867 +{
62868 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62869 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62870 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62871 + else
62872 +#endif
62873 + return dentry->d_sb->s_dev;
62874 +}
62875 +
62876 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62877 +{
62878 + return __get_dev(dentry);
62879 +}
62880 +
62881 +static char gr_task_roletype_to_char(struct task_struct *task)
62882 +{
62883 + switch (task->role->roletype &
62884 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62885 + GR_ROLE_SPECIAL)) {
62886 + case GR_ROLE_DEFAULT:
62887 + return 'D';
62888 + case GR_ROLE_USER:
62889 + return 'U';
62890 + case GR_ROLE_GROUP:
62891 + return 'G';
62892 + case GR_ROLE_SPECIAL:
62893 + return 'S';
62894 + }
62895 +
62896 + return 'X';
62897 +}
62898 +
62899 +char gr_roletype_to_char(void)
62900 +{
62901 + return gr_task_roletype_to_char(current);
62902 +}
62903 +
62904 +__inline__ int
62905 +gr_acl_tpe_check(void)
62906 +{
62907 + if (unlikely(!(gr_status & GR_READY)))
62908 + return 0;
62909 + if (current->role->roletype & GR_ROLE_TPE)
62910 + return 1;
62911 + else
62912 + return 0;
62913 +}
62914 +
62915 +int
62916 +gr_handle_rawio(const struct inode *inode)
62917 +{
62918 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62919 + if (inode && S_ISBLK(inode->i_mode) &&
62920 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62921 + !capable(CAP_SYS_RAWIO))
62922 + return 1;
62923 +#endif
62924 + return 0;
62925 +}
62926 +
62927 +int
62928 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62929 +{
62930 + if (likely(lena != lenb))
62931 + return 0;
62932 +
62933 + return !memcmp(a, b, lena);
62934 +}
62935 +
62936 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62937 +{
62938 + *buflen -= namelen;
62939 + if (*buflen < 0)
62940 + return -ENAMETOOLONG;
62941 + *buffer -= namelen;
62942 + memcpy(*buffer, str, namelen);
62943 + return 0;
62944 +}
62945 +
62946 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62947 +{
62948 + return prepend(buffer, buflen, name->name, name->len);
62949 +}
62950 +
62951 +static int prepend_path(const struct path *path, struct path *root,
62952 + char **buffer, int *buflen)
62953 +{
62954 + struct dentry *dentry = path->dentry;
62955 + struct vfsmount *vfsmnt = path->mnt;
62956 + struct mount *mnt = real_mount(vfsmnt);
62957 + bool slash = false;
62958 + int error = 0;
62959 +
62960 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62961 + struct dentry * parent;
62962 +
62963 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62964 + /* Global root? */
62965 + if (!mnt_has_parent(mnt)) {
62966 + goto out;
62967 + }
62968 + dentry = mnt->mnt_mountpoint;
62969 + mnt = mnt->mnt_parent;
62970 + vfsmnt = &mnt->mnt;
62971 + continue;
62972 + }
62973 + parent = dentry->d_parent;
62974 + prefetch(parent);
62975 + spin_lock(&dentry->d_lock);
62976 + error = prepend_name(buffer, buflen, &dentry->d_name);
62977 + spin_unlock(&dentry->d_lock);
62978 + if (!error)
62979 + error = prepend(buffer, buflen, "/", 1);
62980 + if (error)
62981 + break;
62982 +
62983 + slash = true;
62984 + dentry = parent;
62985 + }
62986 +
62987 +out:
62988 + if (!error && !slash)
62989 + error = prepend(buffer, buflen, "/", 1);
62990 +
62991 + return error;
62992 +}
62993 +
62994 +/* this must be called with vfsmount_lock and rename_lock held */
62995 +
62996 +static char *__our_d_path(const struct path *path, struct path *root,
62997 + char *buf, int buflen)
62998 +{
62999 + char *res = buf + buflen;
63000 + int error;
63001 +
63002 + prepend(&res, &buflen, "\0", 1);
63003 + error = prepend_path(path, root, &res, &buflen);
63004 + if (error)
63005 + return ERR_PTR(error);
63006 +
63007 + return res;
63008 +}
63009 +
63010 +static char *
63011 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
63012 +{
63013 + char *retval;
63014 +
63015 + retval = __our_d_path(path, root, buf, buflen);
63016 + if (unlikely(IS_ERR(retval)))
63017 + retval = strcpy(buf, "<path too long>");
63018 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
63019 + retval[1] = '\0';
63020 +
63021 + return retval;
63022 +}
63023 +
63024 +static char *
63025 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63026 + char *buf, int buflen)
63027 +{
63028 + struct path path;
63029 + char *res;
63030 +
63031 + path.dentry = (struct dentry *)dentry;
63032 + path.mnt = (struct vfsmount *)vfsmnt;
63033 +
63034 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
63035 + by the RBAC system */
63036 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
63037 +
63038 + return res;
63039 +}
63040 +
63041 +static char *
63042 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63043 + char *buf, int buflen)
63044 +{
63045 + char *res;
63046 + struct path path;
63047 + struct path root;
63048 + struct task_struct *reaper = init_pid_ns.child_reaper;
63049 +
63050 + path.dentry = (struct dentry *)dentry;
63051 + path.mnt = (struct vfsmount *)vfsmnt;
63052 +
63053 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
63054 + get_fs_root(reaper->fs, &root);
63055 +
63056 + br_read_lock(&vfsmount_lock);
63057 + write_seqlock(&rename_lock);
63058 + res = gen_full_path(&path, &root, buf, buflen);
63059 + write_sequnlock(&rename_lock);
63060 + br_read_unlock(&vfsmount_lock);
63061 +
63062 + path_put(&root);
63063 + return res;
63064 +}
63065 +
63066 +char *
63067 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63068 +{
63069 + char *ret;
63070 + br_read_lock(&vfsmount_lock);
63071 + write_seqlock(&rename_lock);
63072 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63073 + PAGE_SIZE);
63074 + write_sequnlock(&rename_lock);
63075 + br_read_unlock(&vfsmount_lock);
63076 + return ret;
63077 +}
63078 +
63079 +static char *
63080 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63081 +{
63082 + char *ret;
63083 + char *buf;
63084 + int buflen;
63085 +
63086 + br_read_lock(&vfsmount_lock);
63087 + write_seqlock(&rename_lock);
63088 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
63089 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
63090 + buflen = (int)(ret - buf);
63091 + if (buflen >= 5)
63092 + prepend(&ret, &buflen, "/proc", 5);
63093 + else
63094 + ret = strcpy(buf, "<path too long>");
63095 + write_sequnlock(&rename_lock);
63096 + br_read_unlock(&vfsmount_lock);
63097 + return ret;
63098 +}
63099 +
63100 +char *
63101 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
63102 +{
63103 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63104 + PAGE_SIZE);
63105 +}
63106 +
63107 +char *
63108 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
63109 +{
63110 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
63111 + PAGE_SIZE);
63112 +}
63113 +
63114 +char *
63115 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
63116 +{
63117 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
63118 + PAGE_SIZE);
63119 +}
63120 +
63121 +char *
63122 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
63123 +{
63124 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
63125 + PAGE_SIZE);
63126 +}
63127 +
63128 +char *
63129 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
63130 +{
63131 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
63132 + PAGE_SIZE);
63133 +}
63134 +
63135 +__inline__ __u32
63136 +to_gr_audit(const __u32 reqmode)
63137 +{
63138 + /* masks off auditable permission flags, then shifts them to create
63139 + auditing flags, and adds the special case of append auditing if
63140 + we're requesting write */
63141 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
63142 +}
63143 +
63144 +struct acl_role_label *
63145 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
63146 + const gid_t gid)
63147 +{
63148 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
63149 + struct acl_role_label *match;
63150 + struct role_allowed_ip *ipp;
63151 + unsigned int x;
63152 + u32 curr_ip = task->signal->saved_ip;
63153 +
63154 + match = state->acl_role_set.r_hash[index];
63155 +
63156 + while (match) {
63157 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
63158 + for (x = 0; x < match->domain_child_num; x++) {
63159 + if (match->domain_children[x] == uid)
63160 + goto found;
63161 + }
63162 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
63163 + break;
63164 + match = match->next;
63165 + }
63166 +found:
63167 + if (match == NULL) {
63168 + try_group:
63169 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
63170 + match = state->acl_role_set.r_hash[index];
63171 +
63172 + while (match) {
63173 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
63174 + for (x = 0; x < match->domain_child_num; x++) {
63175 + if (match->domain_children[x] == gid)
63176 + goto found2;
63177 + }
63178 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
63179 + break;
63180 + match = match->next;
63181 + }
63182 +found2:
63183 + if (match == NULL)
63184 + match = state->default_role;
63185 + if (match->allowed_ips == NULL)
63186 + return match;
63187 + else {
63188 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63189 + if (likely
63190 + ((ntohl(curr_ip) & ipp->netmask) ==
63191 + (ntohl(ipp->addr) & ipp->netmask)))
63192 + return match;
63193 + }
63194 + match = state->default_role;
63195 + }
63196 + } else if (match->allowed_ips == NULL) {
63197 + return match;
63198 + } else {
63199 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63200 + if (likely
63201 + ((ntohl(curr_ip) & ipp->netmask) ==
63202 + (ntohl(ipp->addr) & ipp->netmask)))
63203 + return match;
63204 + }
63205 + goto try_group;
63206 + }
63207 +
63208 + return match;
63209 +}
63210 +
63211 +static struct acl_role_label *
63212 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
63213 + const gid_t gid)
63214 +{
63215 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
63216 +}
63217 +
63218 +struct acl_subject_label *
63219 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
63220 + const struct acl_role_label *role)
63221 +{
63222 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63223 + struct acl_subject_label *match;
63224 +
63225 + match = role->subj_hash[index];
63226 +
63227 + while (match && (match->inode != ino || match->device != dev ||
63228 + (match->mode & GR_DELETED))) {
63229 + match = match->next;
63230 + }
63231 +
63232 + if (match && !(match->mode & GR_DELETED))
63233 + return match;
63234 + else
63235 + return NULL;
63236 +}
63237 +
63238 +struct acl_subject_label *
63239 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
63240 + const struct acl_role_label *role)
63241 +{
63242 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63243 + struct acl_subject_label *match;
63244 +
63245 + match = role->subj_hash[index];
63246 +
63247 + while (match && (match->inode != ino || match->device != dev ||
63248 + !(match->mode & GR_DELETED))) {
63249 + match = match->next;
63250 + }
63251 +
63252 + if (match && (match->mode & GR_DELETED))
63253 + return match;
63254 + else
63255 + return NULL;
63256 +}
63257 +
63258 +static struct acl_object_label *
63259 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
63260 + const struct acl_subject_label *subj)
63261 +{
63262 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63263 + struct acl_object_label *match;
63264 +
63265 + match = subj->obj_hash[index];
63266 +
63267 + while (match && (match->inode != ino || match->device != dev ||
63268 + (match->mode & GR_DELETED))) {
63269 + match = match->next;
63270 + }
63271 +
63272 + if (match && !(match->mode & GR_DELETED))
63273 + return match;
63274 + else
63275 + return NULL;
63276 +}
63277 +
63278 +static struct acl_object_label *
63279 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
63280 + const struct acl_subject_label *subj)
63281 +{
63282 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63283 + struct acl_object_label *match;
63284 +
63285 + match = subj->obj_hash[index];
63286 +
63287 + while (match && (match->inode != ino || match->device != dev ||
63288 + !(match->mode & GR_DELETED))) {
63289 + match = match->next;
63290 + }
63291 +
63292 + if (match && (match->mode & GR_DELETED))
63293 + return match;
63294 +
63295 + match = subj->obj_hash[index];
63296 +
63297 + while (match && (match->inode != ino || match->device != dev ||
63298 + (match->mode & GR_DELETED))) {
63299 + match = match->next;
63300 + }
63301 +
63302 + if (match && !(match->mode & GR_DELETED))
63303 + return match;
63304 + else
63305 + return NULL;
63306 +}
63307 +
63308 +struct name_entry *
63309 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
63310 +{
63311 + unsigned int len = strlen(name);
63312 + unsigned int key = full_name_hash(name, len);
63313 + unsigned int index = key % state->name_set.n_size;
63314 + struct name_entry *match;
63315 +
63316 + match = state->name_set.n_hash[index];
63317 +
63318 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
63319 + match = match->next;
63320 +
63321 + return match;
63322 +}
63323 +
63324 +static struct name_entry *
63325 +lookup_name_entry(const char *name)
63326 +{
63327 + return __lookup_name_entry(&running_polstate, name);
63328 +}
63329 +
63330 +static struct name_entry *
63331 +lookup_name_entry_create(const char *name)
63332 +{
63333 + unsigned int len = strlen(name);
63334 + unsigned int key = full_name_hash(name, len);
63335 + unsigned int index = key % running_polstate.name_set.n_size;
63336 + struct name_entry *match;
63337 +
63338 + match = running_polstate.name_set.n_hash[index];
63339 +
63340 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63341 + !match->deleted))
63342 + match = match->next;
63343 +
63344 + if (match && match->deleted)
63345 + return match;
63346 +
63347 + match = running_polstate.name_set.n_hash[index];
63348 +
63349 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63350 + match->deleted))
63351 + match = match->next;
63352 +
63353 + if (match && !match->deleted)
63354 + return match;
63355 + else
63356 + return NULL;
63357 +}
63358 +
63359 +static struct inodev_entry *
63360 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
63361 +{
63362 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
63363 + struct inodev_entry *match;
63364 +
63365 + match = running_polstate.inodev_set.i_hash[index];
63366 +
63367 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
63368 + match = match->next;
63369 +
63370 + return match;
63371 +}
63372 +
63373 +void
63374 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
63375 +{
63376 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
63377 + state->inodev_set.i_size);
63378 + struct inodev_entry **curr;
63379 +
63380 + entry->prev = NULL;
63381 +
63382 + curr = &state->inodev_set.i_hash[index];
63383 + if (*curr != NULL)
63384 + (*curr)->prev = entry;
63385 +
63386 + entry->next = *curr;
63387 + *curr = entry;
63388 +
63389 + return;
63390 +}
63391 +
63392 +static void
63393 +insert_inodev_entry(struct inodev_entry *entry)
63394 +{
63395 + __insert_inodev_entry(&running_polstate, entry);
63396 +}
63397 +
63398 +void
63399 +insert_acl_obj_label(struct acl_object_label *obj,
63400 + struct acl_subject_label *subj)
63401 +{
63402 + unsigned int index =
63403 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63404 + struct acl_object_label **curr;
63405 +
63406 + obj->prev = NULL;
63407 +
63408 + curr = &subj->obj_hash[index];
63409 + if (*curr != NULL)
63410 + (*curr)->prev = obj;
63411 +
63412 + obj->next = *curr;
63413 + *curr = obj;
63414 +
63415 + return;
63416 +}
63417 +
63418 +void
63419 +insert_acl_subj_label(struct acl_subject_label *obj,
63420 + struct acl_role_label *role)
63421 +{
63422 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63423 + struct acl_subject_label **curr;
63424 +
63425 + obj->prev = NULL;
63426 +
63427 + curr = &role->subj_hash[index];
63428 + if (*curr != NULL)
63429 + (*curr)->prev = obj;
63430 +
63431 + obj->next = *curr;
63432 + *curr = obj;
63433 +
63434 + return;
63435 +}
63436 +
63437 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63438 +
63439 +static int
63440 +glob_match(const char *p, const char *n)
63441 +{
63442 + char c;
63443 +
63444 + while ((c = *p++) != '\0') {
63445 + switch (c) {
63446 + case '?':
63447 + if (*n == '\0')
63448 + return 1;
63449 + else if (*n == '/')
63450 + return 1;
63451 + break;
63452 + case '\\':
63453 + if (*n != c)
63454 + return 1;
63455 + break;
63456 + case '*':
63457 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63458 + if (*n == '/')
63459 + return 1;
63460 + else if (c == '?') {
63461 + if (*n == '\0')
63462 + return 1;
63463 + else
63464 + ++n;
63465 + }
63466 + }
63467 + if (c == '\0') {
63468 + return 0;
63469 + } else {
63470 + const char *endp;
63471 +
63472 + if ((endp = strchr(n, '/')) == NULL)
63473 + endp = n + strlen(n);
63474 +
63475 + if (c == '[') {
63476 + for (--p; n < endp; ++n)
63477 + if (!glob_match(p, n))
63478 + return 0;
63479 + } else if (c == '/') {
63480 + while (*n != '\0' && *n != '/')
63481 + ++n;
63482 + if (*n == '/' && !glob_match(p, n + 1))
63483 + return 0;
63484 + } else {
63485 + for (--p; n < endp; ++n)
63486 + if (*n == c && !glob_match(p, n))
63487 + return 0;
63488 + }
63489 +
63490 + return 1;
63491 + }
63492 + case '[':
63493 + {
63494 + int not;
63495 + char cold;
63496 +
63497 + if (*n == '\0' || *n == '/')
63498 + return 1;
63499 +
63500 + not = (*p == '!' || *p == '^');
63501 + if (not)
63502 + ++p;
63503 +
63504 + c = *p++;
63505 + for (;;) {
63506 + unsigned char fn = (unsigned char)*n;
63507 +
63508 + if (c == '\0')
63509 + return 1;
63510 + else {
63511 + if (c == fn)
63512 + goto matched;
63513 + cold = c;
63514 + c = *p++;
63515 +
63516 + if (c == '-' && *p != ']') {
63517 + unsigned char cend = *p++;
63518 +
63519 + if (cend == '\0')
63520 + return 1;
63521 +
63522 + if (cold <= fn && fn <= cend)
63523 + goto matched;
63524 +
63525 + c = *p++;
63526 + }
63527 + }
63528 +
63529 + if (c == ']')
63530 + break;
63531 + }
63532 + if (!not)
63533 + return 1;
63534 + break;
63535 + matched:
63536 + while (c != ']') {
63537 + if (c == '\0')
63538 + return 1;
63539 +
63540 + c = *p++;
63541 + }
63542 + if (not)
63543 + return 1;
63544 + }
63545 + break;
63546 + default:
63547 + if (c != *n)
63548 + return 1;
63549 + }
63550 +
63551 + ++n;
63552 + }
63553 +
63554 + if (*n == '\0')
63555 + return 0;
63556 +
63557 + if (*n == '/')
63558 + return 0;
63559 +
63560 + return 1;
63561 +}
63562 +
63563 +static struct acl_object_label *
63564 +chk_glob_label(struct acl_object_label *globbed,
63565 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
63566 +{
63567 + struct acl_object_label *tmp;
63568 +
63569 + if (*path == NULL)
63570 + *path = gr_to_filename_nolock(dentry, mnt);
63571 +
63572 + tmp = globbed;
63573 +
63574 + while (tmp) {
63575 + if (!glob_match(tmp->filename, *path))
63576 + return tmp;
63577 + tmp = tmp->next;
63578 + }
63579 +
63580 + return NULL;
63581 +}
63582 +
63583 +static struct acl_object_label *
63584 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63585 + const ino_t curr_ino, const dev_t curr_dev,
63586 + const struct acl_subject_label *subj, char **path, const int checkglob)
63587 +{
63588 + struct acl_subject_label *tmpsubj;
63589 + struct acl_object_label *retval;
63590 + struct acl_object_label *retval2;
63591 +
63592 + tmpsubj = (struct acl_subject_label *) subj;
63593 + read_lock(&gr_inode_lock);
63594 + do {
63595 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
63596 + if (retval) {
63597 + if (checkglob && retval->globbed) {
63598 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
63599 + if (retval2)
63600 + retval = retval2;
63601 + }
63602 + break;
63603 + }
63604 + } while ((tmpsubj = tmpsubj->parent_subject));
63605 + read_unlock(&gr_inode_lock);
63606 +
63607 + return retval;
63608 +}
63609 +
63610 +static __inline__ struct acl_object_label *
63611 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63612 + struct dentry *curr_dentry,
63613 + const struct acl_subject_label *subj, char **path, const int checkglob)
63614 +{
63615 + int newglob = checkglob;
63616 + ino_t inode;
63617 + dev_t device;
63618 +
63619 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
63620 + as we don't want a / * rule to match instead of the / object
63621 + don't do this for create lookups that call this function though, since they're looking up
63622 + on the parent and thus need globbing checks on all paths
63623 + */
63624 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
63625 + newglob = GR_NO_GLOB;
63626 +
63627 + spin_lock(&curr_dentry->d_lock);
63628 + inode = curr_dentry->d_inode->i_ino;
63629 + device = __get_dev(curr_dentry);
63630 + spin_unlock(&curr_dentry->d_lock);
63631 +
63632 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
63633 +}
63634 +
63635 +#ifdef CONFIG_HUGETLBFS
63636 +static inline bool
63637 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
63638 +{
63639 + int i;
63640 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
63641 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
63642 + return true;
63643 + }
63644 +
63645 + return false;
63646 +}
63647 +#endif
63648 +
63649 +static struct acl_object_label *
63650 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63651 + const struct acl_subject_label *subj, char *path, const int checkglob)
63652 +{
63653 + struct dentry *dentry = (struct dentry *) l_dentry;
63654 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63655 + struct mount *real_mnt = real_mount(mnt);
63656 + struct acl_object_label *retval;
63657 + struct dentry *parent;
63658 +
63659 + br_read_lock(&vfsmount_lock);
63660 + write_seqlock(&rename_lock);
63661 +
63662 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
63663 +#ifdef CONFIG_NET
63664 + mnt == sock_mnt ||
63665 +#endif
63666 +#ifdef CONFIG_HUGETLBFS
63667 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
63668 +#endif
63669 + /* ignore Eric Biederman */
63670 + IS_PRIVATE(l_dentry->d_inode))) {
63671 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
63672 + goto out;
63673 + }
63674 +
63675 + for (;;) {
63676 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63677 + break;
63678 +
63679 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63680 + if (!mnt_has_parent(real_mnt))
63681 + break;
63682 +
63683 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63684 + if (retval != NULL)
63685 + goto out;
63686 +
63687 + dentry = real_mnt->mnt_mountpoint;
63688 + real_mnt = real_mnt->mnt_parent;
63689 + mnt = &real_mnt->mnt;
63690 + continue;
63691 + }
63692 +
63693 + parent = dentry->d_parent;
63694 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63695 + if (retval != NULL)
63696 + goto out;
63697 +
63698 + dentry = parent;
63699 + }
63700 +
63701 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63702 +
63703 + /* gr_real_root is pinned so we don't have to hold a reference */
63704 + if (retval == NULL)
63705 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
63706 +out:
63707 + write_sequnlock(&rename_lock);
63708 + br_read_unlock(&vfsmount_lock);
63709 +
63710 + BUG_ON(retval == NULL);
63711 +
63712 + return retval;
63713 +}
63714 +
63715 +static __inline__ struct acl_object_label *
63716 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63717 + const struct acl_subject_label *subj)
63718 +{
63719 + char *path = NULL;
63720 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
63721 +}
63722 +
63723 +static __inline__ struct acl_object_label *
63724 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63725 + const struct acl_subject_label *subj)
63726 +{
63727 + char *path = NULL;
63728 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
63729 +}
63730 +
63731 +static __inline__ struct acl_object_label *
63732 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63733 + const struct acl_subject_label *subj, char *path)
63734 +{
63735 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
63736 +}
63737 +
63738 +struct acl_subject_label *
63739 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63740 + const struct acl_role_label *role)
63741 +{
63742 + struct dentry *dentry = (struct dentry *) l_dentry;
63743 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63744 + struct mount *real_mnt = real_mount(mnt);
63745 + struct acl_subject_label *retval;
63746 + struct dentry *parent;
63747 +
63748 + br_read_lock(&vfsmount_lock);
63749 + write_seqlock(&rename_lock);
63750 +
63751 + for (;;) {
63752 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63753 + break;
63754 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63755 + if (!mnt_has_parent(real_mnt))
63756 + break;
63757 +
63758 + spin_lock(&dentry->d_lock);
63759 + read_lock(&gr_inode_lock);
63760 + retval =
63761 + lookup_acl_subj_label(dentry->d_inode->i_ino,
63762 + __get_dev(dentry), role);
63763 + read_unlock(&gr_inode_lock);
63764 + spin_unlock(&dentry->d_lock);
63765 + if (retval != NULL)
63766 + goto out;
63767 +
63768 + dentry = real_mnt->mnt_mountpoint;
63769 + real_mnt = real_mnt->mnt_parent;
63770 + mnt = &real_mnt->mnt;
63771 + continue;
63772 + }
63773 +
63774 + spin_lock(&dentry->d_lock);
63775 + read_lock(&gr_inode_lock);
63776 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63777 + __get_dev(dentry), role);
63778 + read_unlock(&gr_inode_lock);
63779 + parent = dentry->d_parent;
63780 + spin_unlock(&dentry->d_lock);
63781 +
63782 + if (retval != NULL)
63783 + goto out;
63784 +
63785 + dentry = parent;
63786 + }
63787 +
63788 + spin_lock(&dentry->d_lock);
63789 + read_lock(&gr_inode_lock);
63790 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63791 + __get_dev(dentry), role);
63792 + read_unlock(&gr_inode_lock);
63793 + spin_unlock(&dentry->d_lock);
63794 +
63795 + if (unlikely(retval == NULL)) {
63796 + /* gr_real_root is pinned, we don't need to hold a reference */
63797 + read_lock(&gr_inode_lock);
63798 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
63799 + __get_dev(gr_real_root.dentry), role);
63800 + read_unlock(&gr_inode_lock);
63801 + }
63802 +out:
63803 + write_sequnlock(&rename_lock);
63804 + br_read_unlock(&vfsmount_lock);
63805 +
63806 + BUG_ON(retval == NULL);
63807 +
63808 + return retval;
63809 +}
63810 +
63811 +void
63812 +assign_special_role(const char *rolename)
63813 +{
63814 + struct acl_object_label *obj;
63815 + struct acl_role_label *r;
63816 + struct acl_role_label *assigned = NULL;
63817 + struct task_struct *tsk;
63818 + struct file *filp;
63819 +
63820 + FOR_EACH_ROLE_START(r)
63821 + if (!strcmp(rolename, r->rolename) &&
63822 + (r->roletype & GR_ROLE_SPECIAL)) {
63823 + assigned = r;
63824 + break;
63825 + }
63826 + FOR_EACH_ROLE_END(r)
63827 +
63828 + if (!assigned)
63829 + return;
63830 +
63831 + read_lock(&tasklist_lock);
63832 + read_lock(&grsec_exec_file_lock);
63833 +
63834 + tsk = current->real_parent;
63835 + if (tsk == NULL)
63836 + goto out_unlock;
63837 +
63838 + filp = tsk->exec_file;
63839 + if (filp == NULL)
63840 + goto out_unlock;
63841 +
63842 + tsk->is_writable = 0;
63843 + tsk->inherited = 0;
63844 +
63845 + tsk->acl_sp_role = 1;
63846 + tsk->acl_role_id = ++acl_sp_role_value;
63847 + tsk->role = assigned;
63848 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
63849 +
63850 + /* ignore additional mmap checks for processes that are writable
63851 + by the default ACL */
63852 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
63853 + if (unlikely(obj->mode & GR_WRITE))
63854 + tsk->is_writable = 1;
63855 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
63856 + if (unlikely(obj->mode & GR_WRITE))
63857 + tsk->is_writable = 1;
63858 +
63859 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63860 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
63861 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
63862 +#endif
63863 +
63864 +out_unlock:
63865 + read_unlock(&grsec_exec_file_lock);
63866 + read_unlock(&tasklist_lock);
63867 + return;
63868 +}
63869 +
63870 +
63871 +static void
63872 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
63873 +{
63874 + struct task_struct *task = current;
63875 + const struct cred *cred = current_cred();
63876 +
63877 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
63878 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63879 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63880 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
63881 +
63882 + return;
63883 +}
63884 +
63885 +static void
63886 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
63887 +{
63888 + struct task_struct *task = current;
63889 + const struct cred *cred = current_cred();
63890 +
63891 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63892 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63893 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63894 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
63895 +
63896 + return;
63897 +}
63898 +
63899 +static void
63900 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
63901 +{
63902 + struct task_struct *task = current;
63903 + const struct cred *cred = current_cred();
63904 +
63905 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63906 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63907 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63908 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
63909 +
63910 + return;
63911 +}
63912 +
63913 +static void
63914 +gr_set_proc_res(struct task_struct *task)
63915 +{
63916 + struct acl_subject_label *proc;
63917 + unsigned short i;
63918 +
63919 + proc = task->acl;
63920 +
63921 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
63922 + return;
63923 +
63924 + for (i = 0; i < RLIM_NLIMITS; i++) {
63925 + if (!(proc->resmask & (1U << i)))
63926 + continue;
63927 +
63928 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
63929 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
63930 +
63931 + if (i == RLIMIT_CPU)
63932 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
63933 + }
63934 +
63935 + return;
63936 +}
63937 +
63938 +/* both of the below must be called with
63939 + rcu_read_lock();
63940 + read_lock(&tasklist_lock);
63941 + read_lock(&grsec_exec_file_lock);
63942 +*/
63943 +
63944 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
63945 +{
63946 + struct acl_object_label *obj;
63947 + struct file *filp;
63948 +
63949 + filp = task->exec_file;
63950 +
63951 + task->acl = subj;
63952 + task->is_writable = 0;
63953 + /* ignore additional mmap checks for processes that are writable
63954 + by the default ACL */
63955 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
63956 + if (unlikely(obj->mode & GR_WRITE))
63957 + task->is_writable = 1;
63958 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
63959 + if (unlikely(obj->mode & GR_WRITE))
63960 + task->is_writable = 1;
63961 +
63962 + gr_set_proc_res(task);
63963 +
63964 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63965 + 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);
63966 +#endif
63967 +}
63968 +
63969 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
63970 +{
63971 + __gr_apply_subject_to_task(&running_polstate, task, subj);
63972 +}
63973 +
63974 +__u32
63975 +gr_search_file(const struct dentry * dentry, const __u32 mode,
63976 + const struct vfsmount * mnt)
63977 +{
63978 + __u32 retval = mode;
63979 + struct acl_subject_label *curracl;
63980 + struct acl_object_label *currobj;
63981 +
63982 + if (unlikely(!(gr_status & GR_READY)))
63983 + return (mode & ~GR_AUDITS);
63984 +
63985 + curracl = current->acl;
63986 +
63987 + currobj = chk_obj_label(dentry, mnt, curracl);
63988 + retval = currobj->mode & mode;
63989 +
63990 + /* if we're opening a specified transfer file for writing
63991 + (e.g. /dev/initctl), then transfer our role to init
63992 + */
63993 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
63994 + current->role->roletype & GR_ROLE_PERSIST)) {
63995 + struct task_struct *task = init_pid_ns.child_reaper;
63996 +
63997 + if (task->role != current->role) {
63998 + task->acl_sp_role = 0;
63999 + task->acl_role_id = current->acl_role_id;
64000 + task->role = current->role;
64001 + rcu_read_lock();
64002 + read_lock(&grsec_exec_file_lock);
64003 + gr_apply_subject_to_task(task, NULL);
64004 + read_unlock(&grsec_exec_file_lock);
64005 + rcu_read_unlock();
64006 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64007 + }
64008 + }
64009 +
64010 + if (unlikely
64011 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64012 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64013 + __u32 new_mode = mode;
64014 +
64015 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64016 +
64017 + retval = new_mode;
64018 +
64019 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64020 + new_mode |= GR_INHERIT;
64021 +
64022 + if (!(mode & GR_NOLEARN))
64023 + gr_log_learn(dentry, mnt, new_mode);
64024 + }
64025 +
64026 + return retval;
64027 +}
64028 +
64029 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64030 + const struct dentry *parent,
64031 + const struct vfsmount *mnt)
64032 +{
64033 + struct name_entry *match;
64034 + struct acl_object_label *matchpo;
64035 + struct acl_subject_label *curracl;
64036 + char *path;
64037 +
64038 + if (unlikely(!(gr_status & GR_READY)))
64039 + return NULL;
64040 +
64041 + preempt_disable();
64042 + path = gr_to_filename_rbac(new_dentry, mnt);
64043 + match = lookup_name_entry_create(path);
64044 +
64045 + curracl = current->acl;
64046 +
64047 + if (match) {
64048 + read_lock(&gr_inode_lock);
64049 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64050 + read_unlock(&gr_inode_lock);
64051 +
64052 + if (matchpo) {
64053 + preempt_enable();
64054 + return matchpo;
64055 + }
64056 + }
64057 +
64058 + // lookup parent
64059 +
64060 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64061 +
64062 + preempt_enable();
64063 + return matchpo;
64064 +}
64065 +
64066 +__u32
64067 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64068 + const struct vfsmount * mnt, const __u32 mode)
64069 +{
64070 + struct acl_object_label *matchpo;
64071 + __u32 retval;
64072 +
64073 + if (unlikely(!(gr_status & GR_READY)))
64074 + return (mode & ~GR_AUDITS);
64075 +
64076 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64077 +
64078 + retval = matchpo->mode & mode;
64079 +
64080 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64081 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64082 + __u32 new_mode = mode;
64083 +
64084 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64085 +
64086 + gr_log_learn(new_dentry, mnt, new_mode);
64087 + return new_mode;
64088 + }
64089 +
64090 + return retval;
64091 +}
64092 +
64093 +__u32
64094 +gr_check_link(const struct dentry * new_dentry,
64095 + const struct dentry * parent_dentry,
64096 + const struct vfsmount * parent_mnt,
64097 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64098 +{
64099 + struct acl_object_label *obj;
64100 + __u32 oldmode, newmode;
64101 + __u32 needmode;
64102 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64103 + GR_DELETE | GR_INHERIT;
64104 +
64105 + if (unlikely(!(gr_status & GR_READY)))
64106 + return (GR_CREATE | GR_LINK);
64107 +
64108 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64109 + oldmode = obj->mode;
64110 +
64111 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64112 + newmode = obj->mode;
64113 +
64114 + needmode = newmode & checkmodes;
64115 +
64116 + // old name for hardlink must have at least the permissions of the new name
64117 + if ((oldmode & needmode) != needmode)
64118 + goto bad;
64119 +
64120 + // if old name had restrictions/auditing, make sure the new name does as well
64121 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64122 +
64123 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64124 + if (is_privileged_binary(old_dentry))
64125 + needmode |= GR_SETID;
64126 +
64127 + if ((newmode & needmode) != needmode)
64128 + goto bad;
64129 +
64130 + // enforce minimum permissions
64131 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64132 + return newmode;
64133 +bad:
64134 + needmode = oldmode;
64135 + if (is_privileged_binary(old_dentry))
64136 + needmode |= GR_SETID;
64137 +
64138 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64139 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64140 + return (GR_CREATE | GR_LINK);
64141 + } else if (newmode & GR_SUPPRESS)
64142 + return GR_SUPPRESS;
64143 + else
64144 + return 0;
64145 +}
64146 +
64147 +int
64148 +gr_check_hidden_task(const struct task_struct *task)
64149 +{
64150 + if (unlikely(!(gr_status & GR_READY)))
64151 + return 0;
64152 +
64153 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64154 + return 1;
64155 +
64156 + return 0;
64157 +}
64158 +
64159 +int
64160 +gr_check_protected_task(const struct task_struct *task)
64161 +{
64162 + if (unlikely(!(gr_status & GR_READY) || !task))
64163 + return 0;
64164 +
64165 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64166 + task->acl != current->acl)
64167 + return 1;
64168 +
64169 + return 0;
64170 +}
64171 +
64172 +int
64173 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64174 +{
64175 + struct task_struct *p;
64176 + int ret = 0;
64177 +
64178 + if (unlikely(!(gr_status & GR_READY) || !pid))
64179 + return ret;
64180 +
64181 + read_lock(&tasklist_lock);
64182 + do_each_pid_task(pid, type, p) {
64183 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64184 + p->acl != current->acl) {
64185 + ret = 1;
64186 + goto out;
64187 + }
64188 + } while_each_pid_task(pid, type, p);
64189 +out:
64190 + read_unlock(&tasklist_lock);
64191 +
64192 + return ret;
64193 +}
64194 +
64195 +void
64196 +gr_copy_label(struct task_struct *tsk)
64197 +{
64198 + struct task_struct *p = current;
64199 +
64200 + tsk->inherited = p->inherited;
64201 + tsk->acl_sp_role = 0;
64202 + tsk->acl_role_id = p->acl_role_id;
64203 + tsk->acl = p->acl;
64204 + tsk->role = p->role;
64205 + tsk->signal->used_accept = 0;
64206 + tsk->signal->curr_ip = p->signal->curr_ip;
64207 + tsk->signal->saved_ip = p->signal->saved_ip;
64208 + if (p->exec_file)
64209 + get_file(p->exec_file);
64210 + tsk->exec_file = p->exec_file;
64211 + tsk->is_writable = p->is_writable;
64212 + if (unlikely(p->signal->used_accept)) {
64213 + p->signal->curr_ip = 0;
64214 + p->signal->saved_ip = 0;
64215 + }
64216 +
64217 + return;
64218 +}
64219 +
64220 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64221 +
64222 +int
64223 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64224 +{
64225 + unsigned int i;
64226 + __u16 num;
64227 + uid_t *uidlist;
64228 + uid_t curuid;
64229 + int realok = 0;
64230 + int effectiveok = 0;
64231 + int fsok = 0;
64232 + uid_t globalreal, globaleffective, globalfs;
64233 +
64234 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64235 + struct user_struct *user;
64236 +
64237 + if (!uid_valid(real))
64238 + goto skipit;
64239 +
64240 + /* find user based on global namespace */
64241 +
64242 + globalreal = GR_GLOBAL_UID(real);
64243 +
64244 + user = find_user(make_kuid(&init_user_ns, globalreal));
64245 + if (user == NULL)
64246 + goto skipit;
64247 +
64248 + if (gr_process_kernel_setuid_ban(user)) {
64249 + /* for find_user */
64250 + free_uid(user);
64251 + return 1;
64252 + }
64253 +
64254 + /* for find_user */
64255 + free_uid(user);
64256 +
64257 +skipit:
64258 +#endif
64259 +
64260 + if (unlikely(!(gr_status & GR_READY)))
64261 + return 0;
64262 +
64263 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64264 + gr_log_learn_uid_change(real, effective, fs);
64265 +
64266 + num = current->acl->user_trans_num;
64267 + uidlist = current->acl->user_transitions;
64268 +
64269 + if (uidlist == NULL)
64270 + return 0;
64271 +
64272 + if (!uid_valid(real)) {
64273 + realok = 1;
64274 + globalreal = (uid_t)-1;
64275 + } else {
64276 + globalreal = GR_GLOBAL_UID(real);
64277 + }
64278 + if (!uid_valid(effective)) {
64279 + effectiveok = 1;
64280 + globaleffective = (uid_t)-1;
64281 + } else {
64282 + globaleffective = GR_GLOBAL_UID(effective);
64283 + }
64284 + if (!uid_valid(fs)) {
64285 + fsok = 1;
64286 + globalfs = (uid_t)-1;
64287 + } else {
64288 + globalfs = GR_GLOBAL_UID(fs);
64289 + }
64290 +
64291 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64292 + for (i = 0; i < num; i++) {
64293 + curuid = uidlist[i];
64294 + if (globalreal == curuid)
64295 + realok = 1;
64296 + if (globaleffective == curuid)
64297 + effectiveok = 1;
64298 + if (globalfs == curuid)
64299 + fsok = 1;
64300 + }
64301 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64302 + for (i = 0; i < num; i++) {
64303 + curuid = uidlist[i];
64304 + if (globalreal == curuid)
64305 + break;
64306 + if (globaleffective == curuid)
64307 + break;
64308 + if (globalfs == curuid)
64309 + break;
64310 + }
64311 + /* not in deny list */
64312 + if (i == num) {
64313 + realok = 1;
64314 + effectiveok = 1;
64315 + fsok = 1;
64316 + }
64317 + }
64318 +
64319 + if (realok && effectiveok && fsok)
64320 + return 0;
64321 + else {
64322 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64323 + return 1;
64324 + }
64325 +}
64326 +
64327 +int
64328 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64329 +{
64330 + unsigned int i;
64331 + __u16 num;
64332 + gid_t *gidlist;
64333 + gid_t curgid;
64334 + int realok = 0;
64335 + int effectiveok = 0;
64336 + int fsok = 0;
64337 + gid_t globalreal, globaleffective, globalfs;
64338 +
64339 + if (unlikely(!(gr_status & GR_READY)))
64340 + return 0;
64341 +
64342 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64343 + gr_log_learn_gid_change(real, effective, fs);
64344 +
64345 + num = current->acl->group_trans_num;
64346 + gidlist = current->acl->group_transitions;
64347 +
64348 + if (gidlist == NULL)
64349 + return 0;
64350 +
64351 + if (!gid_valid(real)) {
64352 + realok = 1;
64353 + globalreal = (gid_t)-1;
64354 + } else {
64355 + globalreal = GR_GLOBAL_GID(real);
64356 + }
64357 + if (!gid_valid(effective)) {
64358 + effectiveok = 1;
64359 + globaleffective = (gid_t)-1;
64360 + } else {
64361 + globaleffective = GR_GLOBAL_GID(effective);
64362 + }
64363 + if (!gid_valid(fs)) {
64364 + fsok = 1;
64365 + globalfs = (gid_t)-1;
64366 + } else {
64367 + globalfs = GR_GLOBAL_GID(fs);
64368 + }
64369 +
64370 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64371 + for (i = 0; i < num; i++) {
64372 + curgid = gidlist[i];
64373 + if (globalreal == curgid)
64374 + realok = 1;
64375 + if (globaleffective == curgid)
64376 + effectiveok = 1;
64377 + if (globalfs == curgid)
64378 + fsok = 1;
64379 + }
64380 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64381 + for (i = 0; i < num; i++) {
64382 + curgid = gidlist[i];
64383 + if (globalreal == curgid)
64384 + break;
64385 + if (globaleffective == curgid)
64386 + break;
64387 + if (globalfs == curgid)
64388 + break;
64389 + }
64390 + /* not in deny list */
64391 + if (i == num) {
64392 + realok = 1;
64393 + effectiveok = 1;
64394 + fsok = 1;
64395 + }
64396 + }
64397 +
64398 + if (realok && effectiveok && fsok)
64399 + return 0;
64400 + else {
64401 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64402 + return 1;
64403 + }
64404 +}
64405 +
64406 +extern int gr_acl_is_capable(const int cap);
64407 +
64408 +void
64409 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64410 +{
64411 + struct acl_role_label *role = task->role;
64412 + struct acl_subject_label *subj = NULL;
64413 + struct acl_object_label *obj;
64414 + struct file *filp;
64415 + uid_t uid;
64416 + gid_t gid;
64417 +
64418 + if (unlikely(!(gr_status & GR_READY)))
64419 + return;
64420 +
64421 + uid = GR_GLOBAL_UID(kuid);
64422 + gid = GR_GLOBAL_GID(kgid);
64423 +
64424 + filp = task->exec_file;
64425 +
64426 + /* kernel process, we'll give them the kernel role */
64427 + if (unlikely(!filp)) {
64428 + task->role = running_polstate.kernel_role;
64429 + task->acl = running_polstate.kernel_role->root_label;
64430 + return;
64431 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
64432 + /* save the current ip at time of role lookup so that the proper
64433 + IP will be learned for role_allowed_ip */
64434 + task->signal->saved_ip = task->signal->curr_ip;
64435 + role = lookup_acl_role_label(task, uid, gid);
64436 + }
64437 +
64438 + /* don't change the role if we're not a privileged process */
64439 + if (role && task->role != role &&
64440 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64441 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64442 + return;
64443 +
64444 + /* perform subject lookup in possibly new role
64445 + we can use this result below in the case where role == task->role
64446 + */
64447 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64448 +
64449 + /* if we changed uid/gid, but result in the same role
64450 + and are using inheritance, don't lose the inherited subject
64451 + if current subject is other than what normal lookup
64452 + would result in, we arrived via inheritance, don't
64453 + lose subject
64454 + */
64455 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64456 + (subj == task->acl)))
64457 + task->acl = subj;
64458 +
64459 + /* leave task->inherited unaffected */
64460 +
64461 + task->role = role;
64462 +
64463 + task->is_writable = 0;
64464 +
64465 + /* ignore additional mmap checks for processes that are writable
64466 + by the default ACL */
64467 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
64468 + if (unlikely(obj->mode & GR_WRITE))
64469 + task->is_writable = 1;
64470 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64471 + if (unlikely(obj->mode & GR_WRITE))
64472 + task->is_writable = 1;
64473 +
64474 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64475 + 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);
64476 +#endif
64477 +
64478 + gr_set_proc_res(task);
64479 +
64480 + return;
64481 +}
64482 +
64483 +int
64484 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64485 + const int unsafe_flags)
64486 +{
64487 + struct task_struct *task = current;
64488 + struct acl_subject_label *newacl;
64489 + struct acl_object_label *obj;
64490 + __u32 retmode;
64491 +
64492 + if (unlikely(!(gr_status & GR_READY)))
64493 + return 0;
64494 +
64495 + newacl = chk_subj_label(dentry, mnt, task->role);
64496 +
64497 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64498 + did an exec
64499 + */
64500 + rcu_read_lock();
64501 + read_lock(&tasklist_lock);
64502 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64503 + (task->parent->acl->mode & GR_POVERRIDE))) {
64504 + read_unlock(&tasklist_lock);
64505 + rcu_read_unlock();
64506 + goto skip_check;
64507 + }
64508 + read_unlock(&tasklist_lock);
64509 + rcu_read_unlock();
64510 +
64511 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64512 + !(task->role->roletype & GR_ROLE_GOD) &&
64513 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64514 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64515 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64516 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64517 + else
64518 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64519 + return -EACCES;
64520 + }
64521 +
64522 +skip_check:
64523 +
64524 + obj = chk_obj_label(dentry, mnt, task->acl);
64525 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64526 +
64527 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64528 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64529 + if (obj->nested)
64530 + task->acl = obj->nested;
64531 + else
64532 + task->acl = newacl;
64533 + task->inherited = 0;
64534 + } else {
64535 + task->inherited = 1;
64536 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64537 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64538 + }
64539 +
64540 + task->is_writable = 0;
64541 +
64542 + /* ignore additional mmap checks for processes that are writable
64543 + by the default ACL */
64544 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
64545 + if (unlikely(obj->mode & GR_WRITE))
64546 + task->is_writable = 1;
64547 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64548 + if (unlikely(obj->mode & GR_WRITE))
64549 + task->is_writable = 1;
64550 +
64551 + gr_set_proc_res(task);
64552 +
64553 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64554 + 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);
64555 +#endif
64556 + return 0;
64557 +}
64558 +
64559 +/* always called with valid inodev ptr */
64560 +static void
64561 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64562 +{
64563 + struct acl_object_label *matchpo;
64564 + struct acl_subject_label *matchps;
64565 + struct acl_subject_label *subj;
64566 + struct acl_role_label *role;
64567 + unsigned int x;
64568 +
64569 + FOR_EACH_ROLE_START(role)
64570 + FOR_EACH_SUBJECT_START(role, subj, x)
64571 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64572 + matchpo->mode |= GR_DELETED;
64573 + FOR_EACH_SUBJECT_END(subj,x)
64574 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64575 + /* nested subjects aren't in the role's subj_hash table */
64576 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64577 + matchpo->mode |= GR_DELETED;
64578 + FOR_EACH_NESTED_SUBJECT_END(subj)
64579 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64580 + matchps->mode |= GR_DELETED;
64581 + FOR_EACH_ROLE_END(role)
64582 +
64583 + inodev->nentry->deleted = 1;
64584 +
64585 + return;
64586 +}
64587 +
64588 +void
64589 +gr_handle_delete(const ino_t ino, const dev_t dev)
64590 +{
64591 + struct inodev_entry *inodev;
64592 +
64593 + if (unlikely(!(gr_status & GR_READY)))
64594 + return;
64595 +
64596 + write_lock(&gr_inode_lock);
64597 + inodev = lookup_inodev_entry(ino, dev);
64598 + if (inodev != NULL)
64599 + do_handle_delete(inodev, ino, dev);
64600 + write_unlock(&gr_inode_lock);
64601 +
64602 + return;
64603 +}
64604 +
64605 +static void
64606 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64607 + const ino_t newinode, const dev_t newdevice,
64608 + struct acl_subject_label *subj)
64609 +{
64610 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64611 + struct acl_object_label *match;
64612 +
64613 + match = subj->obj_hash[index];
64614 +
64615 + while (match && (match->inode != oldinode ||
64616 + match->device != olddevice ||
64617 + !(match->mode & GR_DELETED)))
64618 + match = match->next;
64619 +
64620 + if (match && (match->inode == oldinode)
64621 + && (match->device == olddevice)
64622 + && (match->mode & GR_DELETED)) {
64623 + if (match->prev == NULL) {
64624 + subj->obj_hash[index] = match->next;
64625 + if (match->next != NULL)
64626 + match->next->prev = NULL;
64627 + } else {
64628 + match->prev->next = match->next;
64629 + if (match->next != NULL)
64630 + match->next->prev = match->prev;
64631 + }
64632 + match->prev = NULL;
64633 + match->next = NULL;
64634 + match->inode = newinode;
64635 + match->device = newdevice;
64636 + match->mode &= ~GR_DELETED;
64637 +
64638 + insert_acl_obj_label(match, subj);
64639 + }
64640 +
64641 + return;
64642 +}
64643 +
64644 +static void
64645 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
64646 + const ino_t newinode, const dev_t newdevice,
64647 + struct acl_role_label *role)
64648 +{
64649 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
64650 + struct acl_subject_label *match;
64651 +
64652 + match = role->subj_hash[index];
64653 +
64654 + while (match && (match->inode != oldinode ||
64655 + match->device != olddevice ||
64656 + !(match->mode & GR_DELETED)))
64657 + match = match->next;
64658 +
64659 + if (match && (match->inode == oldinode)
64660 + && (match->device == olddevice)
64661 + && (match->mode & GR_DELETED)) {
64662 + if (match->prev == NULL) {
64663 + role->subj_hash[index] = match->next;
64664 + if (match->next != NULL)
64665 + match->next->prev = NULL;
64666 + } else {
64667 + match->prev->next = match->next;
64668 + if (match->next != NULL)
64669 + match->next->prev = match->prev;
64670 + }
64671 + match->prev = NULL;
64672 + match->next = NULL;
64673 + match->inode = newinode;
64674 + match->device = newdevice;
64675 + match->mode &= ~GR_DELETED;
64676 +
64677 + insert_acl_subj_label(match, role);
64678 + }
64679 +
64680 + return;
64681 +}
64682 +
64683 +static void
64684 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
64685 + const ino_t newinode, const dev_t newdevice)
64686 +{
64687 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
64688 + struct inodev_entry *match;
64689 +
64690 + match = running_polstate.inodev_set.i_hash[index];
64691 +
64692 + while (match && (match->nentry->inode != oldinode ||
64693 + match->nentry->device != olddevice || !match->nentry->deleted))
64694 + match = match->next;
64695 +
64696 + if (match && (match->nentry->inode == oldinode)
64697 + && (match->nentry->device == olddevice) &&
64698 + match->nentry->deleted) {
64699 + if (match->prev == NULL) {
64700 + running_polstate.inodev_set.i_hash[index] = match->next;
64701 + if (match->next != NULL)
64702 + match->next->prev = NULL;
64703 + } else {
64704 + match->prev->next = match->next;
64705 + if (match->next != NULL)
64706 + match->next->prev = match->prev;
64707 + }
64708 + match->prev = NULL;
64709 + match->next = NULL;
64710 + match->nentry->inode = newinode;
64711 + match->nentry->device = newdevice;
64712 + match->nentry->deleted = 0;
64713 +
64714 + insert_inodev_entry(match);
64715 + }
64716 +
64717 + return;
64718 +}
64719 +
64720 +static void
64721 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
64722 +{
64723 + struct acl_subject_label *subj;
64724 + struct acl_role_label *role;
64725 + unsigned int x;
64726 +
64727 + FOR_EACH_ROLE_START(role)
64728 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
64729 +
64730 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64731 + if ((subj->inode == ino) && (subj->device == dev)) {
64732 + subj->inode = ino;
64733 + subj->device = dev;
64734 + }
64735 + /* nested subjects aren't in the role's subj_hash table */
64736 + update_acl_obj_label(matchn->inode, matchn->device,
64737 + ino, dev, subj);
64738 + FOR_EACH_NESTED_SUBJECT_END(subj)
64739 + FOR_EACH_SUBJECT_START(role, subj, x)
64740 + update_acl_obj_label(matchn->inode, matchn->device,
64741 + ino, dev, subj);
64742 + FOR_EACH_SUBJECT_END(subj,x)
64743 + FOR_EACH_ROLE_END(role)
64744 +
64745 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
64746 +
64747 + return;
64748 +}
64749 +
64750 +static void
64751 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
64752 + const struct vfsmount *mnt)
64753 +{
64754 + ino_t ino = dentry->d_inode->i_ino;
64755 + dev_t dev = __get_dev(dentry);
64756 +
64757 + __do_handle_create(matchn, ino, dev);
64758 +
64759 + return;
64760 +}
64761 +
64762 +void
64763 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64764 +{
64765 + struct name_entry *matchn;
64766 +
64767 + if (unlikely(!(gr_status & GR_READY)))
64768 + return;
64769 +
64770 + preempt_disable();
64771 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
64772 +
64773 + if (unlikely((unsigned long)matchn)) {
64774 + write_lock(&gr_inode_lock);
64775 + do_handle_create(matchn, dentry, mnt);
64776 + write_unlock(&gr_inode_lock);
64777 + }
64778 + preempt_enable();
64779 +
64780 + return;
64781 +}
64782 +
64783 +void
64784 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64785 +{
64786 + struct name_entry *matchn;
64787 +
64788 + if (unlikely(!(gr_status & GR_READY)))
64789 + return;
64790 +
64791 + preempt_disable();
64792 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
64793 +
64794 + if (unlikely((unsigned long)matchn)) {
64795 + write_lock(&gr_inode_lock);
64796 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
64797 + write_unlock(&gr_inode_lock);
64798 + }
64799 + preempt_enable();
64800 +
64801 + return;
64802 +}
64803 +
64804 +void
64805 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64806 + struct dentry *old_dentry,
64807 + struct dentry *new_dentry,
64808 + struct vfsmount *mnt, const __u8 replace)
64809 +{
64810 + struct name_entry *matchn;
64811 + struct inodev_entry *inodev;
64812 + struct inode *inode = new_dentry->d_inode;
64813 + ino_t old_ino = old_dentry->d_inode->i_ino;
64814 + dev_t old_dev = __get_dev(old_dentry);
64815 +
64816 + /* vfs_rename swaps the name and parent link for old_dentry and
64817 + new_dentry
64818 + at this point, old_dentry has the new name, parent link, and inode
64819 + for the renamed file
64820 + if a file is being replaced by a rename, new_dentry has the inode
64821 + and name for the replaced file
64822 + */
64823 +
64824 + if (unlikely(!(gr_status & GR_READY)))
64825 + return;
64826 +
64827 + preempt_disable();
64828 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
64829 +
64830 + /* we wouldn't have to check d_inode if it weren't for
64831 + NFS silly-renaming
64832 + */
64833 +
64834 + write_lock(&gr_inode_lock);
64835 + if (unlikely(replace && inode)) {
64836 + ino_t new_ino = inode->i_ino;
64837 + dev_t new_dev = __get_dev(new_dentry);
64838 +
64839 + inodev = lookup_inodev_entry(new_ino, new_dev);
64840 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
64841 + do_handle_delete(inodev, new_ino, new_dev);
64842 + }
64843 +
64844 + inodev = lookup_inodev_entry(old_ino, old_dev);
64845 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
64846 + do_handle_delete(inodev, old_ino, old_dev);
64847 +
64848 + if (unlikely((unsigned long)matchn))
64849 + do_handle_create(matchn, old_dentry, mnt);
64850 +
64851 + write_unlock(&gr_inode_lock);
64852 + preempt_enable();
64853 +
64854 + return;
64855 +}
64856 +
64857 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
64858 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
64859 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
64860 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
64861 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
64862 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
64863 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
64864 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
64865 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
64866 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
64867 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
64868 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
64869 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
64870 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
64871 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
64872 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
64873 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
64874 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
64875 +};
64876 +
64877 +void
64878 +gr_learn_resource(const struct task_struct *task,
64879 + const int res, const unsigned long wanted, const int gt)
64880 +{
64881 + struct acl_subject_label *acl;
64882 + const struct cred *cred;
64883 +
64884 + if (unlikely((gr_status & GR_READY) &&
64885 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
64886 + goto skip_reslog;
64887 +
64888 + gr_log_resource(task, res, wanted, gt);
64889 +skip_reslog:
64890 +
64891 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
64892 + return;
64893 +
64894 + acl = task->acl;
64895 +
64896 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
64897 + !(acl->resmask & (1U << (unsigned short) res))))
64898 + return;
64899 +
64900 + if (wanted >= acl->res[res].rlim_cur) {
64901 + unsigned long res_add;
64902 +
64903 + res_add = wanted + res_learn_bumps[res];
64904 +
64905 + acl->res[res].rlim_cur = res_add;
64906 +
64907 + if (wanted > acl->res[res].rlim_max)
64908 + acl->res[res].rlim_max = res_add;
64909 +
64910 + /* only log the subject filename, since resource logging is supported for
64911 + single-subject learning only */
64912 + rcu_read_lock();
64913 + cred = __task_cred(task);
64914 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
64915 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
64916 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
64917 + "", (unsigned long) res, &task->signal->saved_ip);
64918 + rcu_read_unlock();
64919 + }
64920 +
64921 + return;
64922 +}
64923 +EXPORT_SYMBOL(gr_learn_resource);
64924 +#endif
64925 +
64926 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
64927 +void
64928 +pax_set_initial_flags(struct linux_binprm *bprm)
64929 +{
64930 + struct task_struct *task = current;
64931 + struct acl_subject_label *proc;
64932 + unsigned long flags;
64933 +
64934 + if (unlikely(!(gr_status & GR_READY)))
64935 + return;
64936 +
64937 + flags = pax_get_flags(task);
64938 +
64939 + proc = task->acl;
64940 +
64941 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
64942 + flags &= ~MF_PAX_PAGEEXEC;
64943 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
64944 + flags &= ~MF_PAX_SEGMEXEC;
64945 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
64946 + flags &= ~MF_PAX_RANDMMAP;
64947 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
64948 + flags &= ~MF_PAX_EMUTRAMP;
64949 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
64950 + flags &= ~MF_PAX_MPROTECT;
64951 +
64952 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
64953 + flags |= MF_PAX_PAGEEXEC;
64954 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
64955 + flags |= MF_PAX_SEGMEXEC;
64956 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
64957 + flags |= MF_PAX_RANDMMAP;
64958 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
64959 + flags |= MF_PAX_EMUTRAMP;
64960 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
64961 + flags |= MF_PAX_MPROTECT;
64962 +
64963 + pax_set_flags(task, flags);
64964 +
64965 + return;
64966 +}
64967 +#endif
64968 +
64969 +int
64970 +gr_handle_proc_ptrace(struct task_struct *task)
64971 +{
64972 + struct file *filp;
64973 + struct task_struct *tmp = task;
64974 + struct task_struct *curtemp = current;
64975 + __u32 retmode;
64976 +
64977 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64978 + if (unlikely(!(gr_status & GR_READY)))
64979 + return 0;
64980 +#endif
64981 +
64982 + read_lock(&tasklist_lock);
64983 + read_lock(&grsec_exec_file_lock);
64984 + filp = task->exec_file;
64985 +
64986 + while (task_pid_nr(tmp) > 0) {
64987 + if (tmp == curtemp)
64988 + break;
64989 + tmp = tmp->real_parent;
64990 + }
64991 +
64992 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
64993 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
64994 + read_unlock(&grsec_exec_file_lock);
64995 + read_unlock(&tasklist_lock);
64996 + return 1;
64997 + }
64998 +
64999 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65000 + if (!(gr_status & GR_READY)) {
65001 + read_unlock(&grsec_exec_file_lock);
65002 + read_unlock(&tasklist_lock);
65003 + return 0;
65004 + }
65005 +#endif
65006 +
65007 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65008 + read_unlock(&grsec_exec_file_lock);
65009 + read_unlock(&tasklist_lock);
65010 +
65011 + if (retmode & GR_NOPTRACE)
65012 + return 1;
65013 +
65014 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
65015 + && (current->acl != task->acl || (current->acl != current->role->root_label
65016 + && task_pid_nr(current) != task_pid_nr(task))))
65017 + return 1;
65018 +
65019 + return 0;
65020 +}
65021 +
65022 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
65023 +{
65024 + if (unlikely(!(gr_status & GR_READY)))
65025 + return;
65026 +
65027 + if (!(current->role->roletype & GR_ROLE_GOD))
65028 + return;
65029 +
65030 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65031 + p->role->rolename, gr_task_roletype_to_char(p),
65032 + p->acl->filename);
65033 +}
65034 +
65035 +int
65036 +gr_handle_ptrace(struct task_struct *task, const long request)
65037 +{
65038 + struct task_struct *tmp = task;
65039 + struct task_struct *curtemp = current;
65040 + __u32 retmode;
65041 +
65042 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65043 + if (unlikely(!(gr_status & GR_READY)))
65044 + return 0;
65045 +#endif
65046 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
65047 + read_lock(&tasklist_lock);
65048 + while (task_pid_nr(tmp) > 0) {
65049 + if (tmp == curtemp)
65050 + break;
65051 + tmp = tmp->real_parent;
65052 + }
65053 +
65054 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65055 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
65056 + read_unlock(&tasklist_lock);
65057 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65058 + return 1;
65059 + }
65060 + read_unlock(&tasklist_lock);
65061 + }
65062 +
65063 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65064 + if (!(gr_status & GR_READY))
65065 + return 0;
65066 +#endif
65067 +
65068 + read_lock(&grsec_exec_file_lock);
65069 + if (unlikely(!task->exec_file)) {
65070 + read_unlock(&grsec_exec_file_lock);
65071 + return 0;
65072 + }
65073 +
65074 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
65075 + read_unlock(&grsec_exec_file_lock);
65076 +
65077 + if (retmode & GR_NOPTRACE) {
65078 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65079 + return 1;
65080 + }
65081 +
65082 + if (retmode & GR_PTRACERD) {
65083 + switch (request) {
65084 + case PTRACE_SEIZE:
65085 + case PTRACE_POKETEXT:
65086 + case PTRACE_POKEDATA:
65087 + case PTRACE_POKEUSR:
65088 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
65089 + case PTRACE_SETREGS:
65090 + case PTRACE_SETFPREGS:
65091 +#endif
65092 +#ifdef CONFIG_X86
65093 + case PTRACE_SETFPXREGS:
65094 +#endif
65095 +#ifdef CONFIG_ALTIVEC
65096 + case PTRACE_SETVRREGS:
65097 +#endif
65098 + return 1;
65099 + default:
65100 + return 0;
65101 + }
65102 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
65103 + !(current->role->roletype & GR_ROLE_GOD) &&
65104 + (current->acl != task->acl)) {
65105 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65106 + return 1;
65107 + }
65108 +
65109 + return 0;
65110 +}
65111 +
65112 +static int is_writable_mmap(const struct file *filp)
65113 +{
65114 + struct task_struct *task = current;
65115 + struct acl_object_label *obj, *obj2;
65116 +
65117 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
65118 + !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))) {
65119 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65120 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
65121 + task->role->root_label);
65122 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
65123 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
65124 + return 1;
65125 + }
65126 + }
65127 + return 0;
65128 +}
65129 +
65130 +int
65131 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
65132 +{
65133 + __u32 mode;
65134 +
65135 + if (unlikely(!file || !(prot & PROT_EXEC)))
65136 + return 1;
65137 +
65138 + if (is_writable_mmap(file))
65139 + return 0;
65140 +
65141 + mode =
65142 + gr_search_file(file->f_path.dentry,
65143 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65144 + file->f_path.mnt);
65145 +
65146 + if (!gr_tpe_allow(file))
65147 + return 0;
65148 +
65149 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65150 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65151 + return 0;
65152 + } else if (unlikely(!(mode & GR_EXEC))) {
65153 + return 0;
65154 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65155 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65156 + return 1;
65157 + }
65158 +
65159 + return 1;
65160 +}
65161 +
65162 +int
65163 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65164 +{
65165 + __u32 mode;
65166 +
65167 + if (unlikely(!file || !(prot & PROT_EXEC)))
65168 + return 1;
65169 +
65170 + if (is_writable_mmap(file))
65171 + return 0;
65172 +
65173 + mode =
65174 + gr_search_file(file->f_path.dentry,
65175 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65176 + file->f_path.mnt);
65177 +
65178 + if (!gr_tpe_allow(file))
65179 + return 0;
65180 +
65181 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65182 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65183 + return 0;
65184 + } else if (unlikely(!(mode & GR_EXEC))) {
65185 + return 0;
65186 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65187 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65188 + return 1;
65189 + }
65190 +
65191 + return 1;
65192 +}
65193 +
65194 +void
65195 +gr_acl_handle_psacct(struct task_struct *task, const long code)
65196 +{
65197 + unsigned long runtime;
65198 + unsigned long cputime;
65199 + unsigned int wday, cday;
65200 + __u8 whr, chr;
65201 + __u8 wmin, cmin;
65202 + __u8 wsec, csec;
65203 + struct timespec timeval;
65204 +
65205 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
65206 + !(task->acl->mode & GR_PROCACCT)))
65207 + return;
65208 +
65209 + do_posix_clock_monotonic_gettime(&timeval);
65210 + runtime = timeval.tv_sec - task->start_time.tv_sec;
65211 + wday = runtime / (3600 * 24);
65212 + runtime -= wday * (3600 * 24);
65213 + whr = runtime / 3600;
65214 + runtime -= whr * 3600;
65215 + wmin = runtime / 60;
65216 + runtime -= wmin * 60;
65217 + wsec = runtime;
65218 +
65219 + cputime = (task->utime + task->stime) / HZ;
65220 + cday = cputime / (3600 * 24);
65221 + cputime -= cday * (3600 * 24);
65222 + chr = cputime / 3600;
65223 + cputime -= chr * 3600;
65224 + cmin = cputime / 60;
65225 + cputime -= cmin * 60;
65226 + csec = cputime;
65227 +
65228 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
65229 +
65230 + return;
65231 +}
65232 +
65233 +#ifdef CONFIG_TASKSTATS
65234 +int gr_is_taskstats_denied(int pid)
65235 +{
65236 + struct task_struct *task;
65237 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65238 + const struct cred *cred;
65239 +#endif
65240 + int ret = 0;
65241 +
65242 + /* restrict taskstats viewing to un-chrooted root users
65243 + who have the 'view' subject flag if the RBAC system is enabled
65244 + */
65245 +
65246 + rcu_read_lock();
65247 + read_lock(&tasklist_lock);
65248 + task = find_task_by_vpid(pid);
65249 + if (task) {
65250 +#ifdef CONFIG_GRKERNSEC_CHROOT
65251 + if (proc_is_chrooted(task))
65252 + ret = -EACCES;
65253 +#endif
65254 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65255 + cred = __task_cred(task);
65256 +#ifdef CONFIG_GRKERNSEC_PROC_USER
65257 + if (gr_is_global_nonroot(cred->uid))
65258 + ret = -EACCES;
65259 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65260 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
65261 + ret = -EACCES;
65262 +#endif
65263 +#endif
65264 + if (gr_status & GR_READY) {
65265 + if (!(task->acl->mode & GR_VIEW))
65266 + ret = -EACCES;
65267 + }
65268 + } else
65269 + ret = -ENOENT;
65270 +
65271 + read_unlock(&tasklist_lock);
65272 + rcu_read_unlock();
65273 +
65274 + return ret;
65275 +}
65276 +#endif
65277 +
65278 +/* AUXV entries are filled via a descendant of search_binary_handler
65279 + after we've already applied the subject for the target
65280 +*/
65281 +int gr_acl_enable_at_secure(void)
65282 +{
65283 + if (unlikely(!(gr_status & GR_READY)))
65284 + return 0;
65285 +
65286 + if (current->acl->mode & GR_ATSECURE)
65287 + return 1;
65288 +
65289 + return 0;
65290 +}
65291 +
65292 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
65293 +{
65294 + struct task_struct *task = current;
65295 + struct dentry *dentry = file->f_path.dentry;
65296 + struct vfsmount *mnt = file->f_path.mnt;
65297 + struct acl_object_label *obj, *tmp;
65298 + struct acl_subject_label *subj;
65299 + unsigned int bufsize;
65300 + int is_not_root;
65301 + char *path;
65302 + dev_t dev = __get_dev(dentry);
65303 +
65304 + if (unlikely(!(gr_status & GR_READY)))
65305 + return 1;
65306 +
65307 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65308 + return 1;
65309 +
65310 + /* ignore Eric Biederman */
65311 + if (IS_PRIVATE(dentry->d_inode))
65312 + return 1;
65313 +
65314 + subj = task->acl;
65315 + read_lock(&gr_inode_lock);
65316 + do {
65317 + obj = lookup_acl_obj_label(ino, dev, subj);
65318 + if (obj != NULL) {
65319 + read_unlock(&gr_inode_lock);
65320 + return (obj->mode & GR_FIND) ? 1 : 0;
65321 + }
65322 + } while ((subj = subj->parent_subject));
65323 + read_unlock(&gr_inode_lock);
65324 +
65325 + /* this is purely an optimization since we're looking for an object
65326 + for the directory we're doing a readdir on
65327 + if it's possible for any globbed object to match the entry we're
65328 + filling into the directory, then the object we find here will be
65329 + an anchor point with attached globbed objects
65330 + */
65331 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
65332 + if (obj->globbed == NULL)
65333 + return (obj->mode & GR_FIND) ? 1 : 0;
65334 +
65335 + is_not_root = ((obj->filename[0] == '/') &&
65336 + (obj->filename[1] == '\0')) ? 0 : 1;
65337 + bufsize = PAGE_SIZE - namelen - is_not_root;
65338 +
65339 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
65340 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
65341 + return 1;
65342 +
65343 + preempt_disable();
65344 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
65345 + bufsize);
65346 +
65347 + bufsize = strlen(path);
65348 +
65349 + /* if base is "/", don't append an additional slash */
65350 + if (is_not_root)
65351 + *(path + bufsize) = '/';
65352 + memcpy(path + bufsize + is_not_root, name, namelen);
65353 + *(path + bufsize + namelen + is_not_root) = '\0';
65354 +
65355 + tmp = obj->globbed;
65356 + while (tmp) {
65357 + if (!glob_match(tmp->filename, path)) {
65358 + preempt_enable();
65359 + return (tmp->mode & GR_FIND) ? 1 : 0;
65360 + }
65361 + tmp = tmp->next;
65362 + }
65363 + preempt_enable();
65364 + return (obj->mode & GR_FIND) ? 1 : 0;
65365 +}
65366 +
65367 +void gr_put_exec_file(struct task_struct *task)
65368 +{
65369 + struct file *filp;
65370 +
65371 + write_lock(&grsec_exec_file_lock);
65372 + filp = task->exec_file;
65373 + task->exec_file = NULL;
65374 + write_unlock(&grsec_exec_file_lock);
65375 +
65376 + if (filp)
65377 + fput(filp);
65378 +
65379 + return;
65380 +}
65381 +
65382 +
65383 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
65384 +EXPORT_SYMBOL(gr_acl_is_enabled);
65385 +#endif
65386 +#ifdef CONFIG_SECURITY
65387 +EXPORT_SYMBOL(gr_check_user_change);
65388 +EXPORT_SYMBOL(gr_check_group_change);
65389 +#endif
65390 +
65391 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
65392 new file mode 100644
65393 index 0000000..18ffbbd
65394 --- /dev/null
65395 +++ b/grsecurity/gracl_alloc.c
65396 @@ -0,0 +1,105 @@
65397 +#include <linux/kernel.h>
65398 +#include <linux/mm.h>
65399 +#include <linux/slab.h>
65400 +#include <linux/vmalloc.h>
65401 +#include <linux/gracl.h>
65402 +#include <linux/grsecurity.h>
65403 +
65404 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
65405 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
65406 +
65407 +static __inline__ int
65408 +alloc_pop(void)
65409 +{
65410 + if (current_alloc_state->alloc_stack_next == 1)
65411 + return 0;
65412 +
65413 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
65414 +
65415 + current_alloc_state->alloc_stack_next--;
65416 +
65417 + return 1;
65418 +}
65419 +
65420 +static __inline__ int
65421 +alloc_push(void *buf)
65422 +{
65423 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
65424 + return 1;
65425 +
65426 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
65427 +
65428 + current_alloc_state->alloc_stack_next++;
65429 +
65430 + return 0;
65431 +}
65432 +
65433 +void *
65434 +acl_alloc(unsigned long len)
65435 +{
65436 + void *ret = NULL;
65437 +
65438 + if (!len || len > PAGE_SIZE)
65439 + goto out;
65440 +
65441 + ret = kmalloc(len, GFP_KERNEL);
65442 +
65443 + if (ret) {
65444 + if (alloc_push(ret)) {
65445 + kfree(ret);
65446 + ret = NULL;
65447 + }
65448 + }
65449 +
65450 +out:
65451 + return ret;
65452 +}
65453 +
65454 +void *
65455 +acl_alloc_num(unsigned long num, unsigned long len)
65456 +{
65457 + if (!len || (num > (PAGE_SIZE / len)))
65458 + return NULL;
65459 +
65460 + return acl_alloc(num * len);
65461 +}
65462 +
65463 +void
65464 +acl_free_all(void)
65465 +{
65466 + if (!current_alloc_state->alloc_stack)
65467 + return;
65468 +
65469 + while (alloc_pop()) ;
65470 +
65471 + if (current_alloc_state->alloc_stack) {
65472 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
65473 + kfree(current_alloc_state->alloc_stack);
65474 + else
65475 + vfree(current_alloc_state->alloc_stack);
65476 + }
65477 +
65478 + current_alloc_state->alloc_stack = NULL;
65479 + current_alloc_state->alloc_stack_size = 1;
65480 + current_alloc_state->alloc_stack_next = 1;
65481 +
65482 + return;
65483 +}
65484 +
65485 +int
65486 +acl_alloc_stack_init(unsigned long size)
65487 +{
65488 + if ((size * sizeof (void *)) <= PAGE_SIZE)
65489 + current_alloc_state->alloc_stack =
65490 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
65491 + else
65492 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
65493 +
65494 + current_alloc_state->alloc_stack_size = size;
65495 + current_alloc_state->alloc_stack_next = 1;
65496 +
65497 + if (!current_alloc_state->alloc_stack)
65498 + return 0;
65499 + else
65500 + return 1;
65501 +}
65502 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
65503 new file mode 100644
65504 index 0000000..bdd51ea
65505 --- /dev/null
65506 +++ b/grsecurity/gracl_cap.c
65507 @@ -0,0 +1,110 @@
65508 +#include <linux/kernel.h>
65509 +#include <linux/module.h>
65510 +#include <linux/sched.h>
65511 +#include <linux/gracl.h>
65512 +#include <linux/grsecurity.h>
65513 +#include <linux/grinternal.h>
65514 +
65515 +extern const char *captab_log[];
65516 +extern int captab_log_entries;
65517 +
65518 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65519 +{
65520 + struct acl_subject_label *curracl;
65521 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65522 + kernel_cap_t cap_audit = __cap_empty_set;
65523 +
65524 + if (!gr_acl_is_enabled())
65525 + return 1;
65526 +
65527 + curracl = task->acl;
65528 +
65529 + cap_drop = curracl->cap_lower;
65530 + cap_mask = curracl->cap_mask;
65531 + cap_audit = curracl->cap_invert_audit;
65532 +
65533 + while ((curracl = curracl->parent_subject)) {
65534 + /* if the cap isn't specified in the current computed mask but is specified in the
65535 + current level subject, and is lowered in the current level subject, then add
65536 + it to the set of dropped capabilities
65537 + otherwise, add the current level subject's mask to the current computed mask
65538 + */
65539 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65540 + cap_raise(cap_mask, cap);
65541 + if (cap_raised(curracl->cap_lower, cap))
65542 + cap_raise(cap_drop, cap);
65543 + if (cap_raised(curracl->cap_invert_audit, cap))
65544 + cap_raise(cap_audit, cap);
65545 + }
65546 + }
65547 +
65548 + if (!cap_raised(cap_drop, cap)) {
65549 + if (cap_raised(cap_audit, cap))
65550 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
65551 + return 1;
65552 + }
65553 +
65554 + curracl = task->acl;
65555 +
65556 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
65557 + && cap_raised(cred->cap_effective, cap)) {
65558 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65559 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
65560 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
65561 + gr_to_filename(task->exec_file->f_path.dentry,
65562 + task->exec_file->f_path.mnt) : curracl->filename,
65563 + curracl->filename, 0UL,
65564 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
65565 + return 1;
65566 + }
65567 +
65568 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
65569 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
65570 +
65571 + return 0;
65572 +}
65573 +
65574 +int
65575 +gr_acl_is_capable(const int cap)
65576 +{
65577 + return gr_task_acl_is_capable(current, current_cred(), cap);
65578 +}
65579 +
65580 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
65581 +{
65582 + struct acl_subject_label *curracl;
65583 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65584 +
65585 + if (!gr_acl_is_enabled())
65586 + return 1;
65587 +
65588 + curracl = task->acl;
65589 +
65590 + cap_drop = curracl->cap_lower;
65591 + cap_mask = curracl->cap_mask;
65592 +
65593 + while ((curracl = curracl->parent_subject)) {
65594 + /* if the cap isn't specified in the current computed mask but is specified in the
65595 + current level subject, and is lowered in the current level subject, then add
65596 + it to the set of dropped capabilities
65597 + otherwise, add the current level subject's mask to the current computed mask
65598 + */
65599 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65600 + cap_raise(cap_mask, cap);
65601 + if (cap_raised(curracl->cap_lower, cap))
65602 + cap_raise(cap_drop, cap);
65603 + }
65604 + }
65605 +
65606 + if (!cap_raised(cap_drop, cap))
65607 + return 1;
65608 +
65609 + return 0;
65610 +}
65611 +
65612 +int
65613 +gr_acl_is_capable_nolog(const int cap)
65614 +{
65615 + return gr_task_acl_is_capable_nolog(current, cap);
65616 +}
65617 +
65618 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
65619 new file mode 100644
65620 index 0000000..ca25605
65621 --- /dev/null
65622 +++ b/grsecurity/gracl_compat.c
65623 @@ -0,0 +1,270 @@
65624 +#include <linux/kernel.h>
65625 +#include <linux/gracl.h>
65626 +#include <linux/compat.h>
65627 +#include <linux/gracl_compat.h>
65628 +
65629 +#include <asm/uaccess.h>
65630 +
65631 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
65632 +{
65633 + struct gr_arg_wrapper_compat uwrapcompat;
65634 +
65635 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
65636 + return -EFAULT;
65637 +
65638 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
65639 + (uwrapcompat.version != 0x2901)) ||
65640 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
65641 + return -EINVAL;
65642 +
65643 + uwrap->arg = compat_ptr(uwrapcompat.arg);
65644 + uwrap->version = uwrapcompat.version;
65645 + uwrap->size = sizeof(struct gr_arg);
65646 +
65647 + return 0;
65648 +}
65649 +
65650 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
65651 +{
65652 + struct gr_arg_compat argcompat;
65653 +
65654 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
65655 + return -EFAULT;
65656 +
65657 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
65658 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
65659 + arg->role_db.num_roles = argcompat.role_db.num_roles;
65660 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
65661 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
65662 + arg->role_db.num_objects = argcompat.role_db.num_objects;
65663 +
65664 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
65665 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
65666 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
65667 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
65668 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
65669 + arg->segv_device = argcompat.segv_device;
65670 + arg->segv_inode = argcompat.segv_inode;
65671 + arg->segv_uid = argcompat.segv_uid;
65672 + arg->num_sprole_pws = argcompat.num_sprole_pws;
65673 + arg->mode = argcompat.mode;
65674 +
65675 + return 0;
65676 +}
65677 +
65678 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
65679 +{
65680 + struct acl_object_label_compat objcompat;
65681 +
65682 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
65683 + return -EFAULT;
65684 +
65685 + obj->filename = compat_ptr(objcompat.filename);
65686 + obj->inode = objcompat.inode;
65687 + obj->device = objcompat.device;
65688 + obj->mode = objcompat.mode;
65689 +
65690 + obj->nested = compat_ptr(objcompat.nested);
65691 + obj->globbed = compat_ptr(objcompat.globbed);
65692 +
65693 + obj->prev = compat_ptr(objcompat.prev);
65694 + obj->next = compat_ptr(objcompat.next);
65695 +
65696 + return 0;
65697 +}
65698 +
65699 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
65700 +{
65701 + unsigned int i;
65702 + struct acl_subject_label_compat subjcompat;
65703 +
65704 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
65705 + return -EFAULT;
65706 +
65707 + subj->filename = compat_ptr(subjcompat.filename);
65708 + subj->inode = subjcompat.inode;
65709 + subj->device = subjcompat.device;
65710 + subj->mode = subjcompat.mode;
65711 + subj->cap_mask = subjcompat.cap_mask;
65712 + subj->cap_lower = subjcompat.cap_lower;
65713 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
65714 +
65715 + for (i = 0; i < GR_NLIMITS; i++) {
65716 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
65717 + subj->res[i].rlim_cur = RLIM_INFINITY;
65718 + else
65719 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
65720 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
65721 + subj->res[i].rlim_max = RLIM_INFINITY;
65722 + else
65723 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
65724 + }
65725 + subj->resmask = subjcompat.resmask;
65726 +
65727 + subj->user_trans_type = subjcompat.user_trans_type;
65728 + subj->group_trans_type = subjcompat.group_trans_type;
65729 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
65730 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
65731 + subj->user_trans_num = subjcompat.user_trans_num;
65732 + subj->group_trans_num = subjcompat.group_trans_num;
65733 +
65734 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
65735 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
65736 + subj->ip_type = subjcompat.ip_type;
65737 + subj->ips = compat_ptr(subjcompat.ips);
65738 + subj->ip_num = subjcompat.ip_num;
65739 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
65740 +
65741 + subj->crashes = subjcompat.crashes;
65742 + subj->expires = subjcompat.expires;
65743 +
65744 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
65745 + subj->hash = compat_ptr(subjcompat.hash);
65746 + subj->prev = compat_ptr(subjcompat.prev);
65747 + subj->next = compat_ptr(subjcompat.next);
65748 +
65749 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
65750 + subj->obj_hash_size = subjcompat.obj_hash_size;
65751 + subj->pax_flags = subjcompat.pax_flags;
65752 +
65753 + return 0;
65754 +}
65755 +
65756 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
65757 +{
65758 + struct acl_role_label_compat rolecompat;
65759 +
65760 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
65761 + return -EFAULT;
65762 +
65763 + role->rolename = compat_ptr(rolecompat.rolename);
65764 + role->uidgid = rolecompat.uidgid;
65765 + role->roletype = rolecompat.roletype;
65766 +
65767 + role->auth_attempts = rolecompat.auth_attempts;
65768 + role->expires = rolecompat.expires;
65769 +
65770 + role->root_label = compat_ptr(rolecompat.root_label);
65771 + role->hash = compat_ptr(rolecompat.hash);
65772 +
65773 + role->prev = compat_ptr(rolecompat.prev);
65774 + role->next = compat_ptr(rolecompat.next);
65775 +
65776 + role->transitions = compat_ptr(rolecompat.transitions);
65777 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
65778 + role->domain_children = compat_ptr(rolecompat.domain_children);
65779 + role->domain_child_num = rolecompat.domain_child_num;
65780 +
65781 + role->umask = rolecompat.umask;
65782 +
65783 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
65784 + role->subj_hash_size = rolecompat.subj_hash_size;
65785 +
65786 + return 0;
65787 +}
65788 +
65789 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
65790 +{
65791 + struct role_allowed_ip_compat roleip_compat;
65792 +
65793 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
65794 + return -EFAULT;
65795 +
65796 + roleip->addr = roleip_compat.addr;
65797 + roleip->netmask = roleip_compat.netmask;
65798 +
65799 + roleip->prev = compat_ptr(roleip_compat.prev);
65800 + roleip->next = compat_ptr(roleip_compat.next);
65801 +
65802 + return 0;
65803 +}
65804 +
65805 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
65806 +{
65807 + struct role_transition_compat trans_compat;
65808 +
65809 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
65810 + return -EFAULT;
65811 +
65812 + trans->rolename = compat_ptr(trans_compat.rolename);
65813 +
65814 + trans->prev = compat_ptr(trans_compat.prev);
65815 + trans->next = compat_ptr(trans_compat.next);
65816 +
65817 + return 0;
65818 +
65819 +}
65820 +
65821 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
65822 +{
65823 + struct gr_hash_struct_compat hash_compat;
65824 +
65825 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
65826 + return -EFAULT;
65827 +
65828 + hash->table = compat_ptr(hash_compat.table);
65829 + hash->nametable = compat_ptr(hash_compat.nametable);
65830 + hash->first = compat_ptr(hash_compat.first);
65831 +
65832 + hash->table_size = hash_compat.table_size;
65833 + hash->used_size = hash_compat.used_size;
65834 +
65835 + hash->type = hash_compat.type;
65836 +
65837 + return 0;
65838 +}
65839 +
65840 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
65841 +{
65842 + compat_uptr_t ptrcompat;
65843 +
65844 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
65845 + return -EFAULT;
65846 +
65847 + *(void **)ptr = compat_ptr(ptrcompat);
65848 +
65849 + return 0;
65850 +}
65851 +
65852 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
65853 +{
65854 + struct acl_ip_label_compat ip_compat;
65855 +
65856 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
65857 + return -EFAULT;
65858 +
65859 + ip->iface = compat_ptr(ip_compat.iface);
65860 + ip->addr = ip_compat.addr;
65861 + ip->netmask = ip_compat.netmask;
65862 + ip->low = ip_compat.low;
65863 + ip->high = ip_compat.high;
65864 + ip->mode = ip_compat.mode;
65865 + ip->type = ip_compat.type;
65866 +
65867 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
65868 +
65869 + ip->prev = compat_ptr(ip_compat.prev);
65870 + ip->next = compat_ptr(ip_compat.next);
65871 +
65872 + return 0;
65873 +}
65874 +
65875 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
65876 +{
65877 + struct sprole_pw_compat pw_compat;
65878 +
65879 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
65880 + return -EFAULT;
65881 +
65882 + pw->rolename = compat_ptr(pw_compat.rolename);
65883 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
65884 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
65885 +
65886 + return 0;
65887 +}
65888 +
65889 +size_t get_gr_arg_wrapper_size_compat(void)
65890 +{
65891 + return sizeof(struct gr_arg_wrapper_compat);
65892 +}
65893 +
65894 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
65895 new file mode 100644
65896 index 0000000..a340c17
65897 --- /dev/null
65898 +++ b/grsecurity/gracl_fs.c
65899 @@ -0,0 +1,431 @@
65900 +#include <linux/kernel.h>
65901 +#include <linux/sched.h>
65902 +#include <linux/types.h>
65903 +#include <linux/fs.h>
65904 +#include <linux/file.h>
65905 +#include <linux/stat.h>
65906 +#include <linux/grsecurity.h>
65907 +#include <linux/grinternal.h>
65908 +#include <linux/gracl.h>
65909 +
65910 +umode_t
65911 +gr_acl_umask(void)
65912 +{
65913 + if (unlikely(!gr_acl_is_enabled()))
65914 + return 0;
65915 +
65916 + return current->role->umask;
65917 +}
65918 +
65919 +__u32
65920 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65921 + const struct vfsmount * mnt)
65922 +{
65923 + __u32 mode;
65924 +
65925 + if (unlikely(!dentry->d_inode))
65926 + return GR_FIND;
65927 +
65928 + mode =
65929 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
65930 +
65931 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
65932 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65933 + return mode;
65934 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
65935 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65936 + return 0;
65937 + } else if (unlikely(!(mode & GR_FIND)))
65938 + return 0;
65939 +
65940 + return GR_FIND;
65941 +}
65942 +
65943 +__u32
65944 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65945 + int acc_mode)
65946 +{
65947 + __u32 reqmode = GR_FIND;
65948 + __u32 mode;
65949 +
65950 + if (unlikely(!dentry->d_inode))
65951 + return reqmode;
65952 +
65953 + if (acc_mode & MAY_APPEND)
65954 + reqmode |= GR_APPEND;
65955 + else if (acc_mode & MAY_WRITE)
65956 + reqmode |= GR_WRITE;
65957 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
65958 + reqmode |= GR_READ;
65959 +
65960 + mode =
65961 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65962 + mnt);
65963 +
65964 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65965 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65966 + reqmode & GR_READ ? " reading" : "",
65967 + reqmode & GR_WRITE ? " writing" : reqmode &
65968 + GR_APPEND ? " appending" : "");
65969 + return reqmode;
65970 + } else
65971 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65972 + {
65973 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65974 + reqmode & GR_READ ? " reading" : "",
65975 + reqmode & GR_WRITE ? " writing" : reqmode &
65976 + GR_APPEND ? " appending" : "");
65977 + return 0;
65978 + } else if (unlikely((mode & reqmode) != reqmode))
65979 + return 0;
65980 +
65981 + return reqmode;
65982 +}
65983 +
65984 +__u32
65985 +gr_acl_handle_creat(const struct dentry * dentry,
65986 + const struct dentry * p_dentry,
65987 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
65988 + const int imode)
65989 +{
65990 + __u32 reqmode = GR_WRITE | GR_CREATE;
65991 + __u32 mode;
65992 +
65993 + if (acc_mode & MAY_APPEND)
65994 + reqmode |= GR_APPEND;
65995 + // if a directory was required or the directory already exists, then
65996 + // don't count this open as a read
65997 + if ((acc_mode & MAY_READ) &&
65998 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
65999 + reqmode |= GR_READ;
66000 + if ((open_flags & O_CREAT) &&
66001 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66002 + reqmode |= GR_SETID;
66003 +
66004 + mode =
66005 + gr_check_create(dentry, p_dentry, p_mnt,
66006 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66007 +
66008 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66009 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66010 + reqmode & GR_READ ? " reading" : "",
66011 + reqmode & GR_WRITE ? " writing" : reqmode &
66012 + GR_APPEND ? " appending" : "");
66013 + return reqmode;
66014 + } else
66015 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66016 + {
66017 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66018 + reqmode & GR_READ ? " reading" : "",
66019 + reqmode & GR_WRITE ? " writing" : reqmode &
66020 + GR_APPEND ? " appending" : "");
66021 + return 0;
66022 + } else if (unlikely((mode & reqmode) != reqmode))
66023 + return 0;
66024 +
66025 + return reqmode;
66026 +}
66027 +
66028 +__u32
66029 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
66030 + const int fmode)
66031 +{
66032 + __u32 mode, reqmode = GR_FIND;
66033 +
66034 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
66035 + reqmode |= GR_EXEC;
66036 + if (fmode & S_IWOTH)
66037 + reqmode |= GR_WRITE;
66038 + if (fmode & S_IROTH)
66039 + reqmode |= GR_READ;
66040 +
66041 + mode =
66042 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66043 + mnt);
66044 +
66045 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66046 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66047 + reqmode & GR_READ ? " reading" : "",
66048 + reqmode & GR_WRITE ? " writing" : "",
66049 + reqmode & GR_EXEC ? " executing" : "");
66050 + return reqmode;
66051 + } else
66052 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66053 + {
66054 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66055 + reqmode & GR_READ ? " reading" : "",
66056 + reqmode & GR_WRITE ? " writing" : "",
66057 + reqmode & GR_EXEC ? " executing" : "");
66058 + return 0;
66059 + } else if (unlikely((mode & reqmode) != reqmode))
66060 + return 0;
66061 +
66062 + return reqmode;
66063 +}
66064 +
66065 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
66066 +{
66067 + __u32 mode;
66068 +
66069 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
66070 +
66071 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66072 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
66073 + return mode;
66074 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66075 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
66076 + return 0;
66077 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66078 + return 0;
66079 +
66080 + return (reqmode);
66081 +}
66082 +
66083 +__u32
66084 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
66085 +{
66086 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
66087 +}
66088 +
66089 +__u32
66090 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
66091 +{
66092 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
66093 +}
66094 +
66095 +__u32
66096 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
66097 +{
66098 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
66099 +}
66100 +
66101 +__u32
66102 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
66103 +{
66104 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
66105 +}
66106 +
66107 +__u32
66108 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
66109 + umode_t *modeptr)
66110 +{
66111 + umode_t mode;
66112 +
66113 + *modeptr &= ~gr_acl_umask();
66114 + mode = *modeptr;
66115 +
66116 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
66117 + return 1;
66118 +
66119 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
66120 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
66121 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
66122 + GR_CHMOD_ACL_MSG);
66123 + } else {
66124 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
66125 + }
66126 +}
66127 +
66128 +__u32
66129 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
66130 +{
66131 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
66132 +}
66133 +
66134 +__u32
66135 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
66136 +{
66137 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
66138 +}
66139 +
66140 +__u32
66141 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
66142 +{
66143 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
66144 +}
66145 +
66146 +__u32
66147 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
66148 +{
66149 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
66150 + GR_UNIXCONNECT_ACL_MSG);
66151 +}
66152 +
66153 +/* hardlinks require at minimum create and link permission,
66154 + any additional privilege required is based on the
66155 + privilege of the file being linked to
66156 +*/
66157 +__u32
66158 +gr_acl_handle_link(const struct dentry * new_dentry,
66159 + const struct dentry * parent_dentry,
66160 + const struct vfsmount * parent_mnt,
66161 + const struct dentry * old_dentry,
66162 + const struct vfsmount * old_mnt, const struct filename *to)
66163 +{
66164 + __u32 mode;
66165 + __u32 needmode = GR_CREATE | GR_LINK;
66166 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
66167 +
66168 + mode =
66169 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
66170 + old_mnt);
66171 +
66172 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
66173 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66174 + return mode;
66175 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66176 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66177 + return 0;
66178 + } else if (unlikely((mode & needmode) != needmode))
66179 + return 0;
66180 +
66181 + return 1;
66182 +}
66183 +
66184 +__u32
66185 +gr_acl_handle_symlink(const struct dentry * new_dentry,
66186 + const struct dentry * parent_dentry,
66187 + const struct vfsmount * parent_mnt, const struct filename *from)
66188 +{
66189 + __u32 needmode = GR_WRITE | GR_CREATE;
66190 + __u32 mode;
66191 +
66192 + mode =
66193 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
66194 + GR_CREATE | GR_AUDIT_CREATE |
66195 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
66196 +
66197 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
66198 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66199 + return mode;
66200 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66201 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66202 + return 0;
66203 + } else if (unlikely((mode & needmode) != needmode))
66204 + return 0;
66205 +
66206 + return (GR_WRITE | GR_CREATE);
66207 +}
66208 +
66209 +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)
66210 +{
66211 + __u32 mode;
66212 +
66213 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66214 +
66215 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66216 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
66217 + return mode;
66218 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66219 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
66220 + return 0;
66221 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66222 + return 0;
66223 +
66224 + return (reqmode);
66225 +}
66226 +
66227 +__u32
66228 +gr_acl_handle_mknod(const struct dentry * new_dentry,
66229 + const struct dentry * parent_dentry,
66230 + const struct vfsmount * parent_mnt,
66231 + const int mode)
66232 +{
66233 + __u32 reqmode = GR_WRITE | GR_CREATE;
66234 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66235 + reqmode |= GR_SETID;
66236 +
66237 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66238 + reqmode, GR_MKNOD_ACL_MSG);
66239 +}
66240 +
66241 +__u32
66242 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
66243 + const struct dentry *parent_dentry,
66244 + const struct vfsmount *parent_mnt)
66245 +{
66246 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66247 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
66248 +}
66249 +
66250 +#define RENAME_CHECK_SUCCESS(old, new) \
66251 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
66252 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
66253 +
66254 +int
66255 +gr_acl_handle_rename(struct dentry *new_dentry,
66256 + struct dentry *parent_dentry,
66257 + const struct vfsmount *parent_mnt,
66258 + struct dentry *old_dentry,
66259 + struct inode *old_parent_inode,
66260 + struct vfsmount *old_mnt, const struct filename *newname)
66261 +{
66262 + __u32 comp1, comp2;
66263 + int error = 0;
66264 +
66265 + if (unlikely(!gr_acl_is_enabled()))
66266 + return 0;
66267 +
66268 + if (!new_dentry->d_inode) {
66269 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
66270 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
66271 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
66272 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
66273 + GR_DELETE | GR_AUDIT_DELETE |
66274 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66275 + GR_SUPPRESS, old_mnt);
66276 + } else {
66277 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
66278 + GR_CREATE | GR_DELETE |
66279 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
66280 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66281 + GR_SUPPRESS, parent_mnt);
66282 + comp2 =
66283 + gr_search_file(old_dentry,
66284 + GR_READ | GR_WRITE | GR_AUDIT_READ |
66285 + GR_DELETE | GR_AUDIT_DELETE |
66286 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
66287 + }
66288 +
66289 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
66290 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
66291 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66292 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
66293 + && !(comp2 & GR_SUPPRESS)) {
66294 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66295 + error = -EACCES;
66296 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
66297 + error = -EACCES;
66298 +
66299 + return error;
66300 +}
66301 +
66302 +void
66303 +gr_acl_handle_exit(void)
66304 +{
66305 + u16 id;
66306 + char *rolename;
66307 +
66308 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
66309 + !(current->role->roletype & GR_ROLE_PERSIST))) {
66310 + id = current->acl_role_id;
66311 + rolename = current->role->rolename;
66312 + gr_set_acls(1);
66313 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
66314 + }
66315 +
66316 + gr_put_exec_file(current);
66317 + return;
66318 +}
66319 +
66320 +int
66321 +gr_acl_handle_procpidmem(const struct task_struct *task)
66322 +{
66323 + if (unlikely(!gr_acl_is_enabled()))
66324 + return 0;
66325 +
66326 + if (task != current && task->acl->mode & GR_PROTPROCFD)
66327 + return -EACCES;
66328 +
66329 + return 0;
66330 +}
66331 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
66332 new file mode 100644
66333 index 0000000..f056b81
66334 --- /dev/null
66335 +++ b/grsecurity/gracl_ip.c
66336 @@ -0,0 +1,386 @@
66337 +#include <linux/kernel.h>
66338 +#include <asm/uaccess.h>
66339 +#include <asm/errno.h>
66340 +#include <net/sock.h>
66341 +#include <linux/file.h>
66342 +#include <linux/fs.h>
66343 +#include <linux/net.h>
66344 +#include <linux/in.h>
66345 +#include <linux/skbuff.h>
66346 +#include <linux/ip.h>
66347 +#include <linux/udp.h>
66348 +#include <linux/types.h>
66349 +#include <linux/sched.h>
66350 +#include <linux/netdevice.h>
66351 +#include <linux/inetdevice.h>
66352 +#include <linux/gracl.h>
66353 +#include <linux/grsecurity.h>
66354 +#include <linux/grinternal.h>
66355 +
66356 +#define GR_BIND 0x01
66357 +#define GR_CONNECT 0x02
66358 +#define GR_INVERT 0x04
66359 +#define GR_BINDOVERRIDE 0x08
66360 +#define GR_CONNECTOVERRIDE 0x10
66361 +#define GR_SOCK_FAMILY 0x20
66362 +
66363 +static const char * gr_protocols[IPPROTO_MAX] = {
66364 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
66365 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
66366 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
66367 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
66368 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
66369 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
66370 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
66371 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
66372 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
66373 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
66374 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
66375 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
66376 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
66377 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
66378 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
66379 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
66380 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
66381 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
66382 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
66383 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
66384 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
66385 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
66386 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
66387 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
66388 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
66389 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
66390 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
66391 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
66392 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
66393 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
66394 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
66395 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
66396 + };
66397 +
66398 +static const char * gr_socktypes[SOCK_MAX] = {
66399 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
66400 + "unknown:7", "unknown:8", "unknown:9", "packet"
66401 + };
66402 +
66403 +static const char * gr_sockfamilies[AF_MAX+1] = {
66404 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
66405 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
66406 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
66407 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
66408 + };
66409 +
66410 +const char *
66411 +gr_proto_to_name(unsigned char proto)
66412 +{
66413 + return gr_protocols[proto];
66414 +}
66415 +
66416 +const char *
66417 +gr_socktype_to_name(unsigned char type)
66418 +{
66419 + return gr_socktypes[type];
66420 +}
66421 +
66422 +const char *
66423 +gr_sockfamily_to_name(unsigned char family)
66424 +{
66425 + return gr_sockfamilies[family];
66426 +}
66427 +
66428 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
66429 +
66430 +int
66431 +gr_search_socket(const int domain, const int type, const int protocol)
66432 +{
66433 + struct acl_subject_label *curr;
66434 + const struct cred *cred = current_cred();
66435 +
66436 + if (unlikely(!gr_acl_is_enabled()))
66437 + goto exit;
66438 +
66439 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
66440 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
66441 + goto exit; // let the kernel handle it
66442 +
66443 + curr = current->acl;
66444 +
66445 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
66446 + /* the family is allowed, if this is PF_INET allow it only if
66447 + the extra sock type/protocol checks pass */
66448 + if (domain == PF_INET)
66449 + goto inet_check;
66450 + goto exit;
66451 + } else {
66452 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66453 + __u32 fakeip = 0;
66454 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66455 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66456 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66457 + gr_to_filename(current->exec_file->f_path.dentry,
66458 + current->exec_file->f_path.mnt) :
66459 + curr->filename, curr->filename,
66460 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
66461 + &current->signal->saved_ip);
66462 + goto exit;
66463 + }
66464 + goto exit_fail;
66465 + }
66466 +
66467 +inet_check:
66468 + /* the rest of this checking is for IPv4 only */
66469 + if (!curr->ips)
66470 + goto exit;
66471 +
66472 + if ((curr->ip_type & (1U << type)) &&
66473 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
66474 + goto exit;
66475 +
66476 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66477 + /* we don't place acls on raw sockets , and sometimes
66478 + dgram/ip sockets are opened for ioctl and not
66479 + bind/connect, so we'll fake a bind learn log */
66480 + if (type == SOCK_RAW || type == SOCK_PACKET) {
66481 + __u32 fakeip = 0;
66482 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66483 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66484 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66485 + gr_to_filename(current->exec_file->f_path.dentry,
66486 + current->exec_file->f_path.mnt) :
66487 + curr->filename, curr->filename,
66488 + &fakeip, 0, type,
66489 + protocol, GR_CONNECT, &current->signal->saved_ip);
66490 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
66491 + __u32 fakeip = 0;
66492 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66493 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66494 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66495 + gr_to_filename(current->exec_file->f_path.dentry,
66496 + current->exec_file->f_path.mnt) :
66497 + curr->filename, curr->filename,
66498 + &fakeip, 0, type,
66499 + protocol, GR_BIND, &current->signal->saved_ip);
66500 + }
66501 + /* we'll log when they use connect or bind */
66502 + goto exit;
66503 + }
66504 +
66505 +exit_fail:
66506 + if (domain == PF_INET)
66507 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
66508 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
66509 + else if (rcu_access_pointer(net_families[domain]) != NULL)
66510 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
66511 + gr_socktype_to_name(type), protocol);
66512 +
66513 + return 0;
66514 +exit:
66515 + return 1;
66516 +}
66517 +
66518 +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)
66519 +{
66520 + if ((ip->mode & mode) &&
66521 + (ip_port >= ip->low) &&
66522 + (ip_port <= ip->high) &&
66523 + ((ntohl(ip_addr) & our_netmask) ==
66524 + (ntohl(our_addr) & our_netmask))
66525 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
66526 + && (ip->type & (1U << type))) {
66527 + if (ip->mode & GR_INVERT)
66528 + return 2; // specifically denied
66529 + else
66530 + return 1; // allowed
66531 + }
66532 +
66533 + return 0; // not specifically allowed, may continue parsing
66534 +}
66535 +
66536 +static int
66537 +gr_search_connectbind(const int full_mode, struct sock *sk,
66538 + struct sockaddr_in *addr, const int type)
66539 +{
66540 + char iface[IFNAMSIZ] = {0};
66541 + struct acl_subject_label *curr;
66542 + struct acl_ip_label *ip;
66543 + struct inet_sock *isk;
66544 + struct net_device *dev;
66545 + struct in_device *idev;
66546 + unsigned long i;
66547 + int ret;
66548 + int mode = full_mode & (GR_BIND | GR_CONNECT);
66549 + __u32 ip_addr = 0;
66550 + __u32 our_addr;
66551 + __u32 our_netmask;
66552 + char *p;
66553 + __u16 ip_port = 0;
66554 + const struct cred *cred = current_cred();
66555 +
66556 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
66557 + return 0;
66558 +
66559 + curr = current->acl;
66560 + isk = inet_sk(sk);
66561 +
66562 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
66563 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
66564 + addr->sin_addr.s_addr = curr->inaddr_any_override;
66565 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
66566 + struct sockaddr_in saddr;
66567 + int err;
66568 +
66569 + saddr.sin_family = AF_INET;
66570 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
66571 + saddr.sin_port = isk->inet_sport;
66572 +
66573 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66574 + if (err)
66575 + return err;
66576 +
66577 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66578 + if (err)
66579 + return err;
66580 + }
66581 +
66582 + if (!curr->ips)
66583 + return 0;
66584 +
66585 + ip_addr = addr->sin_addr.s_addr;
66586 + ip_port = ntohs(addr->sin_port);
66587 +
66588 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66589 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66590 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66591 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66592 + gr_to_filename(current->exec_file->f_path.dentry,
66593 + current->exec_file->f_path.mnt) :
66594 + curr->filename, curr->filename,
66595 + &ip_addr, ip_port, type,
66596 + sk->sk_protocol, mode, &current->signal->saved_ip);
66597 + return 0;
66598 + }
66599 +
66600 + for (i = 0; i < curr->ip_num; i++) {
66601 + ip = *(curr->ips + i);
66602 + if (ip->iface != NULL) {
66603 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
66604 + p = strchr(iface, ':');
66605 + if (p != NULL)
66606 + *p = '\0';
66607 + dev = dev_get_by_name(sock_net(sk), iface);
66608 + if (dev == NULL)
66609 + continue;
66610 + idev = in_dev_get(dev);
66611 + if (idev == NULL) {
66612 + dev_put(dev);
66613 + continue;
66614 + }
66615 + rcu_read_lock();
66616 + for_ifa(idev) {
66617 + if (!strcmp(ip->iface, ifa->ifa_label)) {
66618 + our_addr = ifa->ifa_address;
66619 + our_netmask = 0xffffffff;
66620 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66621 + if (ret == 1) {
66622 + rcu_read_unlock();
66623 + in_dev_put(idev);
66624 + dev_put(dev);
66625 + return 0;
66626 + } else if (ret == 2) {
66627 + rcu_read_unlock();
66628 + in_dev_put(idev);
66629 + dev_put(dev);
66630 + goto denied;
66631 + }
66632 + }
66633 + } endfor_ifa(idev);
66634 + rcu_read_unlock();
66635 + in_dev_put(idev);
66636 + dev_put(dev);
66637 + } else {
66638 + our_addr = ip->addr;
66639 + our_netmask = ip->netmask;
66640 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66641 + if (ret == 1)
66642 + return 0;
66643 + else if (ret == 2)
66644 + goto denied;
66645 + }
66646 + }
66647 +
66648 +denied:
66649 + if (mode == GR_BIND)
66650 + 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));
66651 + else if (mode == GR_CONNECT)
66652 + 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));
66653 +
66654 + return -EACCES;
66655 +}
66656 +
66657 +int
66658 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
66659 +{
66660 + /* always allow disconnection of dgram sockets with connect */
66661 + if (addr->sin_family == AF_UNSPEC)
66662 + return 0;
66663 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
66664 +}
66665 +
66666 +int
66667 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
66668 +{
66669 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
66670 +}
66671 +
66672 +int gr_search_listen(struct socket *sock)
66673 +{
66674 + struct sock *sk = sock->sk;
66675 + struct sockaddr_in addr;
66676 +
66677 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66678 + addr.sin_port = inet_sk(sk)->inet_sport;
66679 +
66680 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66681 +}
66682 +
66683 +int gr_search_accept(struct socket *sock)
66684 +{
66685 + struct sock *sk = sock->sk;
66686 + struct sockaddr_in addr;
66687 +
66688 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66689 + addr.sin_port = inet_sk(sk)->inet_sport;
66690 +
66691 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66692 +}
66693 +
66694 +int
66695 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
66696 +{
66697 + if (addr)
66698 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
66699 + else {
66700 + struct sockaddr_in sin;
66701 + const struct inet_sock *inet = inet_sk(sk);
66702 +
66703 + sin.sin_addr.s_addr = inet->inet_daddr;
66704 + sin.sin_port = inet->inet_dport;
66705 +
66706 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66707 + }
66708 +}
66709 +
66710 +int
66711 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
66712 +{
66713 + struct sockaddr_in sin;
66714 +
66715 + if (unlikely(skb->len < sizeof (struct udphdr)))
66716 + return 0; // skip this packet
66717 +
66718 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
66719 + sin.sin_port = udp_hdr(skb)->source;
66720 +
66721 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66722 +}
66723 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
66724 new file mode 100644
66725 index 0000000..25f54ef
66726 --- /dev/null
66727 +++ b/grsecurity/gracl_learn.c
66728 @@ -0,0 +1,207 @@
66729 +#include <linux/kernel.h>
66730 +#include <linux/mm.h>
66731 +#include <linux/sched.h>
66732 +#include <linux/poll.h>
66733 +#include <linux/string.h>
66734 +#include <linux/file.h>
66735 +#include <linux/types.h>
66736 +#include <linux/vmalloc.h>
66737 +#include <linux/grinternal.h>
66738 +
66739 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
66740 + size_t count, loff_t *ppos);
66741 +extern int gr_acl_is_enabled(void);
66742 +
66743 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
66744 +static int gr_learn_attached;
66745 +
66746 +/* use a 512k buffer */
66747 +#define LEARN_BUFFER_SIZE (512 * 1024)
66748 +
66749 +static DEFINE_SPINLOCK(gr_learn_lock);
66750 +static DEFINE_MUTEX(gr_learn_user_mutex);
66751 +
66752 +/* we need to maintain two buffers, so that the kernel context of grlearn
66753 + uses a semaphore around the userspace copying, and the other kernel contexts
66754 + use a spinlock when copying into the buffer, since they cannot sleep
66755 +*/
66756 +static char *learn_buffer;
66757 +static char *learn_buffer_user;
66758 +static int learn_buffer_len;
66759 +static int learn_buffer_user_len;
66760 +
66761 +static ssize_t
66762 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
66763 +{
66764 + DECLARE_WAITQUEUE(wait, current);
66765 + ssize_t retval = 0;
66766 +
66767 + add_wait_queue(&learn_wait, &wait);
66768 + set_current_state(TASK_INTERRUPTIBLE);
66769 + do {
66770 + mutex_lock(&gr_learn_user_mutex);
66771 + spin_lock(&gr_learn_lock);
66772 + if (learn_buffer_len)
66773 + break;
66774 + spin_unlock(&gr_learn_lock);
66775 + mutex_unlock(&gr_learn_user_mutex);
66776 + if (file->f_flags & O_NONBLOCK) {
66777 + retval = -EAGAIN;
66778 + goto out;
66779 + }
66780 + if (signal_pending(current)) {
66781 + retval = -ERESTARTSYS;
66782 + goto out;
66783 + }
66784 +
66785 + schedule();
66786 + } while (1);
66787 +
66788 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
66789 + learn_buffer_user_len = learn_buffer_len;
66790 + retval = learn_buffer_len;
66791 + learn_buffer_len = 0;
66792 +
66793 + spin_unlock(&gr_learn_lock);
66794 +
66795 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
66796 + retval = -EFAULT;
66797 +
66798 + mutex_unlock(&gr_learn_user_mutex);
66799 +out:
66800 + set_current_state(TASK_RUNNING);
66801 + remove_wait_queue(&learn_wait, &wait);
66802 + return retval;
66803 +}
66804 +
66805 +static unsigned int
66806 +poll_learn(struct file * file, poll_table * wait)
66807 +{
66808 + poll_wait(file, &learn_wait, wait);
66809 +
66810 + if (learn_buffer_len)
66811 + return (POLLIN | POLLRDNORM);
66812 +
66813 + return 0;
66814 +}
66815 +
66816 +void
66817 +gr_clear_learn_entries(void)
66818 +{
66819 + char *tmp;
66820 +
66821 + mutex_lock(&gr_learn_user_mutex);
66822 + spin_lock(&gr_learn_lock);
66823 + tmp = learn_buffer;
66824 + learn_buffer = NULL;
66825 + spin_unlock(&gr_learn_lock);
66826 + if (tmp)
66827 + vfree(tmp);
66828 + if (learn_buffer_user != NULL) {
66829 + vfree(learn_buffer_user);
66830 + learn_buffer_user = NULL;
66831 + }
66832 + learn_buffer_len = 0;
66833 + mutex_unlock(&gr_learn_user_mutex);
66834 +
66835 + return;
66836 +}
66837 +
66838 +void
66839 +gr_add_learn_entry(const char *fmt, ...)
66840 +{
66841 + va_list args;
66842 + unsigned int len;
66843 +
66844 + if (!gr_learn_attached)
66845 + return;
66846 +
66847 + spin_lock(&gr_learn_lock);
66848 +
66849 + /* leave a gap at the end so we know when it's "full" but don't have to
66850 + compute the exact length of the string we're trying to append
66851 + */
66852 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
66853 + spin_unlock(&gr_learn_lock);
66854 + wake_up_interruptible(&learn_wait);
66855 + return;
66856 + }
66857 + if (learn_buffer == NULL) {
66858 + spin_unlock(&gr_learn_lock);
66859 + return;
66860 + }
66861 +
66862 + va_start(args, fmt);
66863 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
66864 + va_end(args);
66865 +
66866 + learn_buffer_len += len + 1;
66867 +
66868 + spin_unlock(&gr_learn_lock);
66869 + wake_up_interruptible(&learn_wait);
66870 +
66871 + return;
66872 +}
66873 +
66874 +static int
66875 +open_learn(struct inode *inode, struct file *file)
66876 +{
66877 + if (file->f_mode & FMODE_READ && gr_learn_attached)
66878 + return -EBUSY;
66879 + if (file->f_mode & FMODE_READ) {
66880 + int retval = 0;
66881 + mutex_lock(&gr_learn_user_mutex);
66882 + if (learn_buffer == NULL)
66883 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
66884 + if (learn_buffer_user == NULL)
66885 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
66886 + if (learn_buffer == NULL) {
66887 + retval = -ENOMEM;
66888 + goto out_error;
66889 + }
66890 + if (learn_buffer_user == NULL) {
66891 + retval = -ENOMEM;
66892 + goto out_error;
66893 + }
66894 + learn_buffer_len = 0;
66895 + learn_buffer_user_len = 0;
66896 + gr_learn_attached = 1;
66897 +out_error:
66898 + mutex_unlock(&gr_learn_user_mutex);
66899 + return retval;
66900 + }
66901 + return 0;
66902 +}
66903 +
66904 +static int
66905 +close_learn(struct inode *inode, struct file *file)
66906 +{
66907 + if (file->f_mode & FMODE_READ) {
66908 + char *tmp = NULL;
66909 + mutex_lock(&gr_learn_user_mutex);
66910 + spin_lock(&gr_learn_lock);
66911 + tmp = learn_buffer;
66912 + learn_buffer = NULL;
66913 + spin_unlock(&gr_learn_lock);
66914 + if (tmp)
66915 + vfree(tmp);
66916 + if (learn_buffer_user != NULL) {
66917 + vfree(learn_buffer_user);
66918 + learn_buffer_user = NULL;
66919 + }
66920 + learn_buffer_len = 0;
66921 + learn_buffer_user_len = 0;
66922 + gr_learn_attached = 0;
66923 + mutex_unlock(&gr_learn_user_mutex);
66924 + }
66925 +
66926 + return 0;
66927 +}
66928 +
66929 +const struct file_operations grsec_fops = {
66930 + .read = read_learn,
66931 + .write = write_grsec_handler,
66932 + .open = open_learn,
66933 + .release = close_learn,
66934 + .poll = poll_learn,
66935 +};
66936 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
66937 new file mode 100644
66938 index 0000000..b38c574
66939 --- /dev/null
66940 +++ b/grsecurity/gracl_policy.c
66941 @@ -0,0 +1,1825 @@
66942 +#include <linux/kernel.h>
66943 +#include <linux/module.h>
66944 +#include <linux/sched.h>
66945 +#include <linux/mm.h>
66946 +#include <linux/file.h>
66947 +#include <linux/fs.h>
66948 +#include <linux/namei.h>
66949 +#include <linux/mount.h>
66950 +#include <linux/tty.h>
66951 +#include <linux/proc_fs.h>
66952 +#include <linux/lglock.h>
66953 +#include <linux/slab.h>
66954 +#include <linux/vmalloc.h>
66955 +#include <linux/types.h>
66956 +#include <linux/sysctl.h>
66957 +#include <linux/netdevice.h>
66958 +#include <linux/ptrace.h>
66959 +#include <linux/gracl.h>
66960 +#include <linux/gralloc.h>
66961 +#include <linux/security.h>
66962 +#include <linux/grinternal.h>
66963 +#include <linux/pid_namespace.h>
66964 +#include <linux/stop_machine.h>
66965 +#include <linux/fdtable.h>
66966 +#include <linux/percpu.h>
66967 +#include <linux/lglock.h>
66968 +#include <linux/hugetlb.h>
66969 +#include <linux/posix-timers.h>
66970 +#include "../fs/mount.h"
66971 +
66972 +#include <asm/uaccess.h>
66973 +#include <asm/errno.h>
66974 +#include <asm/mman.h>
66975 +
66976 +extern struct gr_policy_state *polstate;
66977 +
66978 +#define FOR_EACH_ROLE_START(role) \
66979 + role = polstate->role_list; \
66980 + while (role) {
66981 +
66982 +#define FOR_EACH_ROLE_END(role) \
66983 + role = role->prev; \
66984 + }
66985 +
66986 +struct path gr_real_root;
66987 +
66988 +extern struct gr_alloc_state *current_alloc_state;
66989 +
66990 +u16 acl_sp_role_value;
66991 +
66992 +static DEFINE_MUTEX(gr_dev_mutex);
66993 +
66994 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
66995 +extern void gr_clear_learn_entries(void);
66996 +
66997 +static struct gr_arg gr_usermode;
66998 +static unsigned char gr_system_salt[GR_SALT_LEN];
66999 +static unsigned char gr_system_sum[GR_SHA_LEN];
67000 +
67001 +static unsigned int gr_auth_attempts = 0;
67002 +static unsigned long gr_auth_expires = 0UL;
67003 +
67004 +struct acl_object_label *fakefs_obj_rw;
67005 +struct acl_object_label *fakefs_obj_rwx;
67006 +
67007 +extern int gr_init_uidset(void);
67008 +extern void gr_free_uidset(void);
67009 +extern void gr_remove_uid(uid_t uid);
67010 +extern int gr_find_uid(uid_t uid);
67011 +
67012 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
67013 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
67014 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
67015 +extern struct acl_role_label *__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid, const gid_t gid);
67016 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
67017 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
67018 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
67019 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
67020 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
67021 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
67022 +extern void assign_special_role(const char *rolename);
67023 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
67024 +extern int gr_rbac_disable(void *unused);
67025 +extern void gr_enable_rbac_system(void);
67026 +
67027 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
67028 +{
67029 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
67030 + return -EFAULT;
67031 +
67032 + return 0;
67033 +}
67034 +
67035 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
67036 +{
67037 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
67038 + return -EFAULT;
67039 +
67040 + return 0;
67041 +}
67042 +
67043 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
67044 +{
67045 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
67046 + return -EFAULT;
67047 +
67048 + return 0;
67049 +}
67050 +
67051 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
67052 +{
67053 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
67054 + return -EFAULT;
67055 +
67056 + return 0;
67057 +}
67058 +
67059 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
67060 +{
67061 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
67062 + return -EFAULT;
67063 +
67064 + return 0;
67065 +}
67066 +
67067 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
67068 +{
67069 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
67070 + return -EFAULT;
67071 +
67072 + return 0;
67073 +}
67074 +
67075 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
67076 +{
67077 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
67078 + return -EFAULT;
67079 +
67080 + return 0;
67081 +}
67082 +
67083 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
67084 +{
67085 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
67086 + return -EFAULT;
67087 +
67088 + return 0;
67089 +}
67090 +
67091 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
67092 +{
67093 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
67094 + return -EFAULT;
67095 +
67096 + return 0;
67097 +}
67098 +
67099 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
67100 +{
67101 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
67102 + return -EFAULT;
67103 +
67104 + if (((uwrap->version != GRSECURITY_VERSION) &&
67105 + (uwrap->version != 0x2901)) ||
67106 + (uwrap->size != sizeof(struct gr_arg)))
67107 + return -EINVAL;
67108 +
67109 + return 0;
67110 +}
67111 +
67112 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
67113 +{
67114 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
67115 + return -EFAULT;
67116 +
67117 + return 0;
67118 +}
67119 +
67120 +static size_t get_gr_arg_wrapper_size_normal(void)
67121 +{
67122 + return sizeof(struct gr_arg_wrapper);
67123 +}
67124 +
67125 +#ifdef CONFIG_COMPAT
67126 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
67127 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
67128 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
67129 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
67130 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
67131 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
67132 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
67133 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
67134 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
67135 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
67136 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
67137 +extern size_t get_gr_arg_wrapper_size_compat(void);
67138 +
67139 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
67140 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
67141 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
67142 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
67143 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
67144 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
67145 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
67146 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
67147 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
67148 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
67149 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
67150 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
67151 +
67152 +#else
67153 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
67154 +#define copy_gr_arg copy_gr_arg_normal
67155 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
67156 +#define copy_acl_object_label copy_acl_object_label_normal
67157 +#define copy_acl_subject_label copy_acl_subject_label_normal
67158 +#define copy_acl_role_label copy_acl_role_label_normal
67159 +#define copy_acl_ip_label copy_acl_ip_label_normal
67160 +#define copy_pointer_from_array copy_pointer_from_array_normal
67161 +#define copy_sprole_pw copy_sprole_pw_normal
67162 +#define copy_role_transition copy_role_transition_normal
67163 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
67164 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
67165 +#endif
67166 +
67167 +static struct acl_subject_label *
67168 +lookup_subject_map(const struct acl_subject_label *userp)
67169 +{
67170 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
67171 + struct subject_map *match;
67172 +
67173 + match = polstate->subj_map_set.s_hash[index];
67174 +
67175 + while (match && match->user != userp)
67176 + match = match->next;
67177 +
67178 + if (match != NULL)
67179 + return match->kernel;
67180 + else
67181 + return NULL;
67182 +}
67183 +
67184 +static void
67185 +insert_subj_map_entry(struct subject_map *subjmap)
67186 +{
67187 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
67188 + struct subject_map **curr;
67189 +
67190 + subjmap->prev = NULL;
67191 +
67192 + curr = &polstate->subj_map_set.s_hash[index];
67193 + if (*curr != NULL)
67194 + (*curr)->prev = subjmap;
67195 +
67196 + subjmap->next = *curr;
67197 + *curr = subjmap;
67198 +
67199 + return;
67200 +}
67201 +
67202 +static void
67203 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
67204 +{
67205 + unsigned int index =
67206 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
67207 + struct acl_role_label **curr;
67208 + struct acl_role_label *tmp, *tmp2;
67209 +
67210 + curr = &polstate->acl_role_set.r_hash[index];
67211 +
67212 + /* simple case, slot is empty, just set it to our role */
67213 + if (*curr == NULL) {
67214 + *curr = role;
67215 + } else {
67216 + /* example:
67217 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
67218 + 2 -> 3
67219 + */
67220 + /* first check to see if we can already be reached via this slot */
67221 + tmp = *curr;
67222 + while (tmp && tmp != role)
67223 + tmp = tmp->next;
67224 + if (tmp == role) {
67225 + /* we don't need to add ourselves to this slot's chain */
67226 + return;
67227 + }
67228 + /* we need to add ourselves to this chain, two cases */
67229 + if (role->next == NULL) {
67230 + /* simple case, append the current chain to our role */
67231 + role->next = *curr;
67232 + *curr = role;
67233 + } else {
67234 + /* 1 -> 2 -> 3 -> 4
67235 + 2 -> 3 -> 4
67236 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
67237 + */
67238 + /* trickier case: walk our role's chain until we find
67239 + the role for the start of the current slot's chain */
67240 + tmp = role;
67241 + tmp2 = *curr;
67242 + while (tmp->next && tmp->next != tmp2)
67243 + tmp = tmp->next;
67244 + if (tmp->next == tmp2) {
67245 + /* from example above, we found 3, so just
67246 + replace this slot's chain with ours */
67247 + *curr = role;
67248 + } else {
67249 + /* we didn't find a subset of our role's chain
67250 + in the current slot's chain, so append their
67251 + chain to ours, and set us as the first role in
67252 + the slot's chain
67253 +
67254 + we could fold this case with the case above,
67255 + but making it explicit for clarity
67256 + */
67257 + tmp->next = tmp2;
67258 + *curr = role;
67259 + }
67260 + }
67261 + }
67262 +
67263 + return;
67264 +}
67265 +
67266 +static void
67267 +insert_acl_role_label(struct acl_role_label *role)
67268 +{
67269 + int i;
67270 +
67271 + if (polstate->role_list == NULL) {
67272 + polstate->role_list = role;
67273 + role->prev = NULL;
67274 + } else {
67275 + role->prev = polstate->role_list;
67276 + polstate->role_list = role;
67277 + }
67278 +
67279 + /* used for hash chains */
67280 + role->next = NULL;
67281 +
67282 + if (role->roletype & GR_ROLE_DOMAIN) {
67283 + for (i = 0; i < role->domain_child_num; i++)
67284 + __insert_acl_role_label(role, role->domain_children[i]);
67285 + } else
67286 + __insert_acl_role_label(role, role->uidgid);
67287 +}
67288 +
67289 +static int
67290 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
67291 +{
67292 + struct name_entry **curr, *nentry;
67293 + struct inodev_entry *ientry;
67294 + unsigned int len = strlen(name);
67295 + unsigned int key = full_name_hash(name, len);
67296 + unsigned int index = key % polstate->name_set.n_size;
67297 +
67298 + curr = &polstate->name_set.n_hash[index];
67299 +
67300 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
67301 + curr = &((*curr)->next);
67302 +
67303 + if (*curr != NULL)
67304 + return 1;
67305 +
67306 + nentry = acl_alloc(sizeof (struct name_entry));
67307 + if (nentry == NULL)
67308 + return 0;
67309 + ientry = acl_alloc(sizeof (struct inodev_entry));
67310 + if (ientry == NULL)
67311 + return 0;
67312 + ientry->nentry = nentry;
67313 +
67314 + nentry->key = key;
67315 + nentry->name = name;
67316 + nentry->inode = inode;
67317 + nentry->device = device;
67318 + nentry->len = len;
67319 + nentry->deleted = deleted;
67320 +
67321 + nentry->prev = NULL;
67322 + curr = &polstate->name_set.n_hash[index];
67323 + if (*curr != NULL)
67324 + (*curr)->prev = nentry;
67325 + nentry->next = *curr;
67326 + *curr = nentry;
67327 +
67328 + /* insert us into the table searchable by inode/dev */
67329 + __insert_inodev_entry(polstate, ientry);
67330 +
67331 + return 1;
67332 +}
67333 +
67334 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
67335 +
67336 +static void *
67337 +create_table(__u32 * len, int elementsize)
67338 +{
67339 + unsigned int table_sizes[] = {
67340 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
67341 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
67342 + 4194301, 8388593, 16777213, 33554393, 67108859
67343 + };
67344 + void *newtable = NULL;
67345 + unsigned int pwr = 0;
67346 +
67347 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
67348 + table_sizes[pwr] <= *len)
67349 + pwr++;
67350 +
67351 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
67352 + return newtable;
67353 +
67354 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
67355 + newtable =
67356 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
67357 + else
67358 + newtable = vmalloc(table_sizes[pwr] * elementsize);
67359 +
67360 + *len = table_sizes[pwr];
67361 +
67362 + return newtable;
67363 +}
67364 +
67365 +static int
67366 +init_variables(const struct gr_arg *arg, bool reload)
67367 +{
67368 + struct task_struct *reaper = init_pid_ns.child_reaper;
67369 + unsigned int stacksize;
67370 +
67371 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
67372 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
67373 + polstate->name_set.n_size = arg->role_db.num_objects;
67374 + polstate->inodev_set.i_size = arg->role_db.num_objects;
67375 +
67376 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
67377 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
67378 + return 1;
67379 +
67380 + if (!reload) {
67381 + if (!gr_init_uidset())
67382 + return 1;
67383 + }
67384 +
67385 + /* set up the stack that holds allocation info */
67386 +
67387 + stacksize = arg->role_db.num_pointers + 5;
67388 +
67389 + if (!acl_alloc_stack_init(stacksize))
67390 + return 1;
67391 +
67392 + if (!reload) {
67393 + /* grab reference for the real root dentry and vfsmount */
67394 + get_fs_root(reaper->fs, &gr_real_root);
67395 +
67396 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67397 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(gr_real_root.dentry), gr_real_root.dentry->d_inode->i_ino);
67398 +#endif
67399 +
67400 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
67401 + if (fakefs_obj_rw == NULL)
67402 + return 1;
67403 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
67404 +
67405 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
67406 + if (fakefs_obj_rwx == NULL)
67407 + return 1;
67408 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
67409 + }
67410 +
67411 + polstate->subj_map_set.s_hash =
67412 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
67413 + polstate->acl_role_set.r_hash =
67414 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
67415 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
67416 + polstate->inodev_set.i_hash =
67417 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
67418 +
67419 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
67420 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
67421 + return 1;
67422 +
67423 + memset(polstate->subj_map_set.s_hash, 0,
67424 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
67425 + memset(polstate->acl_role_set.r_hash, 0,
67426 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
67427 + memset(polstate->name_set.n_hash, 0,
67428 + sizeof (struct name_entry *) * polstate->name_set.n_size);
67429 + memset(polstate->inodev_set.i_hash, 0,
67430 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
67431 +
67432 + return 0;
67433 +}
67434 +
67435 +/* free information not needed after startup
67436 + currently contains user->kernel pointer mappings for subjects
67437 +*/
67438 +
67439 +static void
67440 +free_init_variables(void)
67441 +{
67442 + __u32 i;
67443 +
67444 + if (polstate->subj_map_set.s_hash) {
67445 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
67446 + if (polstate->subj_map_set.s_hash[i]) {
67447 + kfree(polstate->subj_map_set.s_hash[i]);
67448 + polstate->subj_map_set.s_hash[i] = NULL;
67449 + }
67450 + }
67451 +
67452 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
67453 + PAGE_SIZE)
67454 + kfree(polstate->subj_map_set.s_hash);
67455 + else
67456 + vfree(polstate->subj_map_set.s_hash);
67457 + }
67458 +
67459 + return;
67460 +}
67461 +
67462 +static void
67463 +free_variables(bool reload)
67464 +{
67465 + struct acl_subject_label *s;
67466 + struct acl_role_label *r;
67467 + struct task_struct *task, *task2;
67468 + unsigned int x;
67469 +
67470 + if (!reload) {
67471 + gr_clear_learn_entries();
67472 +
67473 + read_lock(&tasklist_lock);
67474 + do_each_thread(task2, task) {
67475 + task->acl_sp_role = 0;
67476 + task->acl_role_id = 0;
67477 + task->inherited = 0;
67478 + task->acl = NULL;
67479 + task->role = NULL;
67480 + } while_each_thread(task2, task);
67481 + read_unlock(&tasklist_lock);
67482 +
67483 + /* release the reference to the real root dentry and vfsmount */
67484 + path_put(&gr_real_root);
67485 + memset(&gr_real_root, 0, sizeof(gr_real_root));
67486 + }
67487 +
67488 + /* free all object hash tables */
67489 +
67490 + FOR_EACH_ROLE_START(r)
67491 + if (r->subj_hash == NULL)
67492 + goto next_role;
67493 + FOR_EACH_SUBJECT_START(r, s, x)
67494 + if (s->obj_hash == NULL)
67495 + break;
67496 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
67497 + kfree(s->obj_hash);
67498 + else
67499 + vfree(s->obj_hash);
67500 + FOR_EACH_SUBJECT_END(s, x)
67501 + FOR_EACH_NESTED_SUBJECT_START(r, s)
67502 + if (s->obj_hash == NULL)
67503 + break;
67504 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
67505 + kfree(s->obj_hash);
67506 + else
67507 + vfree(s->obj_hash);
67508 + FOR_EACH_NESTED_SUBJECT_END(s)
67509 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
67510 + kfree(r->subj_hash);
67511 + else
67512 + vfree(r->subj_hash);
67513 + r->subj_hash = NULL;
67514 +next_role:
67515 + FOR_EACH_ROLE_END(r)
67516 +
67517 + acl_free_all();
67518 +
67519 + if (polstate->acl_role_set.r_hash) {
67520 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
67521 + PAGE_SIZE)
67522 + kfree(polstate->acl_role_set.r_hash);
67523 + else
67524 + vfree(polstate->acl_role_set.r_hash);
67525 + }
67526 + if (polstate->name_set.n_hash) {
67527 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
67528 + PAGE_SIZE)
67529 + kfree(polstate->name_set.n_hash);
67530 + else
67531 + vfree(polstate->name_set.n_hash);
67532 + }
67533 +
67534 + if (polstate->inodev_set.i_hash) {
67535 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
67536 + PAGE_SIZE)
67537 + kfree(polstate->inodev_set.i_hash);
67538 + else
67539 + vfree(polstate->inodev_set.i_hash);
67540 + }
67541 +
67542 + if (!reload)
67543 + gr_free_uidset();
67544 +
67545 + memset(&polstate->name_set, 0, sizeof (struct name_db));
67546 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
67547 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
67548 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
67549 +
67550 + polstate->default_role = NULL;
67551 + polstate->kernel_role = NULL;
67552 + polstate->role_list = NULL;
67553 +
67554 + return;
67555 +}
67556 +
67557 +static struct acl_subject_label *
67558 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
67559 +
67560 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
67561 +{
67562 + unsigned int len = strnlen_user(*name, maxlen);
67563 + char *tmp;
67564 +
67565 + if (!len || len >= maxlen)
67566 + return -EINVAL;
67567 +
67568 + if ((tmp = (char *) acl_alloc(len)) == NULL)
67569 + return -ENOMEM;
67570 +
67571 + if (copy_from_user(tmp, *name, len))
67572 + return -EFAULT;
67573 +
67574 + tmp[len-1] = '\0';
67575 + *name = tmp;
67576 +
67577 + return 0;
67578 +}
67579 +
67580 +static int
67581 +copy_user_glob(struct acl_object_label *obj)
67582 +{
67583 + struct acl_object_label *g_tmp, **guser;
67584 + int error;
67585 +
67586 + if (obj->globbed == NULL)
67587 + return 0;
67588 +
67589 + guser = &obj->globbed;
67590 + while (*guser) {
67591 + g_tmp = (struct acl_object_label *)
67592 + acl_alloc(sizeof (struct acl_object_label));
67593 + if (g_tmp == NULL)
67594 + return -ENOMEM;
67595 +
67596 + if (copy_acl_object_label(g_tmp, *guser))
67597 + return -EFAULT;
67598 +
67599 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
67600 + if (error)
67601 + return error;
67602 +
67603 + *guser = g_tmp;
67604 + guser = &(g_tmp->next);
67605 + }
67606 +
67607 + return 0;
67608 +}
67609 +
67610 +static int
67611 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
67612 + struct acl_role_label *role)
67613 +{
67614 + struct acl_object_label *o_tmp;
67615 + int ret;
67616 +
67617 + while (userp) {
67618 + if ((o_tmp = (struct acl_object_label *)
67619 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
67620 + return -ENOMEM;
67621 +
67622 + if (copy_acl_object_label(o_tmp, userp))
67623 + return -EFAULT;
67624 +
67625 + userp = o_tmp->prev;
67626 +
67627 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
67628 + if (ret)
67629 + return ret;
67630 +
67631 + insert_acl_obj_label(o_tmp, subj);
67632 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
67633 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
67634 + return -ENOMEM;
67635 +
67636 + ret = copy_user_glob(o_tmp);
67637 + if (ret)
67638 + return ret;
67639 +
67640 + if (o_tmp->nested) {
67641 + int already_copied;
67642 +
67643 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
67644 + if (IS_ERR(o_tmp->nested))
67645 + return PTR_ERR(o_tmp->nested);
67646 +
67647 + /* insert into nested subject list if we haven't copied this one yet
67648 + to prevent duplicate entries */
67649 + if (!already_copied) {
67650 + o_tmp->nested->next = role->hash->first;
67651 + role->hash->first = o_tmp->nested;
67652 + }
67653 + }
67654 + }
67655 +
67656 + return 0;
67657 +}
67658 +
67659 +static __u32
67660 +count_user_subjs(struct acl_subject_label *userp)
67661 +{
67662 + struct acl_subject_label s_tmp;
67663 + __u32 num = 0;
67664 +
67665 + while (userp) {
67666 + if (copy_acl_subject_label(&s_tmp, userp))
67667 + break;
67668 +
67669 + userp = s_tmp.prev;
67670 + }
67671 +
67672 + return num;
67673 +}
67674 +
67675 +static int
67676 +copy_user_allowedips(struct acl_role_label *rolep)
67677 +{
67678 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
67679 +
67680 + ruserip = rolep->allowed_ips;
67681 +
67682 + while (ruserip) {
67683 + rlast = rtmp;
67684 +
67685 + if ((rtmp = (struct role_allowed_ip *)
67686 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
67687 + return -ENOMEM;
67688 +
67689 + if (copy_role_allowed_ip(rtmp, ruserip))
67690 + return -EFAULT;
67691 +
67692 + ruserip = rtmp->prev;
67693 +
67694 + if (!rlast) {
67695 + rtmp->prev = NULL;
67696 + rolep->allowed_ips = rtmp;
67697 + } else {
67698 + rlast->next = rtmp;
67699 + rtmp->prev = rlast;
67700 + }
67701 +
67702 + if (!ruserip)
67703 + rtmp->next = NULL;
67704 + }
67705 +
67706 + return 0;
67707 +}
67708 +
67709 +static int
67710 +copy_user_transitions(struct acl_role_label *rolep)
67711 +{
67712 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
67713 + int error;
67714 +
67715 + rusertp = rolep->transitions;
67716 +
67717 + while (rusertp) {
67718 + rlast = rtmp;
67719 +
67720 + if ((rtmp = (struct role_transition *)
67721 + acl_alloc(sizeof (struct role_transition))) == NULL)
67722 + return -ENOMEM;
67723 +
67724 + if (copy_role_transition(rtmp, rusertp))
67725 + return -EFAULT;
67726 +
67727 + rusertp = rtmp->prev;
67728 +
67729 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
67730 + if (error)
67731 + return error;
67732 +
67733 + if (!rlast) {
67734 + rtmp->prev = NULL;
67735 + rolep->transitions = rtmp;
67736 + } else {
67737 + rlast->next = rtmp;
67738 + rtmp->prev = rlast;
67739 + }
67740 +
67741 + if (!rusertp)
67742 + rtmp->next = NULL;
67743 + }
67744 +
67745 + return 0;
67746 +}
67747 +
67748 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
67749 +{
67750 + struct acl_object_label o_tmp;
67751 + __u32 num = 0;
67752 +
67753 + while (userp) {
67754 + if (copy_acl_object_label(&o_tmp, userp))
67755 + break;
67756 +
67757 + userp = o_tmp.prev;
67758 + num++;
67759 + }
67760 +
67761 + return num;
67762 +}
67763 +
67764 +static struct acl_subject_label *
67765 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
67766 +{
67767 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
67768 + __u32 num_objs;
67769 + struct acl_ip_label **i_tmp, *i_utmp2;
67770 + struct gr_hash_struct ghash;
67771 + struct subject_map *subjmap;
67772 + unsigned int i_num;
67773 + int err;
67774 +
67775 + if (already_copied != NULL)
67776 + *already_copied = 0;
67777 +
67778 + s_tmp = lookup_subject_map(userp);
67779 +
67780 + /* we've already copied this subject into the kernel, just return
67781 + the reference to it, and don't copy it over again
67782 + */
67783 + if (s_tmp) {
67784 + if (already_copied != NULL)
67785 + *already_copied = 1;
67786 + return(s_tmp);
67787 + }
67788 +
67789 + if ((s_tmp = (struct acl_subject_label *)
67790 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
67791 + return ERR_PTR(-ENOMEM);
67792 +
67793 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
67794 + if (subjmap == NULL)
67795 + return ERR_PTR(-ENOMEM);
67796 +
67797 + subjmap->user = userp;
67798 + subjmap->kernel = s_tmp;
67799 + insert_subj_map_entry(subjmap);
67800 +
67801 + if (copy_acl_subject_label(s_tmp, userp))
67802 + return ERR_PTR(-EFAULT);
67803 +
67804 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
67805 + if (err)
67806 + return ERR_PTR(err);
67807 +
67808 + if (!strcmp(s_tmp->filename, "/"))
67809 + role->root_label = s_tmp;
67810 +
67811 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
67812 + return ERR_PTR(-EFAULT);
67813 +
67814 + /* copy user and group transition tables */
67815 +
67816 + if (s_tmp->user_trans_num) {
67817 + uid_t *uidlist;
67818 +
67819 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
67820 + if (uidlist == NULL)
67821 + return ERR_PTR(-ENOMEM);
67822 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
67823 + return ERR_PTR(-EFAULT);
67824 +
67825 + s_tmp->user_transitions = uidlist;
67826 + }
67827 +
67828 + if (s_tmp->group_trans_num) {
67829 + gid_t *gidlist;
67830 +
67831 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
67832 + if (gidlist == NULL)
67833 + return ERR_PTR(-ENOMEM);
67834 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
67835 + return ERR_PTR(-EFAULT);
67836 +
67837 + s_tmp->group_transitions = gidlist;
67838 + }
67839 +
67840 + /* set up object hash table */
67841 + num_objs = count_user_objs(ghash.first);
67842 +
67843 + s_tmp->obj_hash_size = num_objs;
67844 + s_tmp->obj_hash =
67845 + (struct acl_object_label **)
67846 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
67847 +
67848 + if (!s_tmp->obj_hash)
67849 + return ERR_PTR(-ENOMEM);
67850 +
67851 + memset(s_tmp->obj_hash, 0,
67852 + s_tmp->obj_hash_size *
67853 + sizeof (struct acl_object_label *));
67854 +
67855 + /* add in objects */
67856 + err = copy_user_objs(ghash.first, s_tmp, role);
67857 +
67858 + if (err)
67859 + return ERR_PTR(err);
67860 +
67861 + /* set pointer for parent subject */
67862 + if (s_tmp->parent_subject) {
67863 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
67864 +
67865 + if (IS_ERR(s_tmp2))
67866 + return s_tmp2;
67867 +
67868 + s_tmp->parent_subject = s_tmp2;
67869 + }
67870 +
67871 + /* add in ip acls */
67872 +
67873 + if (!s_tmp->ip_num) {
67874 + s_tmp->ips = NULL;
67875 + goto insert;
67876 + }
67877 +
67878 + i_tmp =
67879 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
67880 + sizeof (struct acl_ip_label *));
67881 +
67882 + if (!i_tmp)
67883 + return ERR_PTR(-ENOMEM);
67884 +
67885 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
67886 + *(i_tmp + i_num) =
67887 + (struct acl_ip_label *)
67888 + acl_alloc(sizeof (struct acl_ip_label));
67889 + if (!*(i_tmp + i_num))
67890 + return ERR_PTR(-ENOMEM);
67891 +
67892 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
67893 + return ERR_PTR(-EFAULT);
67894 +
67895 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
67896 + return ERR_PTR(-EFAULT);
67897 +
67898 + if ((*(i_tmp + i_num))->iface == NULL)
67899 + continue;
67900 +
67901 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
67902 + if (err)
67903 + return ERR_PTR(err);
67904 + }
67905 +
67906 + s_tmp->ips = i_tmp;
67907 +
67908 +insert:
67909 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
67910 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
67911 + return ERR_PTR(-ENOMEM);
67912 +
67913 + return s_tmp;
67914 +}
67915 +
67916 +static int
67917 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
67918 +{
67919 + struct acl_subject_label s_pre;
67920 + struct acl_subject_label * ret;
67921 + int err;
67922 +
67923 + while (userp) {
67924 + if (copy_acl_subject_label(&s_pre, userp))
67925 + return -EFAULT;
67926 +
67927 + ret = do_copy_user_subj(userp, role, NULL);
67928 +
67929 + err = PTR_ERR(ret);
67930 + if (IS_ERR(ret))
67931 + return err;
67932 +
67933 + insert_acl_subj_label(ret, role);
67934 +
67935 + userp = s_pre.prev;
67936 + }
67937 +
67938 + return 0;
67939 +}
67940 +
67941 +static int
67942 +copy_user_acl(struct gr_arg *arg)
67943 +{
67944 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
67945 + struct acl_subject_label *subj_list;
67946 + struct sprole_pw *sptmp;
67947 + struct gr_hash_struct *ghash;
67948 + uid_t *domainlist;
67949 + unsigned int r_num;
67950 + int err = 0;
67951 + __u16 i;
67952 + __u32 num_subjs;
67953 +
67954 + /* we need a default and kernel role */
67955 + if (arg->role_db.num_roles < 2)
67956 + return -EINVAL;
67957 +
67958 + /* copy special role authentication info from userspace */
67959 +
67960 + polstate->num_sprole_pws = arg->num_sprole_pws;
67961 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
67962 +
67963 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
67964 + return -ENOMEM;
67965 +
67966 + for (i = 0; i < polstate->num_sprole_pws; i++) {
67967 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
67968 + if (!sptmp)
67969 + return -ENOMEM;
67970 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
67971 + return -EFAULT;
67972 +
67973 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
67974 + if (err)
67975 + return err;
67976 +
67977 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67978 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
67979 +#endif
67980 +
67981 + polstate->acl_special_roles[i] = sptmp;
67982 + }
67983 +
67984 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
67985 +
67986 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
67987 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
67988 +
67989 + if (!r_tmp)
67990 + return -ENOMEM;
67991 +
67992 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
67993 + return -EFAULT;
67994 +
67995 + if (copy_acl_role_label(r_tmp, r_utmp2))
67996 + return -EFAULT;
67997 +
67998 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
67999 + if (err)
68000 + return err;
68001 +
68002 + if (!strcmp(r_tmp->rolename, "default")
68003 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
68004 + polstate->default_role = r_tmp;
68005 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
68006 + polstate->kernel_role = r_tmp;
68007 + }
68008 +
68009 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
68010 + return -ENOMEM;
68011 +
68012 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
68013 + return -EFAULT;
68014 +
68015 + r_tmp->hash = ghash;
68016 +
68017 + num_subjs = count_user_subjs(r_tmp->hash->first);
68018 +
68019 + r_tmp->subj_hash_size = num_subjs;
68020 + r_tmp->subj_hash =
68021 + (struct acl_subject_label **)
68022 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
68023 +
68024 + if (!r_tmp->subj_hash)
68025 + return -ENOMEM;
68026 +
68027 + err = copy_user_allowedips(r_tmp);
68028 + if (err)
68029 + return err;
68030 +
68031 + /* copy domain info */
68032 + if (r_tmp->domain_children != NULL) {
68033 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
68034 + if (domainlist == NULL)
68035 + return -ENOMEM;
68036 +
68037 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
68038 + return -EFAULT;
68039 +
68040 + r_tmp->domain_children = domainlist;
68041 + }
68042 +
68043 + err = copy_user_transitions(r_tmp);
68044 + if (err)
68045 + return err;
68046 +
68047 + memset(r_tmp->subj_hash, 0,
68048 + r_tmp->subj_hash_size *
68049 + sizeof (struct acl_subject_label *));
68050 +
68051 + /* acquire the list of subjects, then NULL out
68052 + the list prior to parsing the subjects for this role,
68053 + as during this parsing the list is replaced with a list
68054 + of *nested* subjects for the role
68055 + */
68056 + subj_list = r_tmp->hash->first;
68057 +
68058 + /* set nested subject list to null */
68059 + r_tmp->hash->first = NULL;
68060 +
68061 + err = copy_user_subjs(subj_list, r_tmp);
68062 +
68063 + if (err)
68064 + return err;
68065 +
68066 + insert_acl_role_label(r_tmp);
68067 + }
68068 +
68069 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
68070 + return -EINVAL;
68071 +
68072 + return err;
68073 +}
68074 +
68075 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
68076 +{
68077 + char *tmpname;
68078 + struct acl_subject_label *tmpsubj;
68079 + struct file *filp;
68080 + struct name_entry *nmatch;
68081 +
68082 + filp = task->exec_file;
68083 + if (filp == NULL)
68084 + return NULL;
68085 +
68086 + /* the following is to apply the correct subject
68087 + on binaries running when the RBAC system
68088 + is enabled, when the binaries have been
68089 + replaced or deleted since their execution
68090 + -----
68091 + when the RBAC system starts, the inode/dev
68092 + from exec_file will be one the RBAC system
68093 + is unaware of. It only knows the inode/dev
68094 + of the present file on disk, or the absence
68095 + of it.
68096 + */
68097 +
68098 + if (filename)
68099 + nmatch = __lookup_name_entry(polstate, filename);
68100 + else {
68101 + preempt_disable();
68102 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
68103 +
68104 + nmatch = __lookup_name_entry(polstate, tmpname);
68105 + preempt_enable();
68106 + }
68107 + tmpsubj = NULL;
68108 + if (nmatch) {
68109 + if (nmatch->deleted)
68110 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
68111 + else
68112 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
68113 + }
68114 + /* this also works for the reload case -- if we don't match a potentially inherited subject
68115 + then we fall back to a normal lookup based on the binary's ino/dev
68116 + */
68117 + if (tmpsubj == NULL)
68118 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
68119 + task->role);
68120 +
68121 + return tmpsubj;
68122 +}
68123 +
68124 +static int gracl_reload_apply_policies(void *reload)
68125 +{
68126 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
68127 + struct task_struct *task, *task2;
68128 + struct acl_role_label *role, *rtmp;
68129 + struct acl_subject_label *subj;
68130 + const struct cred *cred;
68131 + int role_applied;
68132 + int ret = 0;
68133 +
68134 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
68135 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
68136 +
68137 + /* first make sure we'll be able to apply the new policy cleanly */
68138 + do_each_thread(task2, task) {
68139 + if (task->exec_file == NULL)
68140 + continue;
68141 + role_applied = 0;
68142 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68143 + /* preserve special roles */
68144 + FOR_EACH_ROLE_START(role)
68145 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68146 + rtmp = task->role;
68147 + task->role = role;
68148 + role_applied = 1;
68149 + break;
68150 + }
68151 + FOR_EACH_ROLE_END(role)
68152 + }
68153 + if (!role_applied) {
68154 + cred = __task_cred(task);
68155 + rtmp = task->role;
68156 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68157 + }
68158 + /* this handles non-nested inherited subjects, nested subjects will still
68159 + be dropped currently */
68160 + subj = gr_get_subject_for_task(task, task->acl->filename);
68161 + task->tmpacl = gr_get_subject_for_task(task, NULL);
68162 + /* change the role back so that we've made no modifications to the policy */
68163 + task->role = rtmp;
68164 +
68165 + if (subj == NULL || task->tmpacl == NULL) {
68166 + ret = -EINVAL;
68167 + goto out;
68168 + }
68169 + } while_each_thread(task2, task);
68170 +
68171 + /* now actually apply the policy */
68172 +
68173 + do_each_thread(task2, task) {
68174 + if (task->exec_file) {
68175 + role_applied = 0;
68176 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68177 + /* preserve special roles */
68178 + FOR_EACH_ROLE_START(role)
68179 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68180 + task->role = role;
68181 + role_applied = 1;
68182 + break;
68183 + }
68184 + FOR_EACH_ROLE_END(role)
68185 + }
68186 + if (!role_applied) {
68187 + cred = __task_cred(task);
68188 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68189 + }
68190 + /* this handles non-nested inherited subjects, nested subjects will still
68191 + be dropped currently */
68192 + if (!reload_state->oldmode && task->inherited)
68193 + subj = gr_get_subject_for_task(task, task->acl->filename);
68194 + else {
68195 + /* looked up and tagged to the task previously */
68196 + subj = task->tmpacl;
68197 + }
68198 + /* subj will be non-null */
68199 + __gr_apply_subject_to_task(polstate, task, subj);
68200 + if (reload_state->oldmode) {
68201 + task->acl_role_id = 0;
68202 + task->acl_sp_role = 0;
68203 + task->inherited = 0;
68204 + }
68205 + } else {
68206 + // it's a kernel process
68207 + task->role = polstate->kernel_role;
68208 + task->acl = polstate->kernel_role->root_label;
68209 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68210 + task->acl->mode &= ~GR_PROCFIND;
68211 +#endif
68212 + }
68213 + } while_each_thread(task2, task);
68214 +
68215 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
68216 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
68217 +
68218 +out:
68219 +
68220 + return ret;
68221 +}
68222 +
68223 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
68224 +{
68225 + struct gr_reload_state new_reload_state = { };
68226 + int err;
68227 +
68228 + new_reload_state.oldpolicy_ptr = polstate;
68229 + new_reload_state.oldalloc_ptr = current_alloc_state;
68230 + new_reload_state.oldmode = oldmode;
68231 +
68232 + current_alloc_state = &new_reload_state.newalloc;
68233 + polstate = &new_reload_state.newpolicy;
68234 +
68235 + /* everything relevant is now saved off, copy in the new policy */
68236 + if (init_variables(args, true)) {
68237 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68238 + err = -ENOMEM;
68239 + goto error;
68240 + }
68241 +
68242 + err = copy_user_acl(args);
68243 + free_init_variables();
68244 + if (err)
68245 + goto error;
68246 + /* the new policy is copied in, with the old policy available via saved_state
68247 + first go through applying roles, making sure to preserve special roles
68248 + then apply new subjects, making sure to preserve inherited and nested subjects,
68249 + though currently only inherited subjects will be preserved
68250 + */
68251 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
68252 + if (err)
68253 + goto error;
68254 +
68255 + /* we've now applied the new policy, so restore the old policy state to free it */
68256 + polstate = &new_reload_state.oldpolicy;
68257 + current_alloc_state = &new_reload_state.oldalloc;
68258 + free_variables(true);
68259 +
68260 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
68261 + to running_polstate/current_alloc_state inside stop_machine
68262 + */
68263 + err = 0;
68264 + goto out;
68265 +error:
68266 + /* on error of loading the new policy, we'll just keep the previous
68267 + policy set around
68268 + */
68269 + free_variables(true);
68270 +
68271 + /* doesn't affect runtime, but maintains consistent state */
68272 +out:
68273 + polstate = new_reload_state.oldpolicy_ptr;
68274 + current_alloc_state = new_reload_state.oldalloc_ptr;
68275 +
68276 + return err;
68277 +}
68278 +
68279 +static int
68280 +gracl_init(struct gr_arg *args)
68281 +{
68282 + int error = 0;
68283 +
68284 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
68285 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
68286 +
68287 + if (init_variables(args, false)) {
68288 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68289 + error = -ENOMEM;
68290 + goto out;
68291 + }
68292 +
68293 + error = copy_user_acl(args);
68294 + free_init_variables();
68295 + if (error)
68296 + goto out;
68297 +
68298 + error = gr_set_acls(0);
68299 + if (error)
68300 + goto out;
68301 +
68302 + gr_enable_rbac_system();
68303 +
68304 + return 0;
68305 +
68306 +out:
68307 + free_variables(false);
68308 + return error;
68309 +}
68310 +
68311 +static int
68312 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
68313 + unsigned char **sum)
68314 +{
68315 + struct acl_role_label *r;
68316 + struct role_allowed_ip *ipp;
68317 + struct role_transition *trans;
68318 + unsigned int i;
68319 + int found = 0;
68320 + u32 curr_ip = current->signal->curr_ip;
68321 +
68322 + current->signal->saved_ip = curr_ip;
68323 +
68324 + /* check transition table */
68325 +
68326 + for (trans = current->role->transitions; trans; trans = trans->next) {
68327 + if (!strcmp(rolename, trans->rolename)) {
68328 + found = 1;
68329 + break;
68330 + }
68331 + }
68332 +
68333 + if (!found)
68334 + return 0;
68335 +
68336 + /* handle special roles that do not require authentication
68337 + and check ip */
68338 +
68339 + FOR_EACH_ROLE_START(r)
68340 + if (!strcmp(rolename, r->rolename) &&
68341 + (r->roletype & GR_ROLE_SPECIAL)) {
68342 + found = 0;
68343 + if (r->allowed_ips != NULL) {
68344 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
68345 + if ((ntohl(curr_ip) & ipp->netmask) ==
68346 + (ntohl(ipp->addr) & ipp->netmask))
68347 + found = 1;
68348 + }
68349 + } else
68350 + found = 2;
68351 + if (!found)
68352 + return 0;
68353 +
68354 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
68355 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
68356 + *salt = NULL;
68357 + *sum = NULL;
68358 + return 1;
68359 + }
68360 + }
68361 + FOR_EACH_ROLE_END(r)
68362 +
68363 + for (i = 0; i < polstate->num_sprole_pws; i++) {
68364 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
68365 + *salt = polstate->acl_special_roles[i]->salt;
68366 + *sum = polstate->acl_special_roles[i]->sum;
68367 + return 1;
68368 + }
68369 + }
68370 +
68371 + return 0;
68372 +}
68373 +
68374 +int gr_check_secure_terminal(struct task_struct *task)
68375 +{
68376 + struct task_struct *p, *p2, *p3;
68377 + struct files_struct *files;
68378 + struct fdtable *fdt;
68379 + struct file *our_file = NULL, *file;
68380 + int i;
68381 +
68382 + if (task->signal->tty == NULL)
68383 + return 1;
68384 +
68385 + files = get_files_struct(task);
68386 + if (files != NULL) {
68387 + rcu_read_lock();
68388 + fdt = files_fdtable(files);
68389 + for (i=0; i < fdt->max_fds; i++) {
68390 + file = fcheck_files(files, i);
68391 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
68392 + get_file(file);
68393 + our_file = file;
68394 + }
68395 + }
68396 + rcu_read_unlock();
68397 + put_files_struct(files);
68398 + }
68399 +
68400 + if (our_file == NULL)
68401 + return 1;
68402 +
68403 + read_lock(&tasklist_lock);
68404 + do_each_thread(p2, p) {
68405 + files = get_files_struct(p);
68406 + if (files == NULL ||
68407 + (p->signal && p->signal->tty == task->signal->tty)) {
68408 + if (files != NULL)
68409 + put_files_struct(files);
68410 + continue;
68411 + }
68412 + rcu_read_lock();
68413 + fdt = files_fdtable(files);
68414 + for (i=0; i < fdt->max_fds; i++) {
68415 + file = fcheck_files(files, i);
68416 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
68417 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
68418 + p3 = task;
68419 + while (task_pid_nr(p3) > 0) {
68420 + if (p3 == p)
68421 + break;
68422 + p3 = p3->real_parent;
68423 + }
68424 + if (p3 == p)
68425 + break;
68426 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
68427 + gr_handle_alertkill(p);
68428 + rcu_read_unlock();
68429 + put_files_struct(files);
68430 + read_unlock(&tasklist_lock);
68431 + fput(our_file);
68432 + return 0;
68433 + }
68434 + }
68435 + rcu_read_unlock();
68436 + put_files_struct(files);
68437 + } while_each_thread(p2, p);
68438 + read_unlock(&tasklist_lock);
68439 +
68440 + fput(our_file);
68441 + return 1;
68442 +}
68443 +
68444 +ssize_t
68445 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
68446 +{
68447 + struct gr_arg_wrapper uwrap;
68448 + unsigned char *sprole_salt = NULL;
68449 + unsigned char *sprole_sum = NULL;
68450 + int error = 0;
68451 + int error2 = 0;
68452 + size_t req_count = 0;
68453 + unsigned char oldmode = 0;
68454 +
68455 + mutex_lock(&gr_dev_mutex);
68456 +
68457 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
68458 + error = -EPERM;
68459 + goto out;
68460 + }
68461 +
68462 +#ifdef CONFIG_COMPAT
68463 + pax_open_kernel();
68464 + if (is_compat_task()) {
68465 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
68466 + copy_gr_arg = &copy_gr_arg_compat;
68467 + copy_acl_object_label = &copy_acl_object_label_compat;
68468 + copy_acl_subject_label = &copy_acl_subject_label_compat;
68469 + copy_acl_role_label = &copy_acl_role_label_compat;
68470 + copy_acl_ip_label = &copy_acl_ip_label_compat;
68471 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
68472 + copy_role_transition = &copy_role_transition_compat;
68473 + copy_sprole_pw = &copy_sprole_pw_compat;
68474 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
68475 + copy_pointer_from_array = &copy_pointer_from_array_compat;
68476 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
68477 + } else {
68478 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
68479 + copy_gr_arg = &copy_gr_arg_normal;
68480 + copy_acl_object_label = &copy_acl_object_label_normal;
68481 + copy_acl_subject_label = &copy_acl_subject_label_normal;
68482 + copy_acl_role_label = &copy_acl_role_label_normal;
68483 + copy_acl_ip_label = &copy_acl_ip_label_normal;
68484 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
68485 + copy_role_transition = &copy_role_transition_normal;
68486 + copy_sprole_pw = &copy_sprole_pw_normal;
68487 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
68488 + copy_pointer_from_array = &copy_pointer_from_array_normal;
68489 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
68490 + }
68491 + pax_close_kernel();
68492 +#endif
68493 +
68494 + req_count = get_gr_arg_wrapper_size();
68495 +
68496 + if (count != req_count) {
68497 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
68498 + error = -EINVAL;
68499 + goto out;
68500 + }
68501 +
68502 +
68503 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
68504 + gr_auth_expires = 0;
68505 + gr_auth_attempts = 0;
68506 + }
68507 +
68508 + error = copy_gr_arg_wrapper(buf, &uwrap);
68509 + if (error)
68510 + goto out;
68511 +
68512 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
68513 + if (error)
68514 + goto out;
68515 +
68516 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
68517 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68518 + time_after(gr_auth_expires, get_seconds())) {
68519 + error = -EBUSY;
68520 + goto out;
68521 + }
68522 +
68523 + /* if non-root trying to do anything other than use a special role,
68524 + do not attempt authentication, do not count towards authentication
68525 + locking
68526 + */
68527 +
68528 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
68529 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
68530 + gr_is_global_nonroot(current_uid())) {
68531 + error = -EPERM;
68532 + goto out;
68533 + }
68534 +
68535 + /* ensure pw and special role name are null terminated */
68536 +
68537 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
68538 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
68539 +
68540 + /* Okay.
68541 + * We have our enough of the argument structure..(we have yet
68542 + * to copy_from_user the tables themselves) . Copy the tables
68543 + * only if we need them, i.e. for loading operations. */
68544 +
68545 + switch (gr_usermode.mode) {
68546 + case GR_STATUS:
68547 + if (gr_acl_is_enabled()) {
68548 + error = 1;
68549 + if (!gr_check_secure_terminal(current))
68550 + error = 3;
68551 + } else
68552 + error = 2;
68553 + goto out;
68554 + case GR_SHUTDOWN:
68555 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68556 + stop_machine(gr_rbac_disable, NULL, NULL);
68557 + free_variables(false);
68558 + memset(&gr_usermode, 0, sizeof(gr_usermode));
68559 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
68560 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
68561 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
68562 + } else if (gr_acl_is_enabled()) {
68563 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
68564 + error = -EPERM;
68565 + } else {
68566 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
68567 + error = -EAGAIN;
68568 + }
68569 + break;
68570 + case GR_ENABLE:
68571 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
68572 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
68573 + else {
68574 + if (gr_acl_is_enabled())
68575 + error = -EAGAIN;
68576 + else
68577 + error = error2;
68578 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
68579 + }
68580 + break;
68581 + case GR_OLDRELOAD:
68582 + oldmode = 1;
68583 + case GR_RELOAD:
68584 + if (!gr_acl_is_enabled()) {
68585 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
68586 + error = -EAGAIN;
68587 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68588 + error2 = gracl_reload(&gr_usermode, oldmode);
68589 + if (!error2)
68590 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
68591 + else {
68592 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68593 + error = error2;
68594 + }
68595 + } else {
68596 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68597 + error = -EPERM;
68598 + }
68599 + break;
68600 + case GR_SEGVMOD:
68601 + if (unlikely(!gr_acl_is_enabled())) {
68602 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
68603 + error = -EAGAIN;
68604 + break;
68605 + }
68606 +
68607 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68608 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
68609 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
68610 + struct acl_subject_label *segvacl;
68611 + segvacl =
68612 + lookup_acl_subj_label(gr_usermode.segv_inode,
68613 + gr_usermode.segv_device,
68614 + current->role);
68615 + if (segvacl) {
68616 + segvacl->crashes = 0;
68617 + segvacl->expires = 0;
68618 + }
68619 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
68620 + gr_remove_uid(gr_usermode.segv_uid);
68621 + }
68622 + } else {
68623 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
68624 + error = -EPERM;
68625 + }
68626 + break;
68627 + case GR_SPROLE:
68628 + case GR_SPROLEPAM:
68629 + if (unlikely(!gr_acl_is_enabled())) {
68630 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
68631 + error = -EAGAIN;
68632 + break;
68633 + }
68634 +
68635 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
68636 + current->role->expires = 0;
68637 + current->role->auth_attempts = 0;
68638 + }
68639 +
68640 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68641 + time_after(current->role->expires, get_seconds())) {
68642 + error = -EBUSY;
68643 + goto out;
68644 + }
68645 +
68646 + if (lookup_special_role_auth
68647 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
68648 + && ((!sprole_salt && !sprole_sum)
68649 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
68650 + char *p = "";
68651 + assign_special_role(gr_usermode.sp_role);
68652 + read_lock(&tasklist_lock);
68653 + if (current->real_parent)
68654 + p = current->real_parent->role->rolename;
68655 + read_unlock(&tasklist_lock);
68656 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
68657 + p, acl_sp_role_value);
68658 + } else {
68659 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
68660 + error = -EPERM;
68661 + if(!(current->role->auth_attempts++))
68662 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68663 +
68664 + goto out;
68665 + }
68666 + break;
68667 + case GR_UNSPROLE:
68668 + if (unlikely(!gr_acl_is_enabled())) {
68669 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
68670 + error = -EAGAIN;
68671 + break;
68672 + }
68673 +
68674 + if (current->role->roletype & GR_ROLE_SPECIAL) {
68675 + char *p = "";
68676 + int i = 0;
68677 +
68678 + read_lock(&tasklist_lock);
68679 + if (current->real_parent) {
68680 + p = current->real_parent->role->rolename;
68681 + i = current->real_parent->acl_role_id;
68682 + }
68683 + read_unlock(&tasklist_lock);
68684 +
68685 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
68686 + gr_set_acls(1);
68687 + } else {
68688 + error = -EPERM;
68689 + goto out;
68690 + }
68691 + break;
68692 + default:
68693 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
68694 + error = -EINVAL;
68695 + break;
68696 + }
68697 +
68698 + if (error != -EPERM)
68699 + goto out;
68700 +
68701 + if(!(gr_auth_attempts++))
68702 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68703 +
68704 + out:
68705 + mutex_unlock(&gr_dev_mutex);
68706 +
68707 + if (!error)
68708 + error = req_count;
68709 +
68710 + return error;
68711 +}
68712 +
68713 +int
68714 +gr_set_acls(const int type)
68715 +{
68716 + struct task_struct *task, *task2;
68717 + struct acl_role_label *role = current->role;
68718 + struct acl_subject_label *subj;
68719 + __u16 acl_role_id = current->acl_role_id;
68720 + const struct cred *cred;
68721 + int ret;
68722 +
68723 + rcu_read_lock();
68724 + read_lock(&tasklist_lock);
68725 + read_lock(&grsec_exec_file_lock);
68726 + do_each_thread(task2, task) {
68727 + /* check to see if we're called from the exit handler,
68728 + if so, only replace ACLs that have inherited the admin
68729 + ACL */
68730 +
68731 + if (type && (task->role != role ||
68732 + task->acl_role_id != acl_role_id))
68733 + continue;
68734 +
68735 + task->acl_role_id = 0;
68736 + task->acl_sp_role = 0;
68737 + task->inherited = 0;
68738 +
68739 + if (task->exec_file) {
68740 + cred = __task_cred(task);
68741 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68742 + subj = gr_get_subject_for_task(task, NULL);
68743 + if (subj == NULL) {
68744 + ret = -EINVAL;
68745 + read_unlock(&grsec_exec_file_lock);
68746 + read_unlock(&tasklist_lock);
68747 + rcu_read_unlock();
68748 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
68749 + return ret;
68750 + }
68751 + __gr_apply_subject_to_task(polstate, task, subj);
68752 + } else {
68753 + // it's a kernel process
68754 + task->role = polstate->kernel_role;
68755 + task->acl = polstate->kernel_role->root_label;
68756 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68757 + task->acl->mode &= ~GR_PROCFIND;
68758 +#endif
68759 + }
68760 + } while_each_thread(task2, task);
68761 + read_unlock(&grsec_exec_file_lock);
68762 + read_unlock(&tasklist_lock);
68763 + rcu_read_unlock();
68764 +
68765 + return 0;
68766 +}
68767 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
68768 new file mode 100644
68769 index 0000000..39645c9
68770 --- /dev/null
68771 +++ b/grsecurity/gracl_res.c
68772 @@ -0,0 +1,68 @@
68773 +#include <linux/kernel.h>
68774 +#include <linux/sched.h>
68775 +#include <linux/gracl.h>
68776 +#include <linux/grinternal.h>
68777 +
68778 +static const char *restab_log[] = {
68779 + [RLIMIT_CPU] = "RLIMIT_CPU",
68780 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
68781 + [RLIMIT_DATA] = "RLIMIT_DATA",
68782 + [RLIMIT_STACK] = "RLIMIT_STACK",
68783 + [RLIMIT_CORE] = "RLIMIT_CORE",
68784 + [RLIMIT_RSS] = "RLIMIT_RSS",
68785 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
68786 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
68787 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
68788 + [RLIMIT_AS] = "RLIMIT_AS",
68789 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
68790 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
68791 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
68792 + [RLIMIT_NICE] = "RLIMIT_NICE",
68793 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
68794 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
68795 + [GR_CRASH_RES] = "RLIMIT_CRASH"
68796 +};
68797 +
68798 +void
68799 +gr_log_resource(const struct task_struct *task,
68800 + const int res, const unsigned long wanted, const int gt)
68801 +{
68802 + const struct cred *cred;
68803 + unsigned long rlim;
68804 +
68805 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
68806 + return;
68807 +
68808 + // not yet supported resource
68809 + if (unlikely(!restab_log[res]))
68810 + return;
68811 +
68812 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
68813 + rlim = task_rlimit_max(task, res);
68814 + else
68815 + rlim = task_rlimit(task, res);
68816 +
68817 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
68818 + return;
68819 +
68820 + rcu_read_lock();
68821 + cred = __task_cred(task);
68822 +
68823 + if (res == RLIMIT_NPROC &&
68824 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
68825 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68826 + goto out_rcu_unlock;
68827 + else if (res == RLIMIT_MEMLOCK &&
68828 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68829 + goto out_rcu_unlock;
68830 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68831 + goto out_rcu_unlock;
68832 + rcu_read_unlock();
68833 +
68834 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68835 +
68836 + return;
68837 +out_rcu_unlock:
68838 + rcu_read_unlock();
68839 + return;
68840 +}
68841 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68842 new file mode 100644
68843 index 0000000..2040e61
68844 --- /dev/null
68845 +++ b/grsecurity/gracl_segv.c
68846 @@ -0,0 +1,313 @@
68847 +#include <linux/kernel.h>
68848 +#include <linux/mm.h>
68849 +#include <asm/uaccess.h>
68850 +#include <asm/errno.h>
68851 +#include <asm/mman.h>
68852 +#include <net/sock.h>
68853 +#include <linux/file.h>
68854 +#include <linux/fs.h>
68855 +#include <linux/net.h>
68856 +#include <linux/in.h>
68857 +#include <linux/slab.h>
68858 +#include <linux/types.h>
68859 +#include <linux/sched.h>
68860 +#include <linux/timer.h>
68861 +#include <linux/gracl.h>
68862 +#include <linux/grsecurity.h>
68863 +#include <linux/grinternal.h>
68864 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68865 +#include <linux/magic.h>
68866 +#include <linux/pagemap.h>
68867 +#include "../fs/btrfs/async-thread.h"
68868 +#include "../fs/btrfs/ctree.h"
68869 +#include "../fs/btrfs/btrfs_inode.h"
68870 +#endif
68871 +
68872 +static struct crash_uid *uid_set;
68873 +static unsigned short uid_used;
68874 +static DEFINE_SPINLOCK(gr_uid_lock);
68875 +extern rwlock_t gr_inode_lock;
68876 +extern struct acl_subject_label *
68877 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68878 + struct acl_role_label *role);
68879 +
68880 +static inline dev_t __get_dev(const struct dentry *dentry)
68881 +{
68882 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68883 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68884 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68885 + else
68886 +#endif
68887 + return dentry->d_sb->s_dev;
68888 +}
68889 +
68890 +int
68891 +gr_init_uidset(void)
68892 +{
68893 + uid_set =
68894 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68895 + uid_used = 0;
68896 +
68897 + return uid_set ? 1 : 0;
68898 +}
68899 +
68900 +void
68901 +gr_free_uidset(void)
68902 +{
68903 + if (uid_set) {
68904 + struct crash_uid *tmpset;
68905 + spin_lock(&gr_uid_lock);
68906 + tmpset = uid_set;
68907 + uid_set = NULL;
68908 + uid_used = 0;
68909 + spin_unlock(&gr_uid_lock);
68910 + if (tmpset)
68911 + kfree(tmpset);
68912 + }
68913 +
68914 + return;
68915 +}
68916 +
68917 +int
68918 +gr_find_uid(const uid_t uid)
68919 +{
68920 + struct crash_uid *tmp = uid_set;
68921 + uid_t buid;
68922 + int low = 0, high = uid_used - 1, mid;
68923 +
68924 + while (high >= low) {
68925 + mid = (low + high) >> 1;
68926 + buid = tmp[mid].uid;
68927 + if (buid == uid)
68928 + return mid;
68929 + if (buid > uid)
68930 + high = mid - 1;
68931 + if (buid < uid)
68932 + low = mid + 1;
68933 + }
68934 +
68935 + return -1;
68936 +}
68937 +
68938 +static __inline__ void
68939 +gr_insertsort(void)
68940 +{
68941 + unsigned short i, j;
68942 + struct crash_uid index;
68943 +
68944 + for (i = 1; i < uid_used; i++) {
68945 + index = uid_set[i];
68946 + j = i;
68947 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68948 + uid_set[j] = uid_set[j - 1];
68949 + j--;
68950 + }
68951 + uid_set[j] = index;
68952 + }
68953 +
68954 + return;
68955 +}
68956 +
68957 +static __inline__ void
68958 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68959 +{
68960 + int loc;
68961 + uid_t uid = GR_GLOBAL_UID(kuid);
68962 +
68963 + if (uid_used == GR_UIDTABLE_MAX)
68964 + return;
68965 +
68966 + loc = gr_find_uid(uid);
68967 +
68968 + if (loc >= 0) {
68969 + uid_set[loc].expires = expires;
68970 + return;
68971 + }
68972 +
68973 + uid_set[uid_used].uid = uid;
68974 + uid_set[uid_used].expires = expires;
68975 + uid_used++;
68976 +
68977 + gr_insertsort();
68978 +
68979 + return;
68980 +}
68981 +
68982 +void
68983 +gr_remove_uid(const unsigned short loc)
68984 +{
68985 + unsigned short i;
68986 +
68987 + for (i = loc + 1; i < uid_used; i++)
68988 + uid_set[i - 1] = uid_set[i];
68989 +
68990 + uid_used--;
68991 +
68992 + return;
68993 +}
68994 +
68995 +int
68996 +gr_check_crash_uid(const kuid_t kuid)
68997 +{
68998 + int loc;
68999 + int ret = 0;
69000 + uid_t uid;
69001 +
69002 + if (unlikely(!gr_acl_is_enabled()))
69003 + return 0;
69004 +
69005 + uid = GR_GLOBAL_UID(kuid);
69006 +
69007 + spin_lock(&gr_uid_lock);
69008 + loc = gr_find_uid(uid);
69009 +
69010 + if (loc < 0)
69011 + goto out_unlock;
69012 +
69013 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
69014 + gr_remove_uid(loc);
69015 + else
69016 + ret = 1;
69017 +
69018 +out_unlock:
69019 + spin_unlock(&gr_uid_lock);
69020 + return ret;
69021 +}
69022 +
69023 +static __inline__ int
69024 +proc_is_setxid(const struct cred *cred)
69025 +{
69026 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
69027 + !uid_eq(cred->uid, cred->fsuid))
69028 + return 1;
69029 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69030 + !gid_eq(cred->gid, cred->fsgid))
69031 + return 1;
69032 +
69033 + return 0;
69034 +}
69035 +
69036 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69037 +
69038 +void
69039 +gr_handle_crash(struct task_struct *task, const int sig)
69040 +{
69041 + struct acl_subject_label *curr;
69042 + struct task_struct *tsk, *tsk2;
69043 + const struct cred *cred;
69044 + const struct cred *cred2;
69045 +
69046 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
69047 + return;
69048 +
69049 + if (unlikely(!gr_acl_is_enabled()))
69050 + return;
69051 +
69052 + curr = task->acl;
69053 +
69054 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
69055 + return;
69056 +
69057 + if (time_before_eq(curr->expires, get_seconds())) {
69058 + curr->expires = 0;
69059 + curr->crashes = 0;
69060 + }
69061 +
69062 + curr->crashes++;
69063 +
69064 + if (!curr->expires)
69065 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
69066 +
69067 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69068 + time_after(curr->expires, get_seconds())) {
69069 + rcu_read_lock();
69070 + cred = __task_cred(task);
69071 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
69072 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69073 + spin_lock(&gr_uid_lock);
69074 + gr_insert_uid(cred->uid, curr->expires);
69075 + spin_unlock(&gr_uid_lock);
69076 + curr->expires = 0;
69077 + curr->crashes = 0;
69078 + read_lock(&tasklist_lock);
69079 + do_each_thread(tsk2, tsk) {
69080 + cred2 = __task_cred(tsk);
69081 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
69082 + gr_fake_force_sig(SIGKILL, tsk);
69083 + } while_each_thread(tsk2, tsk);
69084 + read_unlock(&tasklist_lock);
69085 + } else {
69086 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69087 + read_lock(&tasklist_lock);
69088 + read_lock(&grsec_exec_file_lock);
69089 + do_each_thread(tsk2, tsk) {
69090 + if (likely(tsk != task)) {
69091 + // if this thread has the same subject as the one that triggered
69092 + // RES_CRASH and it's the same binary, kill it
69093 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
69094 + gr_fake_force_sig(SIGKILL, tsk);
69095 + }
69096 + } while_each_thread(tsk2, tsk);
69097 + read_unlock(&grsec_exec_file_lock);
69098 + read_unlock(&tasklist_lock);
69099 + }
69100 + rcu_read_unlock();
69101 + }
69102 +
69103 + return;
69104 +}
69105 +
69106 +int
69107 +gr_check_crash_exec(const struct file *filp)
69108 +{
69109 + struct acl_subject_label *curr;
69110 +
69111 + if (unlikely(!gr_acl_is_enabled()))
69112 + return 0;
69113 +
69114 + read_lock(&gr_inode_lock);
69115 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
69116 + __get_dev(filp->f_path.dentry),
69117 + current->role);
69118 + read_unlock(&gr_inode_lock);
69119 +
69120 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
69121 + (!curr->crashes && !curr->expires))
69122 + return 0;
69123 +
69124 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69125 + time_after(curr->expires, get_seconds()))
69126 + return 1;
69127 + else if (time_before_eq(curr->expires, get_seconds())) {
69128 + curr->crashes = 0;
69129 + curr->expires = 0;
69130 + }
69131 +
69132 + return 0;
69133 +}
69134 +
69135 +void
69136 +gr_handle_alertkill(struct task_struct *task)
69137 +{
69138 + struct acl_subject_label *curracl;
69139 + __u32 curr_ip;
69140 + struct task_struct *p, *p2;
69141 +
69142 + if (unlikely(!gr_acl_is_enabled()))
69143 + return;
69144 +
69145 + curracl = task->acl;
69146 + curr_ip = task->signal->curr_ip;
69147 +
69148 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
69149 + read_lock(&tasklist_lock);
69150 + do_each_thread(p2, p) {
69151 + if (p->signal->curr_ip == curr_ip)
69152 + gr_fake_force_sig(SIGKILL, p);
69153 + } while_each_thread(p2, p);
69154 + read_unlock(&tasklist_lock);
69155 + } else if (curracl->mode & GR_KILLPROC)
69156 + gr_fake_force_sig(SIGKILL, task);
69157 +
69158 + return;
69159 +}
69160 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
69161 new file mode 100644
69162 index 0000000..98011b0
69163 --- /dev/null
69164 +++ b/grsecurity/gracl_shm.c
69165 @@ -0,0 +1,40 @@
69166 +#include <linux/kernel.h>
69167 +#include <linux/mm.h>
69168 +#include <linux/sched.h>
69169 +#include <linux/file.h>
69170 +#include <linux/ipc.h>
69171 +#include <linux/gracl.h>
69172 +#include <linux/grsecurity.h>
69173 +#include <linux/grinternal.h>
69174 +
69175 +int
69176 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69177 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69178 +{
69179 + struct task_struct *task;
69180 +
69181 + if (!gr_acl_is_enabled())
69182 + return 1;
69183 +
69184 + rcu_read_lock();
69185 + read_lock(&tasklist_lock);
69186 +
69187 + task = find_task_by_vpid(shm_cprid);
69188 +
69189 + if (unlikely(!task))
69190 + task = find_task_by_vpid(shm_lapid);
69191 +
69192 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
69193 + (task_pid_nr(task) == shm_lapid)) &&
69194 + (task->acl->mode & GR_PROTSHM) &&
69195 + (task->acl != current->acl))) {
69196 + read_unlock(&tasklist_lock);
69197 + rcu_read_unlock();
69198 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
69199 + return 0;
69200 + }
69201 + read_unlock(&tasklist_lock);
69202 + rcu_read_unlock();
69203 +
69204 + return 1;
69205 +}
69206 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
69207 new file mode 100644
69208 index 0000000..bc0be01
69209 --- /dev/null
69210 +++ b/grsecurity/grsec_chdir.c
69211 @@ -0,0 +1,19 @@
69212 +#include <linux/kernel.h>
69213 +#include <linux/sched.h>
69214 +#include <linux/fs.h>
69215 +#include <linux/file.h>
69216 +#include <linux/grsecurity.h>
69217 +#include <linux/grinternal.h>
69218 +
69219 +void
69220 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
69221 +{
69222 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69223 + if ((grsec_enable_chdir && grsec_enable_group &&
69224 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
69225 + !grsec_enable_group)) {
69226 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
69227 + }
69228 +#endif
69229 + return;
69230 +}
69231 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
69232 new file mode 100644
69233 index 0000000..e10b319
69234 --- /dev/null
69235 +++ b/grsecurity/grsec_chroot.c
69236 @@ -0,0 +1,370 @@
69237 +#include <linux/kernel.h>
69238 +#include <linux/module.h>
69239 +#include <linux/sched.h>
69240 +#include <linux/file.h>
69241 +#include <linux/fs.h>
69242 +#include <linux/mount.h>
69243 +#include <linux/types.h>
69244 +#include "../fs/mount.h"
69245 +#include <linux/grsecurity.h>
69246 +#include <linux/grinternal.h>
69247 +
69248 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69249 +int gr_init_ran;
69250 +#endif
69251 +
69252 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
69253 +{
69254 +#ifdef CONFIG_GRKERNSEC
69255 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
69256 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
69257 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69258 + && gr_init_ran
69259 +#endif
69260 + )
69261 + task->gr_is_chrooted = 1;
69262 + else {
69263 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69264 + if (task_pid_nr(task) == 1 && !gr_init_ran)
69265 + gr_init_ran = 1;
69266 +#endif
69267 + task->gr_is_chrooted = 0;
69268 + }
69269 +
69270 + task->gr_chroot_dentry = path->dentry;
69271 +#endif
69272 + return;
69273 +}
69274 +
69275 +void gr_clear_chroot_entries(struct task_struct *task)
69276 +{
69277 +#ifdef CONFIG_GRKERNSEC
69278 + task->gr_is_chrooted = 0;
69279 + task->gr_chroot_dentry = NULL;
69280 +#endif
69281 + return;
69282 +}
69283 +
69284 +int
69285 +gr_handle_chroot_unix(const pid_t pid)
69286 +{
69287 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69288 + struct task_struct *p;
69289 +
69290 + if (unlikely(!grsec_enable_chroot_unix))
69291 + return 1;
69292 +
69293 + if (likely(!proc_is_chrooted(current)))
69294 + return 1;
69295 +
69296 + rcu_read_lock();
69297 + read_lock(&tasklist_lock);
69298 + p = find_task_by_vpid_unrestricted(pid);
69299 + if (unlikely(p && !have_same_root(current, p))) {
69300 + read_unlock(&tasklist_lock);
69301 + rcu_read_unlock();
69302 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
69303 + return 0;
69304 + }
69305 + read_unlock(&tasklist_lock);
69306 + rcu_read_unlock();
69307 +#endif
69308 + return 1;
69309 +}
69310 +
69311 +int
69312 +gr_handle_chroot_nice(void)
69313 +{
69314 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69315 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
69316 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
69317 + return -EPERM;
69318 + }
69319 +#endif
69320 + return 0;
69321 +}
69322 +
69323 +int
69324 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
69325 +{
69326 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69327 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
69328 + && proc_is_chrooted(current)) {
69329 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
69330 + return -EACCES;
69331 + }
69332 +#endif
69333 + return 0;
69334 +}
69335 +
69336 +int
69337 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
69338 +{
69339 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69340 + struct task_struct *p;
69341 + int ret = 0;
69342 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
69343 + return ret;
69344 +
69345 + read_lock(&tasklist_lock);
69346 + do_each_pid_task(pid, type, p) {
69347 + if (!have_same_root(current, p)) {
69348 + ret = 1;
69349 + goto out;
69350 + }
69351 + } while_each_pid_task(pid, type, p);
69352 +out:
69353 + read_unlock(&tasklist_lock);
69354 + return ret;
69355 +#endif
69356 + return 0;
69357 +}
69358 +
69359 +int
69360 +gr_pid_is_chrooted(struct task_struct *p)
69361 +{
69362 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69363 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
69364 + return 0;
69365 +
69366 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
69367 + !have_same_root(current, p)) {
69368 + return 1;
69369 + }
69370 +#endif
69371 + return 0;
69372 +}
69373 +
69374 +EXPORT_SYMBOL(gr_pid_is_chrooted);
69375 +
69376 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
69377 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
69378 +{
69379 + struct path path, currentroot;
69380 + int ret = 0;
69381 +
69382 + path.dentry = (struct dentry *)u_dentry;
69383 + path.mnt = (struct vfsmount *)u_mnt;
69384 + get_fs_root(current->fs, &currentroot);
69385 + if (path_is_under(&path, &currentroot))
69386 + ret = 1;
69387 + path_put(&currentroot);
69388 +
69389 + return ret;
69390 +}
69391 +#endif
69392 +
69393 +int
69394 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
69395 +{
69396 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69397 + if (!grsec_enable_chroot_fchdir)
69398 + return 1;
69399 +
69400 + if (!proc_is_chrooted(current))
69401 + return 1;
69402 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
69403 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
69404 + return 0;
69405 + }
69406 +#endif
69407 + return 1;
69408 +}
69409 +
69410 +int
69411 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69412 + const time_t shm_createtime)
69413 +{
69414 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69415 + struct task_struct *p;
69416 + time_t starttime;
69417 +
69418 + if (unlikely(!grsec_enable_chroot_shmat))
69419 + return 1;
69420 +
69421 + if (likely(!proc_is_chrooted(current)))
69422 + return 1;
69423 +
69424 + rcu_read_lock();
69425 + read_lock(&tasklist_lock);
69426 +
69427 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
69428 + starttime = p->start_time.tv_sec;
69429 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
69430 + if (have_same_root(current, p)) {
69431 + goto allow;
69432 + } else {
69433 + read_unlock(&tasklist_lock);
69434 + rcu_read_unlock();
69435 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69436 + return 0;
69437 + }
69438 + }
69439 + /* creator exited, pid reuse, fall through to next check */
69440 + }
69441 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
69442 + if (unlikely(!have_same_root(current, p))) {
69443 + read_unlock(&tasklist_lock);
69444 + rcu_read_unlock();
69445 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69446 + return 0;
69447 + }
69448 + }
69449 +
69450 +allow:
69451 + read_unlock(&tasklist_lock);
69452 + rcu_read_unlock();
69453 +#endif
69454 + return 1;
69455 +}
69456 +
69457 +void
69458 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
69459 +{
69460 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69461 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
69462 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
69463 +#endif
69464 + return;
69465 +}
69466 +
69467 +int
69468 +gr_handle_chroot_mknod(const struct dentry *dentry,
69469 + const struct vfsmount *mnt, const int mode)
69470 +{
69471 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69472 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
69473 + proc_is_chrooted(current)) {
69474 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
69475 + return -EPERM;
69476 + }
69477 +#endif
69478 + return 0;
69479 +}
69480 +
69481 +int
69482 +gr_handle_chroot_mount(const struct dentry *dentry,
69483 + const struct vfsmount *mnt, const char *dev_name)
69484 +{
69485 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69486 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
69487 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
69488 + return -EPERM;
69489 + }
69490 +#endif
69491 + return 0;
69492 +}
69493 +
69494 +int
69495 +gr_handle_chroot_pivot(void)
69496 +{
69497 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69498 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
69499 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
69500 + return -EPERM;
69501 + }
69502 +#endif
69503 + return 0;
69504 +}
69505 +
69506 +int
69507 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
69508 +{
69509 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69510 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
69511 + !gr_is_outside_chroot(dentry, mnt)) {
69512 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
69513 + return -EPERM;
69514 + }
69515 +#endif
69516 + return 0;
69517 +}
69518 +
69519 +extern const char *captab_log[];
69520 +extern int captab_log_entries;
69521 +
69522 +int
69523 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69524 +{
69525 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69526 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69527 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69528 + if (cap_raised(chroot_caps, cap)) {
69529 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
69530 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
69531 + }
69532 + return 0;
69533 + }
69534 + }
69535 +#endif
69536 + return 1;
69537 +}
69538 +
69539 +int
69540 +gr_chroot_is_capable(const int cap)
69541 +{
69542 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69543 + return gr_task_chroot_is_capable(current, current_cred(), cap);
69544 +#endif
69545 + return 1;
69546 +}
69547 +
69548 +int
69549 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
69550 +{
69551 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69552 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69553 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69554 + if (cap_raised(chroot_caps, cap)) {
69555 + return 0;
69556 + }
69557 + }
69558 +#endif
69559 + return 1;
69560 +}
69561 +
69562 +int
69563 +gr_chroot_is_capable_nolog(const int cap)
69564 +{
69565 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69566 + return gr_task_chroot_is_capable_nolog(current, cap);
69567 +#endif
69568 + return 1;
69569 +}
69570 +
69571 +int
69572 +gr_handle_chroot_sysctl(const int op)
69573 +{
69574 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69575 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
69576 + proc_is_chrooted(current))
69577 + return -EACCES;
69578 +#endif
69579 + return 0;
69580 +}
69581 +
69582 +void
69583 +gr_handle_chroot_chdir(const struct path *path)
69584 +{
69585 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69586 + if (grsec_enable_chroot_chdir)
69587 + set_fs_pwd(current->fs, path);
69588 +#endif
69589 + return;
69590 +}
69591 +
69592 +int
69593 +gr_handle_chroot_chmod(const struct dentry *dentry,
69594 + const struct vfsmount *mnt, const int mode)
69595 +{
69596 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69597 + /* allow chmod +s on directories, but not files */
69598 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
69599 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
69600 + proc_is_chrooted(current)) {
69601 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
69602 + return -EPERM;
69603 + }
69604 +#endif
69605 + return 0;
69606 +}
69607 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
69608 new file mode 100644
69609 index 0000000..0866ab2
69610 --- /dev/null
69611 +++ b/grsecurity/grsec_disabled.c
69612 @@ -0,0 +1,427 @@
69613 +#include <linux/kernel.h>
69614 +#include <linux/module.h>
69615 +#include <linux/sched.h>
69616 +#include <linux/file.h>
69617 +#include <linux/fs.h>
69618 +#include <linux/kdev_t.h>
69619 +#include <linux/net.h>
69620 +#include <linux/in.h>
69621 +#include <linux/ip.h>
69622 +#include <linux/skbuff.h>
69623 +#include <linux/sysctl.h>
69624 +
69625 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
69626 +void
69627 +pax_set_initial_flags(struct linux_binprm *bprm)
69628 +{
69629 + return;
69630 +}
69631 +#endif
69632 +
69633 +#ifdef CONFIG_SYSCTL
69634 +__u32
69635 +gr_handle_sysctl(const struct ctl_table * table, const int op)
69636 +{
69637 + return 0;
69638 +}
69639 +#endif
69640 +
69641 +#ifdef CONFIG_TASKSTATS
69642 +int gr_is_taskstats_denied(int pid)
69643 +{
69644 + return 0;
69645 +}
69646 +#endif
69647 +
69648 +int
69649 +gr_acl_is_enabled(void)
69650 +{
69651 + return 0;
69652 +}
69653 +
69654 +void
69655 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
69656 +{
69657 + return;
69658 +}
69659 +
69660 +int
69661 +gr_handle_rawio(const struct inode *inode)
69662 +{
69663 + return 0;
69664 +}
69665 +
69666 +void
69667 +gr_acl_handle_psacct(struct task_struct *task, const long code)
69668 +{
69669 + return;
69670 +}
69671 +
69672 +int
69673 +gr_handle_ptrace(struct task_struct *task, const long request)
69674 +{
69675 + return 0;
69676 +}
69677 +
69678 +int
69679 +gr_handle_proc_ptrace(struct task_struct *task)
69680 +{
69681 + return 0;
69682 +}
69683 +
69684 +int
69685 +gr_set_acls(const int type)
69686 +{
69687 + return 0;
69688 +}
69689 +
69690 +int
69691 +gr_check_hidden_task(const struct task_struct *tsk)
69692 +{
69693 + return 0;
69694 +}
69695 +
69696 +int
69697 +gr_check_protected_task(const struct task_struct *task)
69698 +{
69699 + return 0;
69700 +}
69701 +
69702 +int
69703 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
69704 +{
69705 + return 0;
69706 +}
69707 +
69708 +void
69709 +gr_copy_label(struct task_struct *tsk)
69710 +{
69711 + return;
69712 +}
69713 +
69714 +void
69715 +gr_set_pax_flags(struct task_struct *task)
69716 +{
69717 + return;
69718 +}
69719 +
69720 +int
69721 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
69722 + const int unsafe_share)
69723 +{
69724 + return 0;
69725 +}
69726 +
69727 +void
69728 +gr_handle_delete(const ino_t ino, const dev_t dev)
69729 +{
69730 + return;
69731 +}
69732 +
69733 +void
69734 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
69735 +{
69736 + return;
69737 +}
69738 +
69739 +void
69740 +gr_handle_crash(struct task_struct *task, const int sig)
69741 +{
69742 + return;
69743 +}
69744 +
69745 +int
69746 +gr_check_crash_exec(const struct file *filp)
69747 +{
69748 + return 0;
69749 +}
69750 +
69751 +int
69752 +gr_check_crash_uid(const kuid_t uid)
69753 +{
69754 + return 0;
69755 +}
69756 +
69757 +void
69758 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69759 + struct dentry *old_dentry,
69760 + struct dentry *new_dentry,
69761 + struct vfsmount *mnt, const __u8 replace)
69762 +{
69763 + return;
69764 +}
69765 +
69766 +int
69767 +gr_search_socket(const int family, const int type, const int protocol)
69768 +{
69769 + return 1;
69770 +}
69771 +
69772 +int
69773 +gr_search_connectbind(const int mode, const struct socket *sock,
69774 + const struct sockaddr_in *addr)
69775 +{
69776 + return 0;
69777 +}
69778 +
69779 +void
69780 +gr_handle_alertkill(struct task_struct *task)
69781 +{
69782 + return;
69783 +}
69784 +
69785 +__u32
69786 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
69787 +{
69788 + return 1;
69789 +}
69790 +
69791 +__u32
69792 +gr_acl_handle_hidden_file(const struct dentry * dentry,
69793 + const struct vfsmount * mnt)
69794 +{
69795 + return 1;
69796 +}
69797 +
69798 +__u32
69799 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
69800 + int acc_mode)
69801 +{
69802 + return 1;
69803 +}
69804 +
69805 +__u32
69806 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
69807 +{
69808 + return 1;
69809 +}
69810 +
69811 +__u32
69812 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
69813 +{
69814 + return 1;
69815 +}
69816 +
69817 +int
69818 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
69819 + unsigned int *vm_flags)
69820 +{
69821 + return 1;
69822 +}
69823 +
69824 +__u32
69825 +gr_acl_handle_truncate(const struct dentry * dentry,
69826 + const struct vfsmount * mnt)
69827 +{
69828 + return 1;
69829 +}
69830 +
69831 +__u32
69832 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
69833 +{
69834 + return 1;
69835 +}
69836 +
69837 +__u32
69838 +gr_acl_handle_access(const struct dentry * dentry,
69839 + const struct vfsmount * mnt, const int fmode)
69840 +{
69841 + return 1;
69842 +}
69843 +
69844 +__u32
69845 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69846 + umode_t *mode)
69847 +{
69848 + return 1;
69849 +}
69850 +
69851 +__u32
69852 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69853 +{
69854 + return 1;
69855 +}
69856 +
69857 +__u32
69858 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69859 +{
69860 + return 1;
69861 +}
69862 +
69863 +void
69864 +grsecurity_init(void)
69865 +{
69866 + return;
69867 +}
69868 +
69869 +umode_t gr_acl_umask(void)
69870 +{
69871 + return 0;
69872 +}
69873 +
69874 +__u32
69875 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69876 + const struct dentry * parent_dentry,
69877 + const struct vfsmount * parent_mnt,
69878 + const int mode)
69879 +{
69880 + return 1;
69881 +}
69882 +
69883 +__u32
69884 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69885 + const struct dentry * parent_dentry,
69886 + const struct vfsmount * parent_mnt)
69887 +{
69888 + return 1;
69889 +}
69890 +
69891 +__u32
69892 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69893 + const struct dentry * parent_dentry,
69894 + const struct vfsmount * parent_mnt, const struct filename *from)
69895 +{
69896 + return 1;
69897 +}
69898 +
69899 +__u32
69900 +gr_acl_handle_link(const struct dentry * new_dentry,
69901 + const struct dentry * parent_dentry,
69902 + const struct vfsmount * parent_mnt,
69903 + const struct dentry * old_dentry,
69904 + const struct vfsmount * old_mnt, const struct filename *to)
69905 +{
69906 + return 1;
69907 +}
69908 +
69909 +int
69910 +gr_acl_handle_rename(const struct dentry *new_dentry,
69911 + const struct dentry *parent_dentry,
69912 + const struct vfsmount *parent_mnt,
69913 + const struct dentry *old_dentry,
69914 + const struct inode *old_parent_inode,
69915 + const struct vfsmount *old_mnt, const struct filename *newname)
69916 +{
69917 + return 0;
69918 +}
69919 +
69920 +int
69921 +gr_acl_handle_filldir(const struct file *file, const char *name,
69922 + const int namelen, const ino_t ino)
69923 +{
69924 + return 1;
69925 +}
69926 +
69927 +int
69928 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69929 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69930 +{
69931 + return 1;
69932 +}
69933 +
69934 +int
69935 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69936 +{
69937 + return 0;
69938 +}
69939 +
69940 +int
69941 +gr_search_accept(const struct socket *sock)
69942 +{
69943 + return 0;
69944 +}
69945 +
69946 +int
69947 +gr_search_listen(const struct socket *sock)
69948 +{
69949 + return 0;
69950 +}
69951 +
69952 +int
69953 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69954 +{
69955 + return 0;
69956 +}
69957 +
69958 +__u32
69959 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69960 +{
69961 + return 1;
69962 +}
69963 +
69964 +__u32
69965 +gr_acl_handle_creat(const struct dentry * dentry,
69966 + const struct dentry * p_dentry,
69967 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69968 + const int imode)
69969 +{
69970 + return 1;
69971 +}
69972 +
69973 +void
69974 +gr_acl_handle_exit(void)
69975 +{
69976 + return;
69977 +}
69978 +
69979 +int
69980 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69981 +{
69982 + return 1;
69983 +}
69984 +
69985 +void
69986 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69987 +{
69988 + return;
69989 +}
69990 +
69991 +int
69992 +gr_acl_handle_procpidmem(const struct task_struct *task)
69993 +{
69994 + return 0;
69995 +}
69996 +
69997 +int
69998 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69999 +{
70000 + return 0;
70001 +}
70002 +
70003 +int
70004 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
70005 +{
70006 + return 0;
70007 +}
70008 +
70009 +int
70010 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
70011 +{
70012 + return 0;
70013 +}
70014 +
70015 +int
70016 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
70017 +{
70018 + return 0;
70019 +}
70020 +
70021 +int gr_acl_enable_at_secure(void)
70022 +{
70023 + return 0;
70024 +}
70025 +
70026 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
70027 +{
70028 + return dentry->d_sb->s_dev;
70029 +}
70030 +
70031 +void gr_put_exec_file(struct task_struct *task)
70032 +{
70033 + return;
70034 +}
70035 +
70036 +#ifdef CONFIG_SECURITY
70037 +EXPORT_SYMBOL(gr_check_user_change);
70038 +EXPORT_SYMBOL(gr_check_group_change);
70039 +#endif
70040 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
70041 new file mode 100644
70042 index 0000000..387032b
70043 --- /dev/null
70044 +++ b/grsecurity/grsec_exec.c
70045 @@ -0,0 +1,187 @@
70046 +#include <linux/kernel.h>
70047 +#include <linux/sched.h>
70048 +#include <linux/file.h>
70049 +#include <linux/binfmts.h>
70050 +#include <linux/fs.h>
70051 +#include <linux/types.h>
70052 +#include <linux/grdefs.h>
70053 +#include <linux/grsecurity.h>
70054 +#include <linux/grinternal.h>
70055 +#include <linux/capability.h>
70056 +#include <linux/module.h>
70057 +#include <linux/compat.h>
70058 +
70059 +#include <asm/uaccess.h>
70060 +
70061 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70062 +static char gr_exec_arg_buf[132];
70063 +static DEFINE_MUTEX(gr_exec_arg_mutex);
70064 +#endif
70065 +
70066 +struct user_arg_ptr {
70067 +#ifdef CONFIG_COMPAT
70068 + bool is_compat;
70069 +#endif
70070 + union {
70071 + const char __user *const __user *native;
70072 +#ifdef CONFIG_COMPAT
70073 + const compat_uptr_t __user *compat;
70074 +#endif
70075 + } ptr;
70076 +};
70077 +
70078 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
70079 +
70080 +void
70081 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
70082 +{
70083 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70084 + char *grarg = gr_exec_arg_buf;
70085 + unsigned int i, x, execlen = 0;
70086 + char c;
70087 +
70088 + if (!((grsec_enable_execlog && grsec_enable_group &&
70089 + in_group_p(grsec_audit_gid))
70090 + || (grsec_enable_execlog && !grsec_enable_group)))
70091 + return;
70092 +
70093 + mutex_lock(&gr_exec_arg_mutex);
70094 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
70095 +
70096 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
70097 + const char __user *p;
70098 + unsigned int len;
70099 +
70100 + p = get_user_arg_ptr(argv, i);
70101 + if (IS_ERR(p))
70102 + goto log;
70103 +
70104 + len = strnlen_user(p, 128 - execlen);
70105 + if (len > 128 - execlen)
70106 + len = 128 - execlen;
70107 + else if (len > 0)
70108 + len--;
70109 + if (copy_from_user(grarg + execlen, p, len))
70110 + goto log;
70111 +
70112 + /* rewrite unprintable characters */
70113 + for (x = 0; x < len; x++) {
70114 + c = *(grarg + execlen + x);
70115 + if (c < 32 || c > 126)
70116 + *(grarg + execlen + x) = ' ';
70117 + }
70118 +
70119 + execlen += len;
70120 + *(grarg + execlen) = ' ';
70121 + *(grarg + execlen + 1) = '\0';
70122 + execlen++;
70123 + }
70124 +
70125 + log:
70126 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
70127 + bprm->file->f_path.mnt, grarg);
70128 + mutex_unlock(&gr_exec_arg_mutex);
70129 +#endif
70130 + return;
70131 +}
70132 +
70133 +#ifdef CONFIG_GRKERNSEC
70134 +extern int gr_acl_is_capable(const int cap);
70135 +extern int gr_acl_is_capable_nolog(const int cap);
70136 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70137 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
70138 +extern int gr_chroot_is_capable(const int cap);
70139 +extern int gr_chroot_is_capable_nolog(const int cap);
70140 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70141 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
70142 +#endif
70143 +
70144 +const char *captab_log[] = {
70145 + "CAP_CHOWN",
70146 + "CAP_DAC_OVERRIDE",
70147 + "CAP_DAC_READ_SEARCH",
70148 + "CAP_FOWNER",
70149 + "CAP_FSETID",
70150 + "CAP_KILL",
70151 + "CAP_SETGID",
70152 + "CAP_SETUID",
70153 + "CAP_SETPCAP",
70154 + "CAP_LINUX_IMMUTABLE",
70155 + "CAP_NET_BIND_SERVICE",
70156 + "CAP_NET_BROADCAST",
70157 + "CAP_NET_ADMIN",
70158 + "CAP_NET_RAW",
70159 + "CAP_IPC_LOCK",
70160 + "CAP_IPC_OWNER",
70161 + "CAP_SYS_MODULE",
70162 + "CAP_SYS_RAWIO",
70163 + "CAP_SYS_CHROOT",
70164 + "CAP_SYS_PTRACE",
70165 + "CAP_SYS_PACCT",
70166 + "CAP_SYS_ADMIN",
70167 + "CAP_SYS_BOOT",
70168 + "CAP_SYS_NICE",
70169 + "CAP_SYS_RESOURCE",
70170 + "CAP_SYS_TIME",
70171 + "CAP_SYS_TTY_CONFIG",
70172 + "CAP_MKNOD",
70173 + "CAP_LEASE",
70174 + "CAP_AUDIT_WRITE",
70175 + "CAP_AUDIT_CONTROL",
70176 + "CAP_SETFCAP",
70177 + "CAP_MAC_OVERRIDE",
70178 + "CAP_MAC_ADMIN",
70179 + "CAP_SYSLOG",
70180 + "CAP_WAKE_ALARM"
70181 +};
70182 +
70183 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
70184 +
70185 +int gr_is_capable(const int cap)
70186 +{
70187 +#ifdef CONFIG_GRKERNSEC
70188 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
70189 + return 1;
70190 + return 0;
70191 +#else
70192 + return 1;
70193 +#endif
70194 +}
70195 +
70196 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70197 +{
70198 +#ifdef CONFIG_GRKERNSEC
70199 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
70200 + return 1;
70201 + return 0;
70202 +#else
70203 + return 1;
70204 +#endif
70205 +}
70206 +
70207 +int gr_is_capable_nolog(const int cap)
70208 +{
70209 +#ifdef CONFIG_GRKERNSEC
70210 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
70211 + return 1;
70212 + return 0;
70213 +#else
70214 + return 1;
70215 +#endif
70216 +}
70217 +
70218 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
70219 +{
70220 +#ifdef CONFIG_GRKERNSEC
70221 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
70222 + return 1;
70223 + return 0;
70224 +#else
70225 + return 1;
70226 +#endif
70227 +}
70228 +
70229 +EXPORT_SYMBOL(gr_is_capable);
70230 +EXPORT_SYMBOL(gr_is_capable_nolog);
70231 +EXPORT_SYMBOL(gr_task_is_capable);
70232 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
70233 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
70234 new file mode 100644
70235 index 0000000..06cc6ea
70236 --- /dev/null
70237 +++ b/grsecurity/grsec_fifo.c
70238 @@ -0,0 +1,24 @@
70239 +#include <linux/kernel.h>
70240 +#include <linux/sched.h>
70241 +#include <linux/fs.h>
70242 +#include <linux/file.h>
70243 +#include <linux/grinternal.h>
70244 +
70245 +int
70246 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
70247 + const struct dentry *dir, const int flag, const int acc_mode)
70248 +{
70249 +#ifdef CONFIG_GRKERNSEC_FIFO
70250 + const struct cred *cred = current_cred();
70251 +
70252 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
70253 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
70254 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
70255 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
70256 + if (!inode_permission(dentry->d_inode, acc_mode))
70257 + 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));
70258 + return -EACCES;
70259 + }
70260 +#endif
70261 + return 0;
70262 +}
70263 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
70264 new file mode 100644
70265 index 0000000..8ca18bf
70266 --- /dev/null
70267 +++ b/grsecurity/grsec_fork.c
70268 @@ -0,0 +1,23 @@
70269 +#include <linux/kernel.h>
70270 +#include <linux/sched.h>
70271 +#include <linux/grsecurity.h>
70272 +#include <linux/grinternal.h>
70273 +#include <linux/errno.h>
70274 +
70275 +void
70276 +gr_log_forkfail(const int retval)
70277 +{
70278 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70279 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
70280 + switch (retval) {
70281 + case -EAGAIN:
70282 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
70283 + break;
70284 + case -ENOMEM:
70285 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
70286 + break;
70287 + }
70288 + }
70289 +#endif
70290 + return;
70291 +}
70292 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
70293 new file mode 100644
70294 index 0000000..a88e901
70295 --- /dev/null
70296 +++ b/grsecurity/grsec_init.c
70297 @@ -0,0 +1,272 @@
70298 +#include <linux/kernel.h>
70299 +#include <linux/sched.h>
70300 +#include <linux/mm.h>
70301 +#include <linux/gracl.h>
70302 +#include <linux/slab.h>
70303 +#include <linux/vmalloc.h>
70304 +#include <linux/percpu.h>
70305 +#include <linux/module.h>
70306 +
70307 +int grsec_enable_ptrace_readexec;
70308 +int grsec_enable_setxid;
70309 +int grsec_enable_symlinkown;
70310 +kgid_t grsec_symlinkown_gid;
70311 +int grsec_enable_brute;
70312 +int grsec_enable_link;
70313 +int grsec_enable_dmesg;
70314 +int grsec_enable_harden_ptrace;
70315 +int grsec_enable_harden_ipc;
70316 +int grsec_enable_fifo;
70317 +int grsec_enable_execlog;
70318 +int grsec_enable_signal;
70319 +int grsec_enable_forkfail;
70320 +int grsec_enable_audit_ptrace;
70321 +int grsec_enable_time;
70322 +int grsec_enable_group;
70323 +kgid_t grsec_audit_gid;
70324 +int grsec_enable_chdir;
70325 +int grsec_enable_mount;
70326 +int grsec_enable_rofs;
70327 +int grsec_deny_new_usb;
70328 +int grsec_enable_chroot_findtask;
70329 +int grsec_enable_chroot_mount;
70330 +int grsec_enable_chroot_shmat;
70331 +int grsec_enable_chroot_fchdir;
70332 +int grsec_enable_chroot_double;
70333 +int grsec_enable_chroot_pivot;
70334 +int grsec_enable_chroot_chdir;
70335 +int grsec_enable_chroot_chmod;
70336 +int grsec_enable_chroot_mknod;
70337 +int grsec_enable_chroot_nice;
70338 +int grsec_enable_chroot_execlog;
70339 +int grsec_enable_chroot_caps;
70340 +int grsec_enable_chroot_sysctl;
70341 +int grsec_enable_chroot_unix;
70342 +int grsec_enable_tpe;
70343 +kgid_t grsec_tpe_gid;
70344 +int grsec_enable_blackhole;
70345 +#ifdef CONFIG_IPV6_MODULE
70346 +EXPORT_SYMBOL(grsec_enable_blackhole);
70347 +#endif
70348 +int grsec_lastack_retries;
70349 +int grsec_enable_tpe_all;
70350 +int grsec_enable_tpe_invert;
70351 +int grsec_enable_socket_all;
70352 +kgid_t grsec_socket_all_gid;
70353 +int grsec_enable_socket_client;
70354 +kgid_t grsec_socket_client_gid;
70355 +int grsec_enable_socket_server;
70356 +kgid_t grsec_socket_server_gid;
70357 +int grsec_resource_logging;
70358 +int grsec_disable_privio;
70359 +int grsec_enable_log_rwxmaps;
70360 +int grsec_lock;
70361 +
70362 +DEFINE_SPINLOCK(grsec_alert_lock);
70363 +unsigned long grsec_alert_wtime = 0;
70364 +unsigned long grsec_alert_fyet = 0;
70365 +
70366 +DEFINE_SPINLOCK(grsec_audit_lock);
70367 +
70368 +DEFINE_RWLOCK(grsec_exec_file_lock);
70369 +
70370 +char *gr_shared_page[4];
70371 +
70372 +char *gr_alert_log_fmt;
70373 +char *gr_audit_log_fmt;
70374 +char *gr_alert_log_buf;
70375 +char *gr_audit_log_buf;
70376 +
70377 +void __init
70378 +grsecurity_init(void)
70379 +{
70380 + int j;
70381 + /* create the per-cpu shared pages */
70382 +
70383 +#ifdef CONFIG_X86
70384 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
70385 +#endif
70386 +
70387 + for (j = 0; j < 4; j++) {
70388 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
70389 + if (gr_shared_page[j] == NULL) {
70390 + panic("Unable to allocate grsecurity shared page");
70391 + return;
70392 + }
70393 + }
70394 +
70395 + /* allocate log buffers */
70396 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
70397 + if (!gr_alert_log_fmt) {
70398 + panic("Unable to allocate grsecurity alert log format buffer");
70399 + return;
70400 + }
70401 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
70402 + if (!gr_audit_log_fmt) {
70403 + panic("Unable to allocate grsecurity audit log format buffer");
70404 + return;
70405 + }
70406 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70407 + if (!gr_alert_log_buf) {
70408 + panic("Unable to allocate grsecurity alert log buffer");
70409 + return;
70410 + }
70411 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70412 + if (!gr_audit_log_buf) {
70413 + panic("Unable to allocate grsecurity audit log buffer");
70414 + return;
70415 + }
70416 +
70417 +#ifdef CONFIG_GRKERNSEC_IO
70418 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
70419 + grsec_disable_privio = 1;
70420 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70421 + grsec_disable_privio = 1;
70422 +#else
70423 + grsec_disable_privio = 0;
70424 +#endif
70425 +#endif
70426 +
70427 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
70428 + /* for backward compatibility, tpe_invert always defaults to on if
70429 + enabled in the kernel
70430 + */
70431 + grsec_enable_tpe_invert = 1;
70432 +#endif
70433 +
70434 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70435 +#ifndef CONFIG_GRKERNSEC_SYSCTL
70436 + grsec_lock = 1;
70437 +#endif
70438 +
70439 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70440 + grsec_enable_log_rwxmaps = 1;
70441 +#endif
70442 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
70443 + grsec_enable_group = 1;
70444 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
70445 +#endif
70446 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70447 + grsec_enable_ptrace_readexec = 1;
70448 +#endif
70449 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70450 + grsec_enable_chdir = 1;
70451 +#endif
70452 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
70453 + grsec_enable_harden_ptrace = 1;
70454 +#endif
70455 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70456 + grsec_enable_harden_ipc = 1;
70457 +#endif
70458 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70459 + grsec_enable_mount = 1;
70460 +#endif
70461 +#ifdef CONFIG_GRKERNSEC_LINK
70462 + grsec_enable_link = 1;
70463 +#endif
70464 +#ifdef CONFIG_GRKERNSEC_BRUTE
70465 + grsec_enable_brute = 1;
70466 +#endif
70467 +#ifdef CONFIG_GRKERNSEC_DMESG
70468 + grsec_enable_dmesg = 1;
70469 +#endif
70470 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70471 + grsec_enable_blackhole = 1;
70472 + grsec_lastack_retries = 4;
70473 +#endif
70474 +#ifdef CONFIG_GRKERNSEC_FIFO
70475 + grsec_enable_fifo = 1;
70476 +#endif
70477 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70478 + grsec_enable_execlog = 1;
70479 +#endif
70480 +#ifdef CONFIG_GRKERNSEC_SETXID
70481 + grsec_enable_setxid = 1;
70482 +#endif
70483 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70484 + grsec_enable_signal = 1;
70485 +#endif
70486 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70487 + grsec_enable_forkfail = 1;
70488 +#endif
70489 +#ifdef CONFIG_GRKERNSEC_TIME
70490 + grsec_enable_time = 1;
70491 +#endif
70492 +#ifdef CONFIG_GRKERNSEC_RESLOG
70493 + grsec_resource_logging = 1;
70494 +#endif
70495 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70496 + grsec_enable_chroot_findtask = 1;
70497 +#endif
70498 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70499 + grsec_enable_chroot_unix = 1;
70500 +#endif
70501 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70502 + grsec_enable_chroot_mount = 1;
70503 +#endif
70504 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70505 + grsec_enable_chroot_fchdir = 1;
70506 +#endif
70507 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70508 + grsec_enable_chroot_shmat = 1;
70509 +#endif
70510 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70511 + grsec_enable_audit_ptrace = 1;
70512 +#endif
70513 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70514 + grsec_enable_chroot_double = 1;
70515 +#endif
70516 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70517 + grsec_enable_chroot_pivot = 1;
70518 +#endif
70519 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70520 + grsec_enable_chroot_chdir = 1;
70521 +#endif
70522 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70523 + grsec_enable_chroot_chmod = 1;
70524 +#endif
70525 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70526 + grsec_enable_chroot_mknod = 1;
70527 +#endif
70528 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70529 + grsec_enable_chroot_nice = 1;
70530 +#endif
70531 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70532 + grsec_enable_chroot_execlog = 1;
70533 +#endif
70534 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70535 + grsec_enable_chroot_caps = 1;
70536 +#endif
70537 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70538 + grsec_enable_chroot_sysctl = 1;
70539 +#endif
70540 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70541 + grsec_enable_symlinkown = 1;
70542 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
70543 +#endif
70544 +#ifdef CONFIG_GRKERNSEC_TPE
70545 + grsec_enable_tpe = 1;
70546 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
70547 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
70548 + grsec_enable_tpe_all = 1;
70549 +#endif
70550 +#endif
70551 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70552 + grsec_enable_socket_all = 1;
70553 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
70554 +#endif
70555 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70556 + grsec_enable_socket_client = 1;
70557 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
70558 +#endif
70559 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70560 + grsec_enable_socket_server = 1;
70561 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
70562 +#endif
70563 +#endif
70564 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
70565 + grsec_deny_new_usb = 1;
70566 +#endif
70567 +
70568 + return;
70569 +}
70570 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
70571 new file mode 100644
70572 index 0000000..f365de0
70573 --- /dev/null
70574 +++ b/grsecurity/grsec_ipc.c
70575 @@ -0,0 +1,22 @@
70576 +#include <linux/kernel.h>
70577 +#include <linux/mm.h>
70578 +#include <linux/sched.h>
70579 +#include <linux/file.h>
70580 +#include <linux/ipc.h>
70581 +#include <linux/ipc_namespace.h>
70582 +#include <linux/grsecurity.h>
70583 +#include <linux/grinternal.h>
70584 +
70585 +int
70586 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
70587 +{
70588 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70589 + int write = (requested_mode & 00002);
70590 +
70591 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
70592 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
70593 + return 0;
70594 + }
70595 +#endif
70596 + return 1;
70597 +}
70598 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
70599 new file mode 100644
70600 index 0000000..5e05e20
70601 --- /dev/null
70602 +++ b/grsecurity/grsec_link.c
70603 @@ -0,0 +1,58 @@
70604 +#include <linux/kernel.h>
70605 +#include <linux/sched.h>
70606 +#include <linux/fs.h>
70607 +#include <linux/file.h>
70608 +#include <linux/grinternal.h>
70609 +
70610 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
70611 +{
70612 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70613 + const struct inode *link_inode = link->dentry->d_inode;
70614 +
70615 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
70616 + /* ignore root-owned links, e.g. /proc/self */
70617 + gr_is_global_nonroot(link_inode->i_uid) && target &&
70618 + !uid_eq(link_inode->i_uid, target->i_uid)) {
70619 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
70620 + return 1;
70621 + }
70622 +#endif
70623 + return 0;
70624 +}
70625 +
70626 +int
70627 +gr_handle_follow_link(const struct inode *parent,
70628 + const struct inode *inode,
70629 + const struct dentry *dentry, const struct vfsmount *mnt)
70630 +{
70631 +#ifdef CONFIG_GRKERNSEC_LINK
70632 + const struct cred *cred = current_cred();
70633 +
70634 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
70635 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
70636 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
70637 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
70638 + return -EACCES;
70639 + }
70640 +#endif
70641 + return 0;
70642 +}
70643 +
70644 +int
70645 +gr_handle_hardlink(const struct dentry *dentry,
70646 + const struct vfsmount *mnt,
70647 + struct inode *inode, const int mode, const struct filename *to)
70648 +{
70649 +#ifdef CONFIG_GRKERNSEC_LINK
70650 + const struct cred *cred = current_cred();
70651 +
70652 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
70653 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
70654 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
70655 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
70656 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
70657 + return -EPERM;
70658 + }
70659 +#endif
70660 + return 0;
70661 +}
70662 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
70663 new file mode 100644
70664 index 0000000..dbe0a6b
70665 --- /dev/null
70666 +++ b/grsecurity/grsec_log.c
70667 @@ -0,0 +1,341 @@
70668 +#include <linux/kernel.h>
70669 +#include <linux/sched.h>
70670 +#include <linux/file.h>
70671 +#include <linux/tty.h>
70672 +#include <linux/fs.h>
70673 +#include <linux/mm.h>
70674 +#include <linux/grinternal.h>
70675 +
70676 +#ifdef CONFIG_TREE_PREEMPT_RCU
70677 +#define DISABLE_PREEMPT() preempt_disable()
70678 +#define ENABLE_PREEMPT() preempt_enable()
70679 +#else
70680 +#define DISABLE_PREEMPT()
70681 +#define ENABLE_PREEMPT()
70682 +#endif
70683 +
70684 +#define BEGIN_LOCKS(x) \
70685 + DISABLE_PREEMPT(); \
70686 + rcu_read_lock(); \
70687 + read_lock(&tasklist_lock); \
70688 + read_lock(&grsec_exec_file_lock); \
70689 + if (x != GR_DO_AUDIT) \
70690 + spin_lock(&grsec_alert_lock); \
70691 + else \
70692 + spin_lock(&grsec_audit_lock)
70693 +
70694 +#define END_LOCKS(x) \
70695 + if (x != GR_DO_AUDIT) \
70696 + spin_unlock(&grsec_alert_lock); \
70697 + else \
70698 + spin_unlock(&grsec_audit_lock); \
70699 + read_unlock(&grsec_exec_file_lock); \
70700 + read_unlock(&tasklist_lock); \
70701 + rcu_read_unlock(); \
70702 + ENABLE_PREEMPT(); \
70703 + if (x == GR_DONT_AUDIT) \
70704 + gr_handle_alertkill(current)
70705 +
70706 +enum {
70707 + FLOODING,
70708 + NO_FLOODING
70709 +};
70710 +
70711 +extern char *gr_alert_log_fmt;
70712 +extern char *gr_audit_log_fmt;
70713 +extern char *gr_alert_log_buf;
70714 +extern char *gr_audit_log_buf;
70715 +
70716 +static int gr_log_start(int audit)
70717 +{
70718 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
70719 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
70720 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70721 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
70722 + unsigned long curr_secs = get_seconds();
70723 +
70724 + if (audit == GR_DO_AUDIT)
70725 + goto set_fmt;
70726 +
70727 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
70728 + grsec_alert_wtime = curr_secs;
70729 + grsec_alert_fyet = 0;
70730 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
70731 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
70732 + grsec_alert_fyet++;
70733 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
70734 + grsec_alert_wtime = curr_secs;
70735 + grsec_alert_fyet++;
70736 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
70737 + return FLOODING;
70738 + }
70739 + else return FLOODING;
70740 +
70741 +set_fmt:
70742 +#endif
70743 + memset(buf, 0, PAGE_SIZE);
70744 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
70745 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
70746 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70747 + } else if (current->signal->curr_ip) {
70748 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
70749 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
70750 + } else if (gr_acl_is_enabled()) {
70751 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
70752 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70753 + } else {
70754 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
70755 + strcpy(buf, fmt);
70756 + }
70757 +
70758 + return NO_FLOODING;
70759 +}
70760 +
70761 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70762 + __attribute__ ((format (printf, 2, 0)));
70763 +
70764 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70765 +{
70766 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70767 + unsigned int len = strlen(buf);
70768 +
70769 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70770 +
70771 + return;
70772 +}
70773 +
70774 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70775 + __attribute__ ((format (printf, 2, 3)));
70776 +
70777 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70778 +{
70779 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70780 + unsigned int len = strlen(buf);
70781 + va_list ap;
70782 +
70783 + va_start(ap, msg);
70784 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70785 + va_end(ap);
70786 +
70787 + return;
70788 +}
70789 +
70790 +static void gr_log_end(int audit, int append_default)
70791 +{
70792 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70793 + if (append_default) {
70794 + struct task_struct *task = current;
70795 + struct task_struct *parent = task->real_parent;
70796 + const struct cred *cred = __task_cred(task);
70797 + const struct cred *pcred = __task_cred(parent);
70798 + unsigned int len = strlen(buf);
70799 +
70800 + 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));
70801 + }
70802 +
70803 + printk("%s\n", buf);
70804 +
70805 + return;
70806 +}
70807 +
70808 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
70809 +{
70810 + int logtype;
70811 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
70812 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
70813 + void *voidptr = NULL;
70814 + int num1 = 0, num2 = 0;
70815 + unsigned long ulong1 = 0, ulong2 = 0;
70816 + struct dentry *dentry = NULL;
70817 + struct vfsmount *mnt = NULL;
70818 + struct file *file = NULL;
70819 + struct task_struct *task = NULL;
70820 + struct vm_area_struct *vma = NULL;
70821 + const struct cred *cred, *pcred;
70822 + va_list ap;
70823 +
70824 + BEGIN_LOCKS(audit);
70825 + logtype = gr_log_start(audit);
70826 + if (logtype == FLOODING) {
70827 + END_LOCKS(audit);
70828 + return;
70829 + }
70830 + va_start(ap, argtypes);
70831 + switch (argtypes) {
70832 + case GR_TTYSNIFF:
70833 + task = va_arg(ap, struct task_struct *);
70834 + 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));
70835 + break;
70836 + case GR_SYSCTL_HIDDEN:
70837 + str1 = va_arg(ap, char *);
70838 + gr_log_middle_varargs(audit, msg, result, str1);
70839 + break;
70840 + case GR_RBAC:
70841 + dentry = va_arg(ap, struct dentry *);
70842 + mnt = va_arg(ap, struct vfsmount *);
70843 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70844 + break;
70845 + case GR_RBAC_STR:
70846 + dentry = va_arg(ap, struct dentry *);
70847 + mnt = va_arg(ap, struct vfsmount *);
70848 + str1 = va_arg(ap, char *);
70849 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70850 + break;
70851 + case GR_STR_RBAC:
70852 + str1 = va_arg(ap, char *);
70853 + dentry = va_arg(ap, struct dentry *);
70854 + mnt = va_arg(ap, struct vfsmount *);
70855 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70856 + break;
70857 + case GR_RBAC_MODE2:
70858 + dentry = va_arg(ap, struct dentry *);
70859 + mnt = va_arg(ap, struct vfsmount *);
70860 + str1 = va_arg(ap, char *);
70861 + str2 = va_arg(ap, char *);
70862 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70863 + break;
70864 + case GR_RBAC_MODE3:
70865 + dentry = va_arg(ap, struct dentry *);
70866 + mnt = va_arg(ap, struct vfsmount *);
70867 + str1 = va_arg(ap, char *);
70868 + str2 = va_arg(ap, char *);
70869 + str3 = va_arg(ap, char *);
70870 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70871 + break;
70872 + case GR_FILENAME:
70873 + dentry = va_arg(ap, struct dentry *);
70874 + mnt = va_arg(ap, struct vfsmount *);
70875 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70876 + break;
70877 + case GR_STR_FILENAME:
70878 + str1 = va_arg(ap, char *);
70879 + dentry = va_arg(ap, struct dentry *);
70880 + mnt = va_arg(ap, struct vfsmount *);
70881 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70882 + break;
70883 + case GR_FILENAME_STR:
70884 + dentry = va_arg(ap, struct dentry *);
70885 + mnt = va_arg(ap, struct vfsmount *);
70886 + str1 = va_arg(ap, char *);
70887 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70888 + break;
70889 + case GR_FILENAME_TWO_INT:
70890 + dentry = va_arg(ap, struct dentry *);
70891 + mnt = va_arg(ap, struct vfsmount *);
70892 + num1 = va_arg(ap, int);
70893 + num2 = va_arg(ap, int);
70894 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70895 + break;
70896 + case GR_FILENAME_TWO_INT_STR:
70897 + dentry = va_arg(ap, struct dentry *);
70898 + mnt = va_arg(ap, struct vfsmount *);
70899 + num1 = va_arg(ap, int);
70900 + num2 = va_arg(ap, int);
70901 + str1 = va_arg(ap, char *);
70902 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70903 + break;
70904 + case GR_TEXTREL:
70905 + file = va_arg(ap, struct file *);
70906 + ulong1 = va_arg(ap, unsigned long);
70907 + ulong2 = va_arg(ap, unsigned long);
70908 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70909 + break;
70910 + case GR_PTRACE:
70911 + task = va_arg(ap, struct task_struct *);
70912 + 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));
70913 + break;
70914 + case GR_RESOURCE:
70915 + task = va_arg(ap, struct task_struct *);
70916 + cred = __task_cred(task);
70917 + pcred = __task_cred(task->real_parent);
70918 + ulong1 = va_arg(ap, unsigned long);
70919 + str1 = va_arg(ap, char *);
70920 + ulong2 = va_arg(ap, unsigned long);
70921 + 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));
70922 + break;
70923 + case GR_CAP:
70924 + task = va_arg(ap, struct task_struct *);
70925 + cred = __task_cred(task);
70926 + pcred = __task_cred(task->real_parent);
70927 + str1 = va_arg(ap, char *);
70928 + 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));
70929 + break;
70930 + case GR_SIG:
70931 + str1 = va_arg(ap, char *);
70932 + voidptr = va_arg(ap, void *);
70933 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70934 + break;
70935 + case GR_SIG2:
70936 + task = va_arg(ap, struct task_struct *);
70937 + cred = __task_cred(task);
70938 + pcred = __task_cred(task->real_parent);
70939 + num1 = va_arg(ap, int);
70940 + 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));
70941 + break;
70942 + case GR_CRASH1:
70943 + task = va_arg(ap, struct task_struct *);
70944 + cred = __task_cred(task);
70945 + pcred = __task_cred(task->real_parent);
70946 + ulong1 = va_arg(ap, unsigned long);
70947 + 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);
70948 + break;
70949 + case GR_CRASH2:
70950 + task = va_arg(ap, struct task_struct *);
70951 + cred = __task_cred(task);
70952 + pcred = __task_cred(task->real_parent);
70953 + ulong1 = va_arg(ap, unsigned long);
70954 + 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);
70955 + break;
70956 + case GR_RWXMAP:
70957 + file = va_arg(ap, struct file *);
70958 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70959 + break;
70960 + case GR_RWXMAPVMA:
70961 + vma = va_arg(ap, struct vm_area_struct *);
70962 + if (vma->vm_file)
70963 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70964 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70965 + str1 = "<stack>";
70966 + else if (vma->vm_start <= current->mm->brk &&
70967 + vma->vm_end >= current->mm->start_brk)
70968 + str1 = "<heap>";
70969 + else
70970 + str1 = "<anonymous mapping>";
70971 + gr_log_middle_varargs(audit, msg, str1);
70972 + break;
70973 + case GR_PSACCT:
70974 + {
70975 + unsigned int wday, cday;
70976 + __u8 whr, chr;
70977 + __u8 wmin, cmin;
70978 + __u8 wsec, csec;
70979 + char cur_tty[64] = { 0 };
70980 + char parent_tty[64] = { 0 };
70981 +
70982 + task = va_arg(ap, struct task_struct *);
70983 + wday = va_arg(ap, unsigned int);
70984 + cday = va_arg(ap, unsigned int);
70985 + whr = va_arg(ap, int);
70986 + chr = va_arg(ap, int);
70987 + wmin = va_arg(ap, int);
70988 + cmin = va_arg(ap, int);
70989 + wsec = va_arg(ap, int);
70990 + csec = va_arg(ap, int);
70991 + ulong1 = va_arg(ap, unsigned long);
70992 + cred = __task_cred(task);
70993 + pcred = __task_cred(task->real_parent);
70994 +
70995 + 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));
70996 + }
70997 + break;
70998 + default:
70999 + gr_log_middle(audit, msg, ap);
71000 + }
71001 + va_end(ap);
71002 + // these don't need DEFAULTSECARGS printed on the end
71003 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
71004 + gr_log_end(audit, 0);
71005 + else
71006 + gr_log_end(audit, 1);
71007 + END_LOCKS(audit);
71008 +}
71009 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
71010 new file mode 100644
71011 index 0000000..f536303
71012 --- /dev/null
71013 +++ b/grsecurity/grsec_mem.c
71014 @@ -0,0 +1,40 @@
71015 +#include <linux/kernel.h>
71016 +#include <linux/sched.h>
71017 +#include <linux/mm.h>
71018 +#include <linux/mman.h>
71019 +#include <linux/grinternal.h>
71020 +
71021 +void
71022 +gr_handle_ioperm(void)
71023 +{
71024 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
71025 + return;
71026 +}
71027 +
71028 +void
71029 +gr_handle_iopl(void)
71030 +{
71031 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
71032 + return;
71033 +}
71034 +
71035 +void
71036 +gr_handle_mem_readwrite(u64 from, u64 to)
71037 +{
71038 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
71039 + return;
71040 +}
71041 +
71042 +void
71043 +gr_handle_vm86(void)
71044 +{
71045 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
71046 + return;
71047 +}
71048 +
71049 +void
71050 +gr_log_badprocpid(const char *entry)
71051 +{
71052 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
71053 + return;
71054 +}
71055 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
71056 new file mode 100644
71057 index 0000000..2131422
71058 --- /dev/null
71059 +++ b/grsecurity/grsec_mount.c
71060 @@ -0,0 +1,62 @@
71061 +#include <linux/kernel.h>
71062 +#include <linux/sched.h>
71063 +#include <linux/mount.h>
71064 +#include <linux/grsecurity.h>
71065 +#include <linux/grinternal.h>
71066 +
71067 +void
71068 +gr_log_remount(const char *devname, const int retval)
71069 +{
71070 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71071 + if (grsec_enable_mount && (retval >= 0))
71072 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
71073 +#endif
71074 + return;
71075 +}
71076 +
71077 +void
71078 +gr_log_unmount(const char *devname, const int retval)
71079 +{
71080 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71081 + if (grsec_enable_mount && (retval >= 0))
71082 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
71083 +#endif
71084 + return;
71085 +}
71086 +
71087 +void
71088 +gr_log_mount(const char *from, const char *to, const int retval)
71089 +{
71090 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71091 + if (grsec_enable_mount && (retval >= 0))
71092 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
71093 +#endif
71094 + return;
71095 +}
71096 +
71097 +int
71098 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
71099 +{
71100 +#ifdef CONFIG_GRKERNSEC_ROFS
71101 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
71102 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
71103 + return -EPERM;
71104 + } else
71105 + return 0;
71106 +#endif
71107 + return 0;
71108 +}
71109 +
71110 +int
71111 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
71112 +{
71113 +#ifdef CONFIG_GRKERNSEC_ROFS
71114 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
71115 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
71116 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
71117 + return -EPERM;
71118 + } else
71119 + return 0;
71120 +#endif
71121 + return 0;
71122 +}
71123 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
71124 new file mode 100644
71125 index 0000000..6ee9d50
71126 --- /dev/null
71127 +++ b/grsecurity/grsec_pax.c
71128 @@ -0,0 +1,45 @@
71129 +#include <linux/kernel.h>
71130 +#include <linux/sched.h>
71131 +#include <linux/mm.h>
71132 +#include <linux/file.h>
71133 +#include <linux/grinternal.h>
71134 +#include <linux/grsecurity.h>
71135 +
71136 +void
71137 +gr_log_textrel(struct vm_area_struct * vma)
71138 +{
71139 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71140 + if (grsec_enable_log_rwxmaps)
71141 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
71142 +#endif
71143 + return;
71144 +}
71145 +
71146 +void gr_log_ptgnustack(struct file *file)
71147 +{
71148 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71149 + if (grsec_enable_log_rwxmaps)
71150 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
71151 +#endif
71152 + return;
71153 +}
71154 +
71155 +void
71156 +gr_log_rwxmmap(struct file *file)
71157 +{
71158 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71159 + if (grsec_enable_log_rwxmaps)
71160 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
71161 +#endif
71162 + return;
71163 +}
71164 +
71165 +void
71166 +gr_log_rwxmprotect(struct vm_area_struct *vma)
71167 +{
71168 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71169 + if (grsec_enable_log_rwxmaps)
71170 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
71171 +#endif
71172 + return;
71173 +}
71174 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
71175 new file mode 100644
71176 index 0000000..f7f29aa
71177 --- /dev/null
71178 +++ b/grsecurity/grsec_ptrace.c
71179 @@ -0,0 +1,30 @@
71180 +#include <linux/kernel.h>
71181 +#include <linux/sched.h>
71182 +#include <linux/grinternal.h>
71183 +#include <linux/security.h>
71184 +
71185 +void
71186 +gr_audit_ptrace(struct task_struct *task)
71187 +{
71188 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71189 + if (grsec_enable_audit_ptrace)
71190 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
71191 +#endif
71192 + return;
71193 +}
71194 +
71195 +int
71196 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
71197 +{
71198 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71199 + const struct dentry *dentry = file->f_path.dentry;
71200 + const struct vfsmount *mnt = file->f_path.mnt;
71201 +
71202 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
71203 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
71204 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
71205 + return -EACCES;
71206 + }
71207 +#endif
71208 + return 0;
71209 +}
71210 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
71211 new file mode 100644
71212 index 0000000..4e29cc7
71213 --- /dev/null
71214 +++ b/grsecurity/grsec_sig.c
71215 @@ -0,0 +1,246 @@
71216 +#include <linux/kernel.h>
71217 +#include <linux/sched.h>
71218 +#include <linux/fs.h>
71219 +#include <linux/delay.h>
71220 +#include <linux/grsecurity.h>
71221 +#include <linux/grinternal.h>
71222 +#include <linux/hardirq.h>
71223 +
71224 +char *signames[] = {
71225 + [SIGSEGV] = "Segmentation fault",
71226 + [SIGILL] = "Illegal instruction",
71227 + [SIGABRT] = "Abort",
71228 + [SIGBUS] = "Invalid alignment/Bus error"
71229 +};
71230 +
71231 +void
71232 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
71233 +{
71234 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71235 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
71236 + (sig == SIGABRT) || (sig == SIGBUS))) {
71237 + if (task_pid_nr(t) == task_pid_nr(current)) {
71238 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
71239 + } else {
71240 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
71241 + }
71242 + }
71243 +#endif
71244 + return;
71245 +}
71246 +
71247 +int
71248 +gr_handle_signal(const struct task_struct *p, const int sig)
71249 +{
71250 +#ifdef CONFIG_GRKERNSEC
71251 + /* ignore the 0 signal for protected task checks */
71252 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
71253 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
71254 + return -EPERM;
71255 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
71256 + return -EPERM;
71257 + }
71258 +#endif
71259 + return 0;
71260 +}
71261 +
71262 +#ifdef CONFIG_GRKERNSEC
71263 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
71264 +
71265 +int gr_fake_force_sig(int sig, struct task_struct *t)
71266 +{
71267 + unsigned long int flags;
71268 + int ret, blocked, ignored;
71269 + struct k_sigaction *action;
71270 +
71271 + spin_lock_irqsave(&t->sighand->siglock, flags);
71272 + action = &t->sighand->action[sig-1];
71273 + ignored = action->sa.sa_handler == SIG_IGN;
71274 + blocked = sigismember(&t->blocked, sig);
71275 + if (blocked || ignored) {
71276 + action->sa.sa_handler = SIG_DFL;
71277 + if (blocked) {
71278 + sigdelset(&t->blocked, sig);
71279 + recalc_sigpending_and_wake(t);
71280 + }
71281 + }
71282 + if (action->sa.sa_handler == SIG_DFL)
71283 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
71284 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
71285 +
71286 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
71287 +
71288 + return ret;
71289 +}
71290 +#endif
71291 +
71292 +#ifdef CONFIG_GRKERNSEC_BRUTE
71293 +#define GR_USER_BAN_TIME (15 * 60)
71294 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
71295 +
71296 +static int __get_dumpable(unsigned long mm_flags)
71297 +{
71298 + int ret;
71299 +
71300 + ret = mm_flags & MMF_DUMPABLE_MASK;
71301 + return (ret >= 2) ? 2 : ret;
71302 +}
71303 +#endif
71304 +
71305 +void gr_handle_brute_attach(unsigned long mm_flags)
71306 +{
71307 +#ifdef CONFIG_GRKERNSEC_BRUTE
71308 + struct task_struct *p = current;
71309 + kuid_t uid = GLOBAL_ROOT_UID;
71310 + int daemon = 0;
71311 +
71312 + if (!grsec_enable_brute)
71313 + return;
71314 +
71315 + rcu_read_lock();
71316 + read_lock(&tasklist_lock);
71317 + read_lock(&grsec_exec_file_lock);
71318 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
71319 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
71320 + p->real_parent->brute = 1;
71321 + daemon = 1;
71322 + } else {
71323 + const struct cred *cred = __task_cred(p), *cred2;
71324 + struct task_struct *tsk, *tsk2;
71325 +
71326 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
71327 + struct user_struct *user;
71328 +
71329 + uid = cred->uid;
71330 +
71331 + /* this is put upon execution past expiration */
71332 + user = find_user(uid);
71333 + if (user == NULL)
71334 + goto unlock;
71335 + user->suid_banned = 1;
71336 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
71337 + if (user->suid_ban_expires == ~0UL)
71338 + user->suid_ban_expires--;
71339 +
71340 + /* only kill other threads of the same binary, from the same user */
71341 + do_each_thread(tsk2, tsk) {
71342 + cred2 = __task_cred(tsk);
71343 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
71344 + gr_fake_force_sig(SIGKILL, tsk);
71345 + } while_each_thread(tsk2, tsk);
71346 + }
71347 + }
71348 +unlock:
71349 + read_unlock(&grsec_exec_file_lock);
71350 + read_unlock(&tasklist_lock);
71351 + rcu_read_unlock();
71352 +
71353 + if (gr_is_global_nonroot(uid))
71354 + 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);
71355 + else if (daemon)
71356 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
71357 +
71358 +#endif
71359 + return;
71360 +}
71361 +
71362 +void gr_handle_brute_check(void)
71363 +{
71364 +#ifdef CONFIG_GRKERNSEC_BRUTE
71365 + struct task_struct *p = current;
71366 +
71367 + if (unlikely(p->brute)) {
71368 + if (!grsec_enable_brute)
71369 + p->brute = 0;
71370 + else if (time_before(get_seconds(), p->brute_expires))
71371 + msleep(30 * 1000);
71372 + }
71373 +#endif
71374 + return;
71375 +}
71376 +
71377 +void gr_handle_kernel_exploit(void)
71378 +{
71379 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71380 + const struct cred *cred;
71381 + struct task_struct *tsk, *tsk2;
71382 + struct user_struct *user;
71383 + kuid_t uid;
71384 +
71385 + if (in_irq() || in_serving_softirq() || in_nmi())
71386 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
71387 +
71388 + uid = current_uid();
71389 +
71390 + if (gr_is_global_root(uid))
71391 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
71392 + else {
71393 + /* kill all the processes of this user, hold a reference
71394 + to their creds struct, and prevent them from creating
71395 + another process until system reset
71396 + */
71397 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
71398 + GR_GLOBAL_UID(uid));
71399 + /* we intentionally leak this ref */
71400 + user = get_uid(current->cred->user);
71401 + if (user)
71402 + user->kernel_banned = 1;
71403 +
71404 + /* kill all processes of this user */
71405 + read_lock(&tasklist_lock);
71406 + do_each_thread(tsk2, tsk) {
71407 + cred = __task_cred(tsk);
71408 + if (uid_eq(cred->uid, uid))
71409 + gr_fake_force_sig(SIGKILL, tsk);
71410 + } while_each_thread(tsk2, tsk);
71411 + read_unlock(&tasklist_lock);
71412 + }
71413 +#endif
71414 +}
71415 +
71416 +#ifdef CONFIG_GRKERNSEC_BRUTE
71417 +static bool suid_ban_expired(struct user_struct *user)
71418 +{
71419 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
71420 + user->suid_banned = 0;
71421 + user->suid_ban_expires = 0;
71422 + free_uid(user);
71423 + return true;
71424 + }
71425 +
71426 + return false;
71427 +}
71428 +#endif
71429 +
71430 +int gr_process_kernel_exec_ban(void)
71431 +{
71432 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71433 + if (unlikely(current->cred->user->kernel_banned))
71434 + return -EPERM;
71435 +#endif
71436 + return 0;
71437 +}
71438 +
71439 +int gr_process_kernel_setuid_ban(struct user_struct *user)
71440 +{
71441 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71442 + if (unlikely(user->kernel_banned))
71443 + gr_fake_force_sig(SIGKILL, current);
71444 +#endif
71445 + return 0;
71446 +}
71447 +
71448 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
71449 +{
71450 +#ifdef CONFIG_GRKERNSEC_BRUTE
71451 + struct user_struct *user = current->cred->user;
71452 + if (unlikely(user->suid_banned)) {
71453 + if (suid_ban_expired(user))
71454 + return 0;
71455 + /* disallow execution of suid binaries only */
71456 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
71457 + return -EPERM;
71458 + }
71459 +#endif
71460 + return 0;
71461 +}
71462 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
71463 new file mode 100644
71464 index 0000000..4030d57
71465 --- /dev/null
71466 +++ b/grsecurity/grsec_sock.c
71467 @@ -0,0 +1,244 @@
71468 +#include <linux/kernel.h>
71469 +#include <linux/module.h>
71470 +#include <linux/sched.h>
71471 +#include <linux/file.h>
71472 +#include <linux/net.h>
71473 +#include <linux/in.h>
71474 +#include <linux/ip.h>
71475 +#include <net/sock.h>
71476 +#include <net/inet_sock.h>
71477 +#include <linux/grsecurity.h>
71478 +#include <linux/grinternal.h>
71479 +#include <linux/gracl.h>
71480 +
71481 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
71482 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
71483 +
71484 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
71485 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
71486 +
71487 +#ifdef CONFIG_UNIX_MODULE
71488 +EXPORT_SYMBOL(gr_acl_handle_unix);
71489 +EXPORT_SYMBOL(gr_acl_handle_mknod);
71490 +EXPORT_SYMBOL(gr_handle_chroot_unix);
71491 +EXPORT_SYMBOL(gr_handle_create);
71492 +#endif
71493 +
71494 +#ifdef CONFIG_GRKERNSEC
71495 +#define gr_conn_table_size 32749
71496 +struct conn_table_entry {
71497 + struct conn_table_entry *next;
71498 + struct signal_struct *sig;
71499 +};
71500 +
71501 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
71502 +DEFINE_SPINLOCK(gr_conn_table_lock);
71503 +
71504 +extern const char * gr_socktype_to_name(unsigned char type);
71505 +extern const char * gr_proto_to_name(unsigned char proto);
71506 +extern const char * gr_sockfamily_to_name(unsigned char family);
71507 +
71508 +static __inline__ int
71509 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
71510 +{
71511 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
71512 +}
71513 +
71514 +static __inline__ int
71515 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
71516 + __u16 sport, __u16 dport)
71517 +{
71518 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
71519 + sig->gr_sport == sport && sig->gr_dport == dport))
71520 + return 1;
71521 + else
71522 + return 0;
71523 +}
71524 +
71525 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
71526 +{
71527 + struct conn_table_entry **match;
71528 + unsigned int index;
71529 +
71530 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71531 + sig->gr_sport, sig->gr_dport,
71532 + gr_conn_table_size);
71533 +
71534 + newent->sig = sig;
71535 +
71536 + match = &gr_conn_table[index];
71537 + newent->next = *match;
71538 + *match = newent;
71539 +
71540 + return;
71541 +}
71542 +
71543 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
71544 +{
71545 + struct conn_table_entry *match, *last = NULL;
71546 + unsigned int index;
71547 +
71548 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71549 + sig->gr_sport, sig->gr_dport,
71550 + gr_conn_table_size);
71551 +
71552 + match = gr_conn_table[index];
71553 + while (match && !conn_match(match->sig,
71554 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
71555 + sig->gr_dport)) {
71556 + last = match;
71557 + match = match->next;
71558 + }
71559 +
71560 + if (match) {
71561 + if (last)
71562 + last->next = match->next;
71563 + else
71564 + gr_conn_table[index] = NULL;
71565 + kfree(match);
71566 + }
71567 +
71568 + return;
71569 +}
71570 +
71571 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
71572 + __u16 sport, __u16 dport)
71573 +{
71574 + struct conn_table_entry *match;
71575 + unsigned int index;
71576 +
71577 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
71578 +
71579 + match = gr_conn_table[index];
71580 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
71581 + match = match->next;
71582 +
71583 + if (match)
71584 + return match->sig;
71585 + else
71586 + return NULL;
71587 +}
71588 +
71589 +#endif
71590 +
71591 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
71592 +{
71593 +#ifdef CONFIG_GRKERNSEC
71594 + struct signal_struct *sig = task->signal;
71595 + struct conn_table_entry *newent;
71596 +
71597 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
71598 + if (newent == NULL)
71599 + return;
71600 + /* no bh lock needed since we are called with bh disabled */
71601 + spin_lock(&gr_conn_table_lock);
71602 + gr_del_task_from_ip_table_nolock(sig);
71603 + sig->gr_saddr = inet->inet_rcv_saddr;
71604 + sig->gr_daddr = inet->inet_daddr;
71605 + sig->gr_sport = inet->inet_sport;
71606 + sig->gr_dport = inet->inet_dport;
71607 + gr_add_to_task_ip_table_nolock(sig, newent);
71608 + spin_unlock(&gr_conn_table_lock);
71609 +#endif
71610 + return;
71611 +}
71612 +
71613 +void gr_del_task_from_ip_table(struct task_struct *task)
71614 +{
71615 +#ifdef CONFIG_GRKERNSEC
71616 + spin_lock_bh(&gr_conn_table_lock);
71617 + gr_del_task_from_ip_table_nolock(task->signal);
71618 + spin_unlock_bh(&gr_conn_table_lock);
71619 +#endif
71620 + return;
71621 +}
71622 +
71623 +void
71624 +gr_attach_curr_ip(const struct sock *sk)
71625 +{
71626 +#ifdef CONFIG_GRKERNSEC
71627 + struct signal_struct *p, *set;
71628 + const struct inet_sock *inet = inet_sk(sk);
71629 +
71630 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
71631 + return;
71632 +
71633 + set = current->signal;
71634 +
71635 + spin_lock_bh(&gr_conn_table_lock);
71636 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
71637 + inet->inet_dport, inet->inet_sport);
71638 + if (unlikely(p != NULL)) {
71639 + set->curr_ip = p->curr_ip;
71640 + set->used_accept = 1;
71641 + gr_del_task_from_ip_table_nolock(p);
71642 + spin_unlock_bh(&gr_conn_table_lock);
71643 + return;
71644 + }
71645 + spin_unlock_bh(&gr_conn_table_lock);
71646 +
71647 + set->curr_ip = inet->inet_daddr;
71648 + set->used_accept = 1;
71649 +#endif
71650 + return;
71651 +}
71652 +
71653 +int
71654 +gr_handle_sock_all(const int family, const int type, const int protocol)
71655 +{
71656 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71657 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
71658 + (family != AF_UNIX)) {
71659 + if (family == AF_INET)
71660 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
71661 + else
71662 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
71663 + return -EACCES;
71664 + }
71665 +#endif
71666 + return 0;
71667 +}
71668 +
71669 +int
71670 +gr_handle_sock_server(const struct sockaddr *sck)
71671 +{
71672 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71673 + if (grsec_enable_socket_server &&
71674 + in_group_p(grsec_socket_server_gid) &&
71675 + sck && (sck->sa_family != AF_UNIX) &&
71676 + (sck->sa_family != AF_LOCAL)) {
71677 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71678 + return -EACCES;
71679 + }
71680 +#endif
71681 + return 0;
71682 +}
71683 +
71684 +int
71685 +gr_handle_sock_server_other(const struct sock *sck)
71686 +{
71687 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71688 + if (grsec_enable_socket_server &&
71689 + in_group_p(grsec_socket_server_gid) &&
71690 + sck && (sck->sk_family != AF_UNIX) &&
71691 + (sck->sk_family != AF_LOCAL)) {
71692 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71693 + return -EACCES;
71694 + }
71695 +#endif
71696 + return 0;
71697 +}
71698 +
71699 +int
71700 +gr_handle_sock_client(const struct sockaddr *sck)
71701 +{
71702 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71703 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
71704 + sck && (sck->sa_family != AF_UNIX) &&
71705 + (sck->sa_family != AF_LOCAL)) {
71706 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
71707 + return -EACCES;
71708 + }
71709 +#endif
71710 + return 0;
71711 +}
71712 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
71713 new file mode 100644
71714 index 0000000..8159888
71715 --- /dev/null
71716 +++ b/grsecurity/grsec_sysctl.c
71717 @@ -0,0 +1,479 @@
71718 +#include <linux/kernel.h>
71719 +#include <linux/sched.h>
71720 +#include <linux/sysctl.h>
71721 +#include <linux/grsecurity.h>
71722 +#include <linux/grinternal.h>
71723 +
71724 +int
71725 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
71726 +{
71727 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71728 + if (dirname == NULL || name == NULL)
71729 + return 0;
71730 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
71731 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
71732 + return -EACCES;
71733 + }
71734 +#endif
71735 + return 0;
71736 +}
71737 +
71738 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
71739 +static int __maybe_unused __read_only one = 1;
71740 +#endif
71741 +
71742 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
71743 + defined(CONFIG_GRKERNSEC_DENYUSB)
71744 +struct ctl_table grsecurity_table[] = {
71745 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71746 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
71747 +#ifdef CONFIG_GRKERNSEC_IO
71748 + {
71749 + .procname = "disable_priv_io",
71750 + .data = &grsec_disable_privio,
71751 + .maxlen = sizeof(int),
71752 + .mode = 0600,
71753 + .proc_handler = &proc_dointvec,
71754 + },
71755 +#endif
71756 +#endif
71757 +#ifdef CONFIG_GRKERNSEC_LINK
71758 + {
71759 + .procname = "linking_restrictions",
71760 + .data = &grsec_enable_link,
71761 + .maxlen = sizeof(int),
71762 + .mode = 0600,
71763 + .proc_handler = &proc_dointvec,
71764 + },
71765 +#endif
71766 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71767 + {
71768 + .procname = "enforce_symlinksifowner",
71769 + .data = &grsec_enable_symlinkown,
71770 + .maxlen = sizeof(int),
71771 + .mode = 0600,
71772 + .proc_handler = &proc_dointvec,
71773 + },
71774 + {
71775 + .procname = "symlinkown_gid",
71776 + .data = &grsec_symlinkown_gid,
71777 + .maxlen = sizeof(int),
71778 + .mode = 0600,
71779 + .proc_handler = &proc_dointvec,
71780 + },
71781 +#endif
71782 +#ifdef CONFIG_GRKERNSEC_BRUTE
71783 + {
71784 + .procname = "deter_bruteforce",
71785 + .data = &grsec_enable_brute,
71786 + .maxlen = sizeof(int),
71787 + .mode = 0600,
71788 + .proc_handler = &proc_dointvec,
71789 + },
71790 +#endif
71791 +#ifdef CONFIG_GRKERNSEC_FIFO
71792 + {
71793 + .procname = "fifo_restrictions",
71794 + .data = &grsec_enable_fifo,
71795 + .maxlen = sizeof(int),
71796 + .mode = 0600,
71797 + .proc_handler = &proc_dointvec,
71798 + },
71799 +#endif
71800 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71801 + {
71802 + .procname = "ptrace_readexec",
71803 + .data = &grsec_enable_ptrace_readexec,
71804 + .maxlen = sizeof(int),
71805 + .mode = 0600,
71806 + .proc_handler = &proc_dointvec,
71807 + },
71808 +#endif
71809 +#ifdef CONFIG_GRKERNSEC_SETXID
71810 + {
71811 + .procname = "consistent_setxid",
71812 + .data = &grsec_enable_setxid,
71813 + .maxlen = sizeof(int),
71814 + .mode = 0600,
71815 + .proc_handler = &proc_dointvec,
71816 + },
71817 +#endif
71818 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71819 + {
71820 + .procname = "ip_blackhole",
71821 + .data = &grsec_enable_blackhole,
71822 + .maxlen = sizeof(int),
71823 + .mode = 0600,
71824 + .proc_handler = &proc_dointvec,
71825 + },
71826 + {
71827 + .procname = "lastack_retries",
71828 + .data = &grsec_lastack_retries,
71829 + .maxlen = sizeof(int),
71830 + .mode = 0600,
71831 + .proc_handler = &proc_dointvec,
71832 + },
71833 +#endif
71834 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71835 + {
71836 + .procname = "exec_logging",
71837 + .data = &grsec_enable_execlog,
71838 + .maxlen = sizeof(int),
71839 + .mode = 0600,
71840 + .proc_handler = &proc_dointvec,
71841 + },
71842 +#endif
71843 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71844 + {
71845 + .procname = "rwxmap_logging",
71846 + .data = &grsec_enable_log_rwxmaps,
71847 + .maxlen = sizeof(int),
71848 + .mode = 0600,
71849 + .proc_handler = &proc_dointvec,
71850 + },
71851 +#endif
71852 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71853 + {
71854 + .procname = "signal_logging",
71855 + .data = &grsec_enable_signal,
71856 + .maxlen = sizeof(int),
71857 + .mode = 0600,
71858 + .proc_handler = &proc_dointvec,
71859 + },
71860 +#endif
71861 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71862 + {
71863 + .procname = "forkfail_logging",
71864 + .data = &grsec_enable_forkfail,
71865 + .maxlen = sizeof(int),
71866 + .mode = 0600,
71867 + .proc_handler = &proc_dointvec,
71868 + },
71869 +#endif
71870 +#ifdef CONFIG_GRKERNSEC_TIME
71871 + {
71872 + .procname = "timechange_logging",
71873 + .data = &grsec_enable_time,
71874 + .maxlen = sizeof(int),
71875 + .mode = 0600,
71876 + .proc_handler = &proc_dointvec,
71877 + },
71878 +#endif
71879 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71880 + {
71881 + .procname = "chroot_deny_shmat",
71882 + .data = &grsec_enable_chroot_shmat,
71883 + .maxlen = sizeof(int),
71884 + .mode = 0600,
71885 + .proc_handler = &proc_dointvec,
71886 + },
71887 +#endif
71888 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71889 + {
71890 + .procname = "chroot_deny_unix",
71891 + .data = &grsec_enable_chroot_unix,
71892 + .maxlen = sizeof(int),
71893 + .mode = 0600,
71894 + .proc_handler = &proc_dointvec,
71895 + },
71896 +#endif
71897 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71898 + {
71899 + .procname = "chroot_deny_mount",
71900 + .data = &grsec_enable_chroot_mount,
71901 + .maxlen = sizeof(int),
71902 + .mode = 0600,
71903 + .proc_handler = &proc_dointvec,
71904 + },
71905 +#endif
71906 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71907 + {
71908 + .procname = "chroot_deny_fchdir",
71909 + .data = &grsec_enable_chroot_fchdir,
71910 + .maxlen = sizeof(int),
71911 + .mode = 0600,
71912 + .proc_handler = &proc_dointvec,
71913 + },
71914 +#endif
71915 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71916 + {
71917 + .procname = "chroot_deny_chroot",
71918 + .data = &grsec_enable_chroot_double,
71919 + .maxlen = sizeof(int),
71920 + .mode = 0600,
71921 + .proc_handler = &proc_dointvec,
71922 + },
71923 +#endif
71924 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71925 + {
71926 + .procname = "chroot_deny_pivot",
71927 + .data = &grsec_enable_chroot_pivot,
71928 + .maxlen = sizeof(int),
71929 + .mode = 0600,
71930 + .proc_handler = &proc_dointvec,
71931 + },
71932 +#endif
71933 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71934 + {
71935 + .procname = "chroot_enforce_chdir",
71936 + .data = &grsec_enable_chroot_chdir,
71937 + .maxlen = sizeof(int),
71938 + .mode = 0600,
71939 + .proc_handler = &proc_dointvec,
71940 + },
71941 +#endif
71942 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71943 + {
71944 + .procname = "chroot_deny_chmod",
71945 + .data = &grsec_enable_chroot_chmod,
71946 + .maxlen = sizeof(int),
71947 + .mode = 0600,
71948 + .proc_handler = &proc_dointvec,
71949 + },
71950 +#endif
71951 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71952 + {
71953 + .procname = "chroot_deny_mknod",
71954 + .data = &grsec_enable_chroot_mknod,
71955 + .maxlen = sizeof(int),
71956 + .mode = 0600,
71957 + .proc_handler = &proc_dointvec,
71958 + },
71959 +#endif
71960 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71961 + {
71962 + .procname = "chroot_restrict_nice",
71963 + .data = &grsec_enable_chroot_nice,
71964 + .maxlen = sizeof(int),
71965 + .mode = 0600,
71966 + .proc_handler = &proc_dointvec,
71967 + },
71968 +#endif
71969 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71970 + {
71971 + .procname = "chroot_execlog",
71972 + .data = &grsec_enable_chroot_execlog,
71973 + .maxlen = sizeof(int),
71974 + .mode = 0600,
71975 + .proc_handler = &proc_dointvec,
71976 + },
71977 +#endif
71978 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71979 + {
71980 + .procname = "chroot_caps",
71981 + .data = &grsec_enable_chroot_caps,
71982 + .maxlen = sizeof(int),
71983 + .mode = 0600,
71984 + .proc_handler = &proc_dointvec,
71985 + },
71986 +#endif
71987 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71988 + {
71989 + .procname = "chroot_deny_sysctl",
71990 + .data = &grsec_enable_chroot_sysctl,
71991 + .maxlen = sizeof(int),
71992 + .mode = 0600,
71993 + .proc_handler = &proc_dointvec,
71994 + },
71995 +#endif
71996 +#ifdef CONFIG_GRKERNSEC_TPE
71997 + {
71998 + .procname = "tpe",
71999 + .data = &grsec_enable_tpe,
72000 + .maxlen = sizeof(int),
72001 + .mode = 0600,
72002 + .proc_handler = &proc_dointvec,
72003 + },
72004 + {
72005 + .procname = "tpe_gid",
72006 + .data = &grsec_tpe_gid,
72007 + .maxlen = sizeof(int),
72008 + .mode = 0600,
72009 + .proc_handler = &proc_dointvec,
72010 + },
72011 +#endif
72012 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72013 + {
72014 + .procname = "tpe_invert",
72015 + .data = &grsec_enable_tpe_invert,
72016 + .maxlen = sizeof(int),
72017 + .mode = 0600,
72018 + .proc_handler = &proc_dointvec,
72019 + },
72020 +#endif
72021 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72022 + {
72023 + .procname = "tpe_restrict_all",
72024 + .data = &grsec_enable_tpe_all,
72025 + .maxlen = sizeof(int),
72026 + .mode = 0600,
72027 + .proc_handler = &proc_dointvec,
72028 + },
72029 +#endif
72030 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72031 + {
72032 + .procname = "socket_all",
72033 + .data = &grsec_enable_socket_all,
72034 + .maxlen = sizeof(int),
72035 + .mode = 0600,
72036 + .proc_handler = &proc_dointvec,
72037 + },
72038 + {
72039 + .procname = "socket_all_gid",
72040 + .data = &grsec_socket_all_gid,
72041 + .maxlen = sizeof(int),
72042 + .mode = 0600,
72043 + .proc_handler = &proc_dointvec,
72044 + },
72045 +#endif
72046 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72047 + {
72048 + .procname = "socket_client",
72049 + .data = &grsec_enable_socket_client,
72050 + .maxlen = sizeof(int),
72051 + .mode = 0600,
72052 + .proc_handler = &proc_dointvec,
72053 + },
72054 + {
72055 + .procname = "socket_client_gid",
72056 + .data = &grsec_socket_client_gid,
72057 + .maxlen = sizeof(int),
72058 + .mode = 0600,
72059 + .proc_handler = &proc_dointvec,
72060 + },
72061 +#endif
72062 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72063 + {
72064 + .procname = "socket_server",
72065 + .data = &grsec_enable_socket_server,
72066 + .maxlen = sizeof(int),
72067 + .mode = 0600,
72068 + .proc_handler = &proc_dointvec,
72069 + },
72070 + {
72071 + .procname = "socket_server_gid",
72072 + .data = &grsec_socket_server_gid,
72073 + .maxlen = sizeof(int),
72074 + .mode = 0600,
72075 + .proc_handler = &proc_dointvec,
72076 + },
72077 +#endif
72078 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
72079 + {
72080 + .procname = "audit_group",
72081 + .data = &grsec_enable_group,
72082 + .maxlen = sizeof(int),
72083 + .mode = 0600,
72084 + .proc_handler = &proc_dointvec,
72085 + },
72086 + {
72087 + .procname = "audit_gid",
72088 + .data = &grsec_audit_gid,
72089 + .maxlen = sizeof(int),
72090 + .mode = 0600,
72091 + .proc_handler = &proc_dointvec,
72092 + },
72093 +#endif
72094 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
72095 + {
72096 + .procname = "audit_chdir",
72097 + .data = &grsec_enable_chdir,
72098 + .maxlen = sizeof(int),
72099 + .mode = 0600,
72100 + .proc_handler = &proc_dointvec,
72101 + },
72102 +#endif
72103 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72104 + {
72105 + .procname = "audit_mount",
72106 + .data = &grsec_enable_mount,
72107 + .maxlen = sizeof(int),
72108 + .mode = 0600,
72109 + .proc_handler = &proc_dointvec,
72110 + },
72111 +#endif
72112 +#ifdef CONFIG_GRKERNSEC_DMESG
72113 + {
72114 + .procname = "dmesg",
72115 + .data = &grsec_enable_dmesg,
72116 + .maxlen = sizeof(int),
72117 + .mode = 0600,
72118 + .proc_handler = &proc_dointvec,
72119 + },
72120 +#endif
72121 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72122 + {
72123 + .procname = "chroot_findtask",
72124 + .data = &grsec_enable_chroot_findtask,
72125 + .maxlen = sizeof(int),
72126 + .mode = 0600,
72127 + .proc_handler = &proc_dointvec,
72128 + },
72129 +#endif
72130 +#ifdef CONFIG_GRKERNSEC_RESLOG
72131 + {
72132 + .procname = "resource_logging",
72133 + .data = &grsec_resource_logging,
72134 + .maxlen = sizeof(int),
72135 + .mode = 0600,
72136 + .proc_handler = &proc_dointvec,
72137 + },
72138 +#endif
72139 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72140 + {
72141 + .procname = "audit_ptrace",
72142 + .data = &grsec_enable_audit_ptrace,
72143 + .maxlen = sizeof(int),
72144 + .mode = 0600,
72145 + .proc_handler = &proc_dointvec,
72146 + },
72147 +#endif
72148 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
72149 + {
72150 + .procname = "harden_ptrace",
72151 + .data = &grsec_enable_harden_ptrace,
72152 + .maxlen = sizeof(int),
72153 + .mode = 0600,
72154 + .proc_handler = &proc_dointvec,
72155 + },
72156 +#endif
72157 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
72158 + {
72159 + .procname = "harden_ipc",
72160 + .data = &grsec_enable_harden_ipc,
72161 + .maxlen = sizeof(int),
72162 + .mode = 0600,
72163 + .proc_handler = &proc_dointvec,
72164 + },
72165 +#endif
72166 + {
72167 + .procname = "grsec_lock",
72168 + .data = &grsec_lock,
72169 + .maxlen = sizeof(int),
72170 + .mode = 0600,
72171 + .proc_handler = &proc_dointvec,
72172 + },
72173 +#endif
72174 +#ifdef CONFIG_GRKERNSEC_ROFS
72175 + {
72176 + .procname = "romount_protect",
72177 + .data = &grsec_enable_rofs,
72178 + .maxlen = sizeof(int),
72179 + .mode = 0600,
72180 + .proc_handler = &proc_dointvec_minmax,
72181 + .extra1 = &one,
72182 + .extra2 = &one,
72183 + },
72184 +#endif
72185 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
72186 + {
72187 + .procname = "deny_new_usb",
72188 + .data = &grsec_deny_new_usb,
72189 + .maxlen = sizeof(int),
72190 + .mode = 0600,
72191 + .proc_handler = &proc_dointvec,
72192 + },
72193 +#endif
72194 + { }
72195 +};
72196 +#endif
72197 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
72198 new file mode 100644
72199 index 0000000..0dc13c3
72200 --- /dev/null
72201 +++ b/grsecurity/grsec_time.c
72202 @@ -0,0 +1,16 @@
72203 +#include <linux/kernel.h>
72204 +#include <linux/sched.h>
72205 +#include <linux/grinternal.h>
72206 +#include <linux/module.h>
72207 +
72208 +void
72209 +gr_log_timechange(void)
72210 +{
72211 +#ifdef CONFIG_GRKERNSEC_TIME
72212 + if (grsec_enable_time)
72213 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
72214 +#endif
72215 + return;
72216 +}
72217 +
72218 +EXPORT_SYMBOL(gr_log_timechange);
72219 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
72220 new file mode 100644
72221 index 0000000..ee57dcf
72222 --- /dev/null
72223 +++ b/grsecurity/grsec_tpe.c
72224 @@ -0,0 +1,73 @@
72225 +#include <linux/kernel.h>
72226 +#include <linux/sched.h>
72227 +#include <linux/file.h>
72228 +#include <linux/fs.h>
72229 +#include <linux/grinternal.h>
72230 +
72231 +extern int gr_acl_tpe_check(void);
72232 +
72233 +int
72234 +gr_tpe_allow(const struct file *file)
72235 +{
72236 +#ifdef CONFIG_GRKERNSEC
72237 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
72238 + const struct cred *cred = current_cred();
72239 + char *msg = NULL;
72240 + char *msg2 = NULL;
72241 +
72242 + // never restrict root
72243 + if (gr_is_global_root(cred->uid))
72244 + return 1;
72245 +
72246 + if (grsec_enable_tpe) {
72247 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72248 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
72249 + msg = "not being in trusted group";
72250 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
72251 + msg = "being in untrusted group";
72252 +#else
72253 + if (in_group_p(grsec_tpe_gid))
72254 + msg = "being in untrusted group";
72255 +#endif
72256 + }
72257 + if (!msg && gr_acl_tpe_check())
72258 + msg = "being in untrusted role";
72259 +
72260 + // not in any affected group/role
72261 + if (!msg)
72262 + goto next_check;
72263 +
72264 + if (gr_is_global_nonroot(inode->i_uid))
72265 + msg2 = "file in non-root-owned directory";
72266 + else if (inode->i_mode & S_IWOTH)
72267 + msg2 = "file in world-writable directory";
72268 + else if (inode->i_mode & S_IWGRP)
72269 + msg2 = "file in group-writable directory";
72270 +
72271 + if (msg && msg2) {
72272 + char fullmsg[70] = {0};
72273 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
72274 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
72275 + return 0;
72276 + }
72277 + msg = NULL;
72278 +next_check:
72279 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72280 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
72281 + return 1;
72282 +
72283 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
72284 + msg = "directory not owned by user";
72285 + else if (inode->i_mode & S_IWOTH)
72286 + msg = "file in world-writable directory";
72287 + else if (inode->i_mode & S_IWGRP)
72288 + msg = "file in group-writable directory";
72289 +
72290 + if (msg) {
72291 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
72292 + return 0;
72293 + }
72294 +#endif
72295 +#endif
72296 + return 1;
72297 +}
72298 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
72299 new file mode 100644
72300 index 0000000..ae02d8e
72301 --- /dev/null
72302 +++ b/grsecurity/grsec_usb.c
72303 @@ -0,0 +1,15 @@
72304 +#include <linux/kernel.h>
72305 +#include <linux/grinternal.h>
72306 +#include <linux/module.h>
72307 +
72308 +int gr_handle_new_usb(void)
72309 +{
72310 +#ifdef CONFIG_GRKERNSEC_DENYUSB
72311 + if (grsec_deny_new_usb) {
72312 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
72313 + return 1;
72314 + }
72315 +#endif
72316 + return 0;
72317 +}
72318 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
72319 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
72320 new file mode 100644
72321 index 0000000..9f7b1ac
72322 --- /dev/null
72323 +++ b/grsecurity/grsum.c
72324 @@ -0,0 +1,61 @@
72325 +#include <linux/err.h>
72326 +#include <linux/kernel.h>
72327 +#include <linux/sched.h>
72328 +#include <linux/mm.h>
72329 +#include <linux/scatterlist.h>
72330 +#include <linux/crypto.h>
72331 +#include <linux/gracl.h>
72332 +
72333 +
72334 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
72335 +#error "crypto and sha256 must be built into the kernel"
72336 +#endif
72337 +
72338 +int
72339 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
72340 +{
72341 + char *p;
72342 + struct crypto_hash *tfm;
72343 + struct hash_desc desc;
72344 + struct scatterlist sg;
72345 + unsigned char temp_sum[GR_SHA_LEN];
72346 + volatile int retval = 0;
72347 + volatile int dummy = 0;
72348 + unsigned int i;
72349 +
72350 + sg_init_table(&sg, 1);
72351 +
72352 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
72353 + if (IS_ERR(tfm)) {
72354 + /* should never happen, since sha256 should be built in */
72355 + return 1;
72356 + }
72357 +
72358 + desc.tfm = tfm;
72359 + desc.flags = 0;
72360 +
72361 + crypto_hash_init(&desc);
72362 +
72363 + p = salt;
72364 + sg_set_buf(&sg, p, GR_SALT_LEN);
72365 + crypto_hash_update(&desc, &sg, sg.length);
72366 +
72367 + p = entry->pw;
72368 + sg_set_buf(&sg, p, strlen(p));
72369 +
72370 + crypto_hash_update(&desc, &sg, sg.length);
72371 +
72372 + crypto_hash_final(&desc, temp_sum);
72373 +
72374 + memset(entry->pw, 0, GR_PW_LEN);
72375 +
72376 + for (i = 0; i < GR_SHA_LEN; i++)
72377 + if (sum[i] != temp_sum[i])
72378 + retval = 1;
72379 + else
72380 + dummy = 1; // waste a cycle
72381 +
72382 + crypto_free_hash(tfm);
72383 +
72384 + return retval;
72385 +}
72386 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
72387 index 77ff547..181834f 100644
72388 --- a/include/asm-generic/4level-fixup.h
72389 +++ b/include/asm-generic/4level-fixup.h
72390 @@ -13,8 +13,10 @@
72391 #define pmd_alloc(mm, pud, address) \
72392 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
72393 NULL: pmd_offset(pud, address))
72394 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
72395
72396 #define pud_alloc(mm, pgd, address) (pgd)
72397 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
72398 #define pud_offset(pgd, start) (pgd)
72399 #define pud_none(pud) 0
72400 #define pud_bad(pud) 0
72401 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
72402 index b7babf0..04ad282 100644
72403 --- a/include/asm-generic/atomic-long.h
72404 +++ b/include/asm-generic/atomic-long.h
72405 @@ -22,6 +22,12 @@
72406
72407 typedef atomic64_t atomic_long_t;
72408
72409 +#ifdef CONFIG_PAX_REFCOUNT
72410 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
72411 +#else
72412 +typedef atomic64_t atomic_long_unchecked_t;
72413 +#endif
72414 +
72415 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
72416
72417 static inline long atomic_long_read(atomic_long_t *l)
72418 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72419 return (long)atomic64_read(v);
72420 }
72421
72422 +#ifdef CONFIG_PAX_REFCOUNT
72423 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72424 +{
72425 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72426 +
72427 + return (long)atomic64_read_unchecked(v);
72428 +}
72429 +#endif
72430 +
72431 static inline void atomic_long_set(atomic_long_t *l, long i)
72432 {
72433 atomic64_t *v = (atomic64_t *)l;
72434 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72435 atomic64_set(v, i);
72436 }
72437
72438 +#ifdef CONFIG_PAX_REFCOUNT
72439 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72440 +{
72441 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72442 +
72443 + atomic64_set_unchecked(v, i);
72444 +}
72445 +#endif
72446 +
72447 static inline void atomic_long_inc(atomic_long_t *l)
72448 {
72449 atomic64_t *v = (atomic64_t *)l;
72450 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72451 atomic64_inc(v);
72452 }
72453
72454 +#ifdef CONFIG_PAX_REFCOUNT
72455 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72456 +{
72457 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72458 +
72459 + atomic64_inc_unchecked(v);
72460 +}
72461 +#endif
72462 +
72463 static inline void atomic_long_dec(atomic_long_t *l)
72464 {
72465 atomic64_t *v = (atomic64_t *)l;
72466 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72467 atomic64_dec(v);
72468 }
72469
72470 +#ifdef CONFIG_PAX_REFCOUNT
72471 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72472 +{
72473 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72474 +
72475 + atomic64_dec_unchecked(v);
72476 +}
72477 +#endif
72478 +
72479 static inline void atomic_long_add(long i, atomic_long_t *l)
72480 {
72481 atomic64_t *v = (atomic64_t *)l;
72482 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72483 atomic64_add(i, v);
72484 }
72485
72486 +#ifdef CONFIG_PAX_REFCOUNT
72487 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72488 +{
72489 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72490 +
72491 + atomic64_add_unchecked(i, v);
72492 +}
72493 +#endif
72494 +
72495 static inline void atomic_long_sub(long i, atomic_long_t *l)
72496 {
72497 atomic64_t *v = (atomic64_t *)l;
72498 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72499 atomic64_sub(i, v);
72500 }
72501
72502 +#ifdef CONFIG_PAX_REFCOUNT
72503 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72504 +{
72505 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72506 +
72507 + atomic64_sub_unchecked(i, v);
72508 +}
72509 +#endif
72510 +
72511 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72512 {
72513 atomic64_t *v = (atomic64_t *)l;
72514 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72515 return (long)atomic64_add_return(i, v);
72516 }
72517
72518 +#ifdef CONFIG_PAX_REFCOUNT
72519 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72520 +{
72521 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72522 +
72523 + return (long)atomic64_add_return_unchecked(i, v);
72524 +}
72525 +#endif
72526 +
72527 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72528 {
72529 atomic64_t *v = (atomic64_t *)l;
72530 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72531 return (long)atomic64_inc_return(v);
72532 }
72533
72534 +#ifdef CONFIG_PAX_REFCOUNT
72535 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72536 +{
72537 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72538 +
72539 + return (long)atomic64_inc_return_unchecked(v);
72540 +}
72541 +#endif
72542 +
72543 static inline long atomic_long_dec_return(atomic_long_t *l)
72544 {
72545 atomic64_t *v = (atomic64_t *)l;
72546 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72547
72548 typedef atomic_t atomic_long_t;
72549
72550 +#ifdef CONFIG_PAX_REFCOUNT
72551 +typedef atomic_unchecked_t atomic_long_unchecked_t;
72552 +#else
72553 +typedef atomic_t atomic_long_unchecked_t;
72554 +#endif
72555 +
72556 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
72557 static inline long atomic_long_read(atomic_long_t *l)
72558 {
72559 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72560 return (long)atomic_read(v);
72561 }
72562
72563 +#ifdef CONFIG_PAX_REFCOUNT
72564 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72565 +{
72566 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72567 +
72568 + return (long)atomic_read_unchecked(v);
72569 +}
72570 +#endif
72571 +
72572 static inline void atomic_long_set(atomic_long_t *l, long i)
72573 {
72574 atomic_t *v = (atomic_t *)l;
72575 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72576 atomic_set(v, i);
72577 }
72578
72579 +#ifdef CONFIG_PAX_REFCOUNT
72580 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72581 +{
72582 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72583 +
72584 + atomic_set_unchecked(v, i);
72585 +}
72586 +#endif
72587 +
72588 static inline void atomic_long_inc(atomic_long_t *l)
72589 {
72590 atomic_t *v = (atomic_t *)l;
72591 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72592 atomic_inc(v);
72593 }
72594
72595 +#ifdef CONFIG_PAX_REFCOUNT
72596 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72597 +{
72598 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72599 +
72600 + atomic_inc_unchecked(v);
72601 +}
72602 +#endif
72603 +
72604 static inline void atomic_long_dec(atomic_long_t *l)
72605 {
72606 atomic_t *v = (atomic_t *)l;
72607 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72608 atomic_dec(v);
72609 }
72610
72611 +#ifdef CONFIG_PAX_REFCOUNT
72612 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72613 +{
72614 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72615 +
72616 + atomic_dec_unchecked(v);
72617 +}
72618 +#endif
72619 +
72620 static inline void atomic_long_add(long i, atomic_long_t *l)
72621 {
72622 atomic_t *v = (atomic_t *)l;
72623 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72624 atomic_add(i, v);
72625 }
72626
72627 +#ifdef CONFIG_PAX_REFCOUNT
72628 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72629 +{
72630 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72631 +
72632 + atomic_add_unchecked(i, v);
72633 +}
72634 +#endif
72635 +
72636 static inline void atomic_long_sub(long i, atomic_long_t *l)
72637 {
72638 atomic_t *v = (atomic_t *)l;
72639 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72640 atomic_sub(i, v);
72641 }
72642
72643 +#ifdef CONFIG_PAX_REFCOUNT
72644 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72645 +{
72646 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72647 +
72648 + atomic_sub_unchecked(i, v);
72649 +}
72650 +#endif
72651 +
72652 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72653 {
72654 atomic_t *v = (atomic_t *)l;
72655 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72656 return (long)atomic_add_return(i, v);
72657 }
72658
72659 +#ifdef CONFIG_PAX_REFCOUNT
72660 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72661 +{
72662 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72663 +
72664 + return (long)atomic_add_return_unchecked(i, v);
72665 +}
72666 +
72667 +#endif
72668 +
72669 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72670 {
72671 atomic_t *v = (atomic_t *)l;
72672 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72673 return (long)atomic_inc_return(v);
72674 }
72675
72676 +#ifdef CONFIG_PAX_REFCOUNT
72677 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72678 +{
72679 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72680 +
72681 + return (long)atomic_inc_return_unchecked(v);
72682 +}
72683 +#endif
72684 +
72685 static inline long atomic_long_dec_return(atomic_long_t *l)
72686 {
72687 atomic_t *v = (atomic_t *)l;
72688 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72689
72690 #endif /* BITS_PER_LONG == 64 */
72691
72692 +#ifdef CONFIG_PAX_REFCOUNT
72693 +static inline void pax_refcount_needs_these_functions(void)
72694 +{
72695 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
72696 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
72697 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
72698 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
72699 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
72700 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
72701 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
72702 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
72703 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
72704 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
72705 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
72706 +#ifdef CONFIG_X86
72707 + atomic_clear_mask_unchecked(0, NULL);
72708 + atomic_set_mask_unchecked(0, NULL);
72709 +#endif
72710 +
72711 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
72712 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
72713 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
72714 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
72715 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
72716 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
72717 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
72718 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
72719 +}
72720 +#else
72721 +#define atomic_read_unchecked(v) atomic_read(v)
72722 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
72723 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
72724 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
72725 +#define atomic_inc_unchecked(v) atomic_inc(v)
72726 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
72727 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
72728 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
72729 +#define atomic_dec_unchecked(v) atomic_dec(v)
72730 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
72731 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
72732 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
72733 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
72734 +
72735 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
72736 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
72737 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
72738 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
72739 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
72740 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
72741 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
72742 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
72743 +#endif
72744 +
72745 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
72746 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
72747 index 33bd2de..f31bff97 100644
72748 --- a/include/asm-generic/atomic.h
72749 +++ b/include/asm-generic/atomic.h
72750 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
72751 * Atomically clears the bits set in @mask from @v
72752 */
72753 #ifndef atomic_clear_mask
72754 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
72755 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
72756 {
72757 unsigned long flags;
72758
72759 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
72760 index b18ce4f..2ee2843 100644
72761 --- a/include/asm-generic/atomic64.h
72762 +++ b/include/asm-generic/atomic64.h
72763 @@ -16,6 +16,8 @@ typedef struct {
72764 long long counter;
72765 } atomic64_t;
72766
72767 +typedef atomic64_t atomic64_unchecked_t;
72768 +
72769 #define ATOMIC64_INIT(i) { (i) }
72770
72771 extern long long atomic64_read(const atomic64_t *v);
72772 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
72773 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
72774 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
72775
72776 +#define atomic64_read_unchecked(v) atomic64_read(v)
72777 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
72778 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
72779 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
72780 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
72781 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
72782 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
72783 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
72784 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
72785 +
72786 #endif /* _ASM_GENERIC_ATOMIC64_H */
72787 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
72788 index 1bfcfe5..e04c5c9 100644
72789 --- a/include/asm-generic/cache.h
72790 +++ b/include/asm-generic/cache.h
72791 @@ -6,7 +6,7 @@
72792 * cache lines need to provide their own cache.h.
72793 */
72794
72795 -#define L1_CACHE_SHIFT 5
72796 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
72797 +#define L1_CACHE_SHIFT 5UL
72798 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
72799
72800 #endif /* __ASM_GENERIC_CACHE_H */
72801 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
72802 index 0d68a1e..b74a761 100644
72803 --- a/include/asm-generic/emergency-restart.h
72804 +++ b/include/asm-generic/emergency-restart.h
72805 @@ -1,7 +1,7 @@
72806 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
72807 #define _ASM_GENERIC_EMERGENCY_RESTART_H
72808
72809 -static inline void machine_emergency_restart(void)
72810 +static inline __noreturn void machine_emergency_restart(void)
72811 {
72812 machine_restart(NULL);
72813 }
72814 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72815 index 90f99c7..00ce236 100644
72816 --- a/include/asm-generic/kmap_types.h
72817 +++ b/include/asm-generic/kmap_types.h
72818 @@ -2,9 +2,9 @@
72819 #define _ASM_GENERIC_KMAP_TYPES_H
72820
72821 #ifdef __WITH_KM_FENCE
72822 -# define KM_TYPE_NR 41
72823 +# define KM_TYPE_NR 42
72824 #else
72825 -# define KM_TYPE_NR 20
72826 +# define KM_TYPE_NR 21
72827 #endif
72828
72829 #endif
72830 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72831 index 9ceb03b..62b0b8f 100644
72832 --- a/include/asm-generic/local.h
72833 +++ b/include/asm-generic/local.h
72834 @@ -23,24 +23,37 @@ typedef struct
72835 atomic_long_t a;
72836 } local_t;
72837
72838 +typedef struct {
72839 + atomic_long_unchecked_t a;
72840 +} local_unchecked_t;
72841 +
72842 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
72843
72844 #define local_read(l) atomic_long_read(&(l)->a)
72845 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
72846 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72847 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72848 #define local_inc(l) atomic_long_inc(&(l)->a)
72849 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72850 #define local_dec(l) atomic_long_dec(&(l)->a)
72851 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72852 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72853 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72854 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72855 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72856
72857 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72858 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72859 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72860 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72861 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72862 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72863 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72864 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72865 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72866
72867 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72868 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72869 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72870 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72871 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72872 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72873 index 725612b..9cc513a 100644
72874 --- a/include/asm-generic/pgtable-nopmd.h
72875 +++ b/include/asm-generic/pgtable-nopmd.h
72876 @@ -1,14 +1,19 @@
72877 #ifndef _PGTABLE_NOPMD_H
72878 #define _PGTABLE_NOPMD_H
72879
72880 -#ifndef __ASSEMBLY__
72881 -
72882 #include <asm-generic/pgtable-nopud.h>
72883
72884 -struct mm_struct;
72885 -
72886 #define __PAGETABLE_PMD_FOLDED
72887
72888 +#define PMD_SHIFT PUD_SHIFT
72889 +#define PTRS_PER_PMD 1
72890 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72891 +#define PMD_MASK (~(PMD_SIZE-1))
72892 +
72893 +#ifndef __ASSEMBLY__
72894 +
72895 +struct mm_struct;
72896 +
72897 /*
72898 * Having the pmd type consist of a pud gets the size right, and allows
72899 * us to conceptually access the pud entry that this pmd is folded into
72900 @@ -16,11 +21,6 @@ struct mm_struct;
72901 */
72902 typedef struct { pud_t pud; } pmd_t;
72903
72904 -#define PMD_SHIFT PUD_SHIFT
72905 -#define PTRS_PER_PMD 1
72906 -#define PMD_SIZE (1UL << PMD_SHIFT)
72907 -#define PMD_MASK (~(PMD_SIZE-1))
72908 -
72909 /*
72910 * The "pud_xxx()" functions here are trivial for a folded two-level
72911 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72912 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72913 index 810431d..0ec4804f 100644
72914 --- a/include/asm-generic/pgtable-nopud.h
72915 +++ b/include/asm-generic/pgtable-nopud.h
72916 @@ -1,10 +1,15 @@
72917 #ifndef _PGTABLE_NOPUD_H
72918 #define _PGTABLE_NOPUD_H
72919
72920 -#ifndef __ASSEMBLY__
72921 -
72922 #define __PAGETABLE_PUD_FOLDED
72923
72924 +#define PUD_SHIFT PGDIR_SHIFT
72925 +#define PTRS_PER_PUD 1
72926 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72927 +#define PUD_MASK (~(PUD_SIZE-1))
72928 +
72929 +#ifndef __ASSEMBLY__
72930 +
72931 /*
72932 * Having the pud type consist of a pgd gets the size right, and allows
72933 * us to conceptually access the pgd entry that this pud is folded into
72934 @@ -12,11 +17,6 @@
72935 */
72936 typedef struct { pgd_t pgd; } pud_t;
72937
72938 -#define PUD_SHIFT PGDIR_SHIFT
72939 -#define PTRS_PER_PUD 1
72940 -#define PUD_SIZE (1UL << PUD_SHIFT)
72941 -#define PUD_MASK (~(PUD_SIZE-1))
72942 -
72943 /*
72944 * The "pgd_xxx()" functions here are trivial for a folded two-level
72945 * setup: the pud is never bad, and a pud always exists (as it's folded
72946 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72947 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72948
72949 #define pgd_populate(mm, pgd, pud) do { } while (0)
72950 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72951 /*
72952 * (puds are folded into pgds so this doesn't get actually called,
72953 * but the define is needed for a generic inline function.)
72954 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72955 index f330d28..83ce28f 100644
72956 --- a/include/asm-generic/pgtable.h
72957 +++ b/include/asm-generic/pgtable.h
72958 @@ -737,6 +737,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72959 }
72960 #endif /* CONFIG_NUMA_BALANCING */
72961
72962 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72963 +#ifdef CONFIG_PAX_KERNEXEC
72964 +#error KERNEXEC requires pax_open_kernel
72965 +#else
72966 +static inline unsigned long pax_open_kernel(void) { return 0; }
72967 +#endif
72968 +#endif
72969 +
72970 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72971 +#ifdef CONFIG_PAX_KERNEXEC
72972 +#error KERNEXEC requires pax_close_kernel
72973 +#else
72974 +static inline unsigned long pax_close_kernel(void) { return 0; }
72975 +#endif
72976 +#endif
72977 +
72978 #endif /* CONFIG_MMU */
72979
72980 #endif /* !__ASSEMBLY__ */
72981 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72982 index dc1269c..48a4f51 100644
72983 --- a/include/asm-generic/uaccess.h
72984 +++ b/include/asm-generic/uaccess.h
72985 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72986 return __clear_user(to, n);
72987 }
72988
72989 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72990 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72991 +#error UDEREF requires pax_open_userland
72992 +#else
72993 +static inline unsigned long pax_open_userland(void) { return 0; }
72994 +#endif
72995 +#endif
72996 +
72997 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72998 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72999 +#error UDEREF requires pax_close_userland
73000 +#else
73001 +static inline unsigned long pax_close_userland(void) { return 0; }
73002 +#endif
73003 +#endif
73004 +
73005 #endif /* __ASM_GENERIC_UACCESS_H */
73006 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
73007 index 83e2c31..eeb4a04 100644
73008 --- a/include/asm-generic/vmlinux.lds.h
73009 +++ b/include/asm-generic/vmlinux.lds.h
73010 @@ -232,6 +232,7 @@
73011 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
73012 VMLINUX_SYMBOL(__start_rodata) = .; \
73013 *(.rodata) *(.rodata.*) \
73014 + *(.data..read_only) \
73015 *(__vermagic) /* Kernel version magic */ \
73016 . = ALIGN(8); \
73017 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
73018 @@ -715,17 +716,18 @@
73019 * section in the linker script will go there too. @phdr should have
73020 * a leading colon.
73021 *
73022 - * Note that this macros defines __per_cpu_load as an absolute symbol.
73023 + * Note that this macros defines per_cpu_load as an absolute symbol.
73024 * If there is no need to put the percpu section at a predetermined
73025 * address, use PERCPU_SECTION.
73026 */
73027 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
73028 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
73029 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
73030 + per_cpu_load = .; \
73031 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
73032 - LOAD_OFFSET) { \
73033 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
73034 PERCPU_INPUT(cacheline) \
73035 } phdr \
73036 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
73037 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
73038
73039 /**
73040 * PERCPU_SECTION - define output section for percpu area, simple version
73041 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
73042 index 418d270..bfd2794 100644
73043 --- a/include/crypto/algapi.h
73044 +++ b/include/crypto/algapi.h
73045 @@ -34,7 +34,7 @@ struct crypto_type {
73046 unsigned int maskclear;
73047 unsigned int maskset;
73048 unsigned int tfmsize;
73049 -};
73050 +} __do_const;
73051
73052 struct crypto_instance {
73053 struct crypto_alg alg;
73054 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
73055 index b46fb45..b30d6d5 100644
73056 --- a/include/drm/drmP.h
73057 +++ b/include/drm/drmP.h
73058 @@ -66,6 +66,7 @@
73059 #include <linux/workqueue.h>
73060 #include <linux/poll.h>
73061 #include <asm/pgalloc.h>
73062 +#include <asm/local.h>
73063 #include <drm/drm.h>
73064 #include <drm/drm_sarea.h>
73065 #include <drm/drm_vma_manager.h>
73066 @@ -277,10 +278,12 @@ do { \
73067 * \param cmd command.
73068 * \param arg argument.
73069 */
73070 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
73071 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
73072 + struct drm_file *file_priv);
73073 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
73074 struct drm_file *file_priv);
73075
73076 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73077 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
73078 unsigned long arg);
73079
73080 #define DRM_IOCTL_NR(n) _IOC_NR(n)
73081 @@ -296,10 +299,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73082 struct drm_ioctl_desc {
73083 unsigned int cmd;
73084 int flags;
73085 - drm_ioctl_t *func;
73086 + drm_ioctl_t func;
73087 unsigned int cmd_drv;
73088 const char *name;
73089 -};
73090 +} __do_const;
73091
73092 /**
73093 * Creates a driver or general drm_ioctl_desc array entry for the given
73094 @@ -1027,7 +1030,7 @@ struct drm_info_list {
73095 int (*show)(struct seq_file*, void*); /** show callback */
73096 u32 driver_features; /**< Required driver features for this entry */
73097 void *data;
73098 -};
73099 +} __do_const;
73100
73101 /**
73102 * debugfs node structure. This structure represents a debugfs file.
73103 @@ -1098,7 +1101,7 @@ struct drm_device {
73104
73105 /** \name Usage Counters */
73106 /*@{ */
73107 - int open_count; /**< Outstanding files open */
73108 + local_t open_count; /**< Outstanding files open */
73109 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
73110 atomic_t vma_count; /**< Outstanding vma areas open */
73111 int buf_use; /**< Buffers in use -- cannot alloc */
73112 @@ -1109,7 +1112,7 @@ struct drm_device {
73113 /*@{ */
73114 unsigned long counters;
73115 enum drm_stat_type types[15];
73116 - atomic_t counts[15];
73117 + atomic_unchecked_t counts[15];
73118 /*@} */
73119
73120 struct list_head filelist;
73121 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
73122 index f43d556..94d9343 100644
73123 --- a/include/drm/drm_crtc_helper.h
73124 +++ b/include/drm/drm_crtc_helper.h
73125 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
73126 struct drm_connector *connector);
73127 /* disable encoder when not in use - more explicit than dpms off */
73128 void (*disable)(struct drm_encoder *encoder);
73129 -};
73130 +} __no_const;
73131
73132 /**
73133 * drm_connector_helper_funcs - helper operations for connectors
73134 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
73135 index 8a10f5c..5de7f5c 100644
73136 --- a/include/drm/i915_pciids.h
73137 +++ b/include/drm/i915_pciids.h
73138 @@ -37,7 +37,7 @@
73139 */
73140 #define INTEL_VGA_DEVICE(id, info) { \
73141 0x8086, id, \
73142 - ~0, ~0, \
73143 + PCI_ANY_ID, PCI_ANY_ID, \
73144 0x030000, 0xff0000, \
73145 (unsigned long) info }
73146
73147 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
73148 index 72dcbe8..8db58d7 100644
73149 --- a/include/drm/ttm/ttm_memory.h
73150 +++ b/include/drm/ttm/ttm_memory.h
73151 @@ -48,7 +48,7 @@
73152
73153 struct ttm_mem_shrink {
73154 int (*do_shrink) (struct ttm_mem_shrink *);
73155 -};
73156 +} __no_const;
73157
73158 /**
73159 * struct ttm_mem_global - Global memory accounting structure.
73160 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
73161 index 4b840e8..155d235 100644
73162 --- a/include/keys/asymmetric-subtype.h
73163 +++ b/include/keys/asymmetric-subtype.h
73164 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
73165 /* Verify the signature on a key of this subtype (optional) */
73166 int (*verify_signature)(const struct key *key,
73167 const struct public_key_signature *sig);
73168 -};
73169 +} __do_const;
73170
73171 /**
73172 * asymmetric_key_subtype - Get the subtype from an asymmetric key
73173 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
73174 index c1da539..1dcec55 100644
73175 --- a/include/linux/atmdev.h
73176 +++ b/include/linux/atmdev.h
73177 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
73178 #endif
73179
73180 struct k_atm_aal_stats {
73181 -#define __HANDLE_ITEM(i) atomic_t i
73182 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73183 __AAL_STAT_ITEMS
73184 #undef __HANDLE_ITEM
73185 };
73186 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
73187 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
73188 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
73189 struct module *owner;
73190 -};
73191 +} __do_const ;
73192
73193 struct atmphy_ops {
73194 int (*start)(struct atm_dev *dev);
73195 diff --git a/include/linux/audit.h b/include/linux/audit.h
73196 index 729a4d1..9b304ae 100644
73197 --- a/include/linux/audit.h
73198 +++ b/include/linux/audit.h
73199 @@ -193,7 +193,7 @@ static inline void audit_ptrace(struct task_struct *t)
73200 extern unsigned int audit_serial(void);
73201 extern int auditsc_get_stamp(struct audit_context *ctx,
73202 struct timespec *t, unsigned int *serial);
73203 -extern int audit_set_loginuid(kuid_t loginuid);
73204 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
73205
73206 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
73207 {
73208 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
73209 index e8112ae..05b8e7f 100644
73210 --- a/include/linux/binfmts.h
73211 +++ b/include/linux/binfmts.h
73212 @@ -73,8 +73,10 @@ struct linux_binfmt {
73213 int (*load_binary)(struct linux_binprm *);
73214 int (*load_shlib)(struct file *);
73215 int (*core_dump)(struct coredump_params *cprm);
73216 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
73217 + void (*handle_mmap)(struct file *);
73218 unsigned long min_coredump; /* minimal dump size */
73219 -};
73220 +} __do_const;
73221
73222 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
73223
73224 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
73225 index a3b6b82..cd8f69c 100644
73226 --- a/include/linux/bitops.h
73227 +++ b/include/linux/bitops.h
73228 @@ -91,7 +91,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
73229 * @word: value to rotate
73230 * @shift: bits to roll
73231 */
73232 -static inline __u32 rol32(__u32 word, unsigned int shift)
73233 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
73234 {
73235 return (word << shift) | (word >> (32 - shift));
73236 }
73237 @@ -101,7 +101,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
73238 * @word: value to rotate
73239 * @shift: bits to roll
73240 */
73241 -static inline __u32 ror32(__u32 word, unsigned int shift)
73242 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
73243 {
73244 return (word >> shift) | (word << (32 - shift));
73245 }
73246 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
73247 index 0e6f765..885bb2b 100644
73248 --- a/include/linux/blkdev.h
73249 +++ b/include/linux/blkdev.h
73250 @@ -1537,7 +1537,7 @@ struct block_device_operations {
73251 /* this callback is with swap_lock and sometimes page table lock held */
73252 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
73253 struct module *owner;
73254 -};
73255 +} __do_const;
73256
73257 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
73258 unsigned long);
73259 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
73260 index 7c2e030..b72475d 100644
73261 --- a/include/linux/blktrace_api.h
73262 +++ b/include/linux/blktrace_api.h
73263 @@ -23,7 +23,7 @@ struct blk_trace {
73264 struct dentry *dir;
73265 struct dentry *dropped_file;
73266 struct dentry *msg_file;
73267 - atomic_t dropped;
73268 + atomic_unchecked_t dropped;
73269 };
73270
73271 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
73272 diff --git a/include/linux/cache.h b/include/linux/cache.h
73273 index 4c57065..40346da 100644
73274 --- a/include/linux/cache.h
73275 +++ b/include/linux/cache.h
73276 @@ -16,6 +16,14 @@
73277 #define __read_mostly
73278 #endif
73279
73280 +#ifndef __read_only
73281 +#ifdef CONFIG_PAX_KERNEXEC
73282 +#error KERNEXEC requires __read_only
73283 +#else
73284 +#define __read_only __read_mostly
73285 +#endif
73286 +#endif
73287 +
73288 #ifndef ____cacheline_aligned
73289 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
73290 #endif
73291 diff --git a/include/linux/capability.h b/include/linux/capability.h
73292 index a6ee1f9..e1ca49d 100644
73293 --- a/include/linux/capability.h
73294 +++ b/include/linux/capability.h
73295 @@ -212,8 +212,13 @@ extern bool capable(int cap);
73296 extern bool ns_capable(struct user_namespace *ns, int cap);
73297 extern bool inode_capable(const struct inode *inode, int cap);
73298 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
73299 +extern bool capable_nolog(int cap);
73300 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
73301 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
73302
73303 /* audit system wants to get cap info from files as well */
73304 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
73305
73306 +extern int is_privileged_binary(const struct dentry *dentry);
73307 +
73308 #endif /* !_LINUX_CAPABILITY_H */
73309 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
73310 index 8609d57..86e4d79 100644
73311 --- a/include/linux/cdrom.h
73312 +++ b/include/linux/cdrom.h
73313 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
73314
73315 /* driver specifications */
73316 const int capability; /* capability flags */
73317 - int n_minors; /* number of active minor devices */
73318 /* handle uniform packets for scsi type devices (scsi,atapi) */
73319 int (*generic_packet) (struct cdrom_device_info *,
73320 struct packet_command *);
73321 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
73322 index 4ce9056..86caac6 100644
73323 --- a/include/linux/cleancache.h
73324 +++ b/include/linux/cleancache.h
73325 @@ -31,7 +31,7 @@ struct cleancache_ops {
73326 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
73327 void (*invalidate_inode)(int, struct cleancache_filekey);
73328 void (*invalidate_fs)(int);
73329 -};
73330 +} __no_const;
73331
73332 extern struct cleancache_ops *
73333 cleancache_register_ops(struct cleancache_ops *ops);
73334 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
73335 index 73bdb69..d66d47a 100644
73336 --- a/include/linux/clk-provider.h
73337 +++ b/include/linux/clk-provider.h
73338 @@ -141,6 +141,7 @@ struct clk_ops {
73339 unsigned long);
73340 void (*init)(struct clk_hw *hw);
73341 };
73342 +typedef struct clk_ops __no_const clk_ops_no_const;
73343
73344 /**
73345 * struct clk_init_data - holds init data that's common to all clocks and is
73346 diff --git a/include/linux/compat.h b/include/linux/compat.h
73347 index 345da00..b6eff26 100644
73348 --- a/include/linux/compat.h
73349 +++ b/include/linux/compat.h
73350 @@ -313,7 +313,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
73351 compat_size_t __user *len_ptr);
73352
73353 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
73354 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
73355 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
73356 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
73357 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
73358 compat_ssize_t msgsz, int msgflg);
73359 @@ -420,7 +420,7 @@ extern int compat_ptrace_request(struct task_struct *child,
73360 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
73361 compat_ulong_t addr, compat_ulong_t data);
73362 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
73363 - compat_long_t addr, compat_long_t data);
73364 + compat_ulong_t addr, compat_ulong_t data);
73365
73366 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
73367 /*
73368 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
73369 index ded4299..da50e3b 100644
73370 --- a/include/linux/compiler-gcc4.h
73371 +++ b/include/linux/compiler-gcc4.h
73372 @@ -39,9 +39,29 @@
73373 # define __compiletime_warning(message) __attribute__((warning(message)))
73374 # define __compiletime_error(message) __attribute__((error(message)))
73375 #endif /* __CHECKER__ */
73376 +
73377 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
73378 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
73379 +#define __bos0(ptr) __bos((ptr), 0)
73380 +#define __bos1(ptr) __bos((ptr), 1)
73381 #endif /* GCC_VERSION >= 40300 */
73382
73383 #if GCC_VERSION >= 40500
73384 +
73385 +#ifdef CONSTIFY_PLUGIN
73386 +#define __no_const __attribute__((no_const))
73387 +#define __do_const __attribute__((do_const))
73388 +#endif
73389 +
73390 +#ifdef SIZE_OVERFLOW_PLUGIN
73391 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
73392 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
73393 +#endif
73394 +
73395 +#ifdef LATENT_ENTROPY_PLUGIN
73396 +#define __latent_entropy __attribute__((latent_entropy))
73397 +#endif
73398 +
73399 /*
73400 * Mark a position in code as unreachable. This can be used to
73401 * suppress control flow warnings after asm blocks that transfer
73402 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
73403 index 92669cd..1771a15 100644
73404 --- a/include/linux/compiler.h
73405 +++ b/include/linux/compiler.h
73406 @@ -5,11 +5,14 @@
73407
73408 #ifdef __CHECKER__
73409 # define __user __attribute__((noderef, address_space(1)))
73410 +# define __force_user __force __user
73411 # define __kernel __attribute__((address_space(0)))
73412 +# define __force_kernel __force __kernel
73413 # define __safe __attribute__((safe))
73414 # define __force __attribute__((force))
73415 # define __nocast __attribute__((nocast))
73416 # define __iomem __attribute__((noderef, address_space(2)))
73417 +# define __force_iomem __force __iomem
73418 # define __must_hold(x) __attribute__((context(x,1,1)))
73419 # define __acquires(x) __attribute__((context(x,0,1)))
73420 # define __releases(x) __attribute__((context(x,1,0)))
73421 @@ -17,20 +20,37 @@
73422 # define __release(x) __context__(x,-1)
73423 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
73424 # define __percpu __attribute__((noderef, address_space(3)))
73425 +# define __force_percpu __force __percpu
73426 #ifdef CONFIG_SPARSE_RCU_POINTER
73427 # define __rcu __attribute__((noderef, address_space(4)))
73428 +# define __force_rcu __force __rcu
73429 #else
73430 # define __rcu
73431 +# define __force_rcu
73432 #endif
73433 extern void __chk_user_ptr(const volatile void __user *);
73434 extern void __chk_io_ptr(const volatile void __iomem *);
73435 #else
73436 -# define __user
73437 -# define __kernel
73438 +# ifdef CHECKER_PLUGIN
73439 +//# define __user
73440 +//# define __force_user
73441 +//# define __kernel
73442 +//# define __force_kernel
73443 +# else
73444 +# ifdef STRUCTLEAK_PLUGIN
73445 +# define __user __attribute__((user))
73446 +# else
73447 +# define __user
73448 +# endif
73449 +# define __force_user
73450 +# define __kernel
73451 +# define __force_kernel
73452 +# endif
73453 # define __safe
73454 # define __force
73455 # define __nocast
73456 # define __iomem
73457 +# define __force_iomem
73458 # define __chk_user_ptr(x) (void)0
73459 # define __chk_io_ptr(x) (void)0
73460 # define __builtin_warning(x, y...) (1)
73461 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
73462 # define __release(x) (void)0
73463 # define __cond_lock(x,c) (c)
73464 # define __percpu
73465 +# define __force_percpu
73466 # define __rcu
73467 +# define __force_rcu
73468 #endif
73469
73470 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
73471 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73472 # define __attribute_const__ /* unimplemented */
73473 #endif
73474
73475 +#ifndef __no_const
73476 +# define __no_const
73477 +#endif
73478 +
73479 +#ifndef __do_const
73480 +# define __do_const
73481 +#endif
73482 +
73483 +#ifndef __size_overflow
73484 +# define __size_overflow(...)
73485 +#endif
73486 +
73487 +#ifndef __intentional_overflow
73488 +# define __intentional_overflow(...)
73489 +#endif
73490 +
73491 +#ifndef __latent_entropy
73492 +# define __latent_entropy
73493 +#endif
73494 +
73495 /*
73496 * Tell gcc if a function is cold. The compiler will assume any path
73497 * directly leading to the call is unlikely.
73498 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73499 #define __cold
73500 #endif
73501
73502 +#ifndef __alloc_size
73503 +#define __alloc_size(...)
73504 +#endif
73505 +
73506 +#ifndef __bos
73507 +#define __bos(ptr, arg)
73508 +#endif
73509 +
73510 +#ifndef __bos0
73511 +#define __bos0(ptr)
73512 +#endif
73513 +
73514 +#ifndef __bos1
73515 +#define __bos1(ptr)
73516 +#endif
73517 +
73518 /* Simple shorthand for a section definition */
73519 #ifndef __section
73520 # define __section(S) __attribute__ ((__section__(#S)))
73521 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73522 * use is to mediate communication between process-level code and irq/NMI
73523 * handlers, all running on the same CPU.
73524 */
73525 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
73526 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
73527 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
73528
73529 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
73530 #ifdef CONFIG_KPROBES
73531 diff --git a/include/linux/completion.h b/include/linux/completion.h
73532 index 3cd574d..240dcb0 100644
73533 --- a/include/linux/completion.h
73534 +++ b/include/linux/completion.h
73535 @@ -78,16 +78,16 @@ static inline void init_completion(struct completion *x)
73536
73537 extern void wait_for_completion(struct completion *);
73538 extern void wait_for_completion_io(struct completion *);
73539 -extern int wait_for_completion_interruptible(struct completion *x);
73540 -extern int wait_for_completion_killable(struct completion *x);
73541 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
73542 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
73543 extern unsigned long wait_for_completion_timeout(struct completion *x,
73544 - unsigned long timeout);
73545 + unsigned long timeout) __intentional_overflow(-1);
73546 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
73547 - unsigned long timeout);
73548 + unsigned long timeout) __intentional_overflow(-1);
73549 extern long wait_for_completion_interruptible_timeout(
73550 - struct completion *x, unsigned long timeout);
73551 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73552 extern long wait_for_completion_killable_timeout(
73553 - struct completion *x, unsigned long timeout);
73554 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73555 extern bool try_wait_for_completion(struct completion *x);
73556 extern bool completion_done(struct completion *x);
73557
73558 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
73559 index 34025df..d94bbbc 100644
73560 --- a/include/linux/configfs.h
73561 +++ b/include/linux/configfs.h
73562 @@ -125,7 +125,7 @@ struct configfs_attribute {
73563 const char *ca_name;
73564 struct module *ca_owner;
73565 umode_t ca_mode;
73566 -};
73567 +} __do_const;
73568
73569 /*
73570 * Users often need to create attribute structures for their configurable
73571 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
73572 index fcabc42..cba5d93 100644
73573 --- a/include/linux/cpufreq.h
73574 +++ b/include/linux/cpufreq.h
73575 @@ -167,6 +167,7 @@ struct global_attr {
73576 ssize_t (*store)(struct kobject *a, struct attribute *b,
73577 const char *c, size_t count);
73578 };
73579 +typedef struct global_attr __no_const global_attr_no_const;
73580
73581 #define define_one_global_ro(_name) \
73582 static struct global_attr _name = \
73583 @@ -208,7 +209,7 @@ struct cpufreq_driver {
73584 int (*suspend) (struct cpufreq_policy *policy);
73585 int (*resume) (struct cpufreq_policy *policy);
73586 struct freq_attr **attr;
73587 -};
73588 +} __do_const;
73589
73590 /* flags */
73591 #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
73592 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
73593 index 781addc..d1e1fe6 100644
73594 --- a/include/linux/cpuidle.h
73595 +++ b/include/linux/cpuidle.h
73596 @@ -50,7 +50,8 @@ struct cpuidle_state {
73597 int index);
73598
73599 int (*enter_dead) (struct cpuidle_device *dev, int index);
73600 -};
73601 +} __do_const;
73602 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
73603
73604 /* Idle State Flags */
73605 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
73606 @@ -192,7 +193,7 @@ struct cpuidle_governor {
73607 void (*reflect) (struct cpuidle_device *dev, int index);
73608
73609 struct module *owner;
73610 -};
73611 +} __do_const;
73612
73613 #ifdef CONFIG_CPU_IDLE
73614
73615 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
73616 index d08e4d2..95fad61 100644
73617 --- a/include/linux/cpumask.h
73618 +++ b/include/linux/cpumask.h
73619 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73620 }
73621
73622 /* Valid inputs for n are -1 and 0. */
73623 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73624 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73625 {
73626 return n+1;
73627 }
73628
73629 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73630 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73631 {
73632 return n+1;
73633 }
73634
73635 -static inline unsigned int cpumask_next_and(int n,
73636 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
73637 const struct cpumask *srcp,
73638 const struct cpumask *andp)
73639 {
73640 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73641 *
73642 * Returns >= nr_cpu_ids if no further cpus set.
73643 */
73644 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73645 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73646 {
73647 /* -1 is a legal arg here. */
73648 if (n != -1)
73649 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73650 *
73651 * Returns >= nr_cpu_ids if no further cpus unset.
73652 */
73653 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73654 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73655 {
73656 /* -1 is a legal arg here. */
73657 if (n != -1)
73658 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73659 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
73660 }
73661
73662 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
73663 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
73664 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
73665
73666 /**
73667 diff --git a/include/linux/cred.h b/include/linux/cred.h
73668 index 04421e8..6bce4ef 100644
73669 --- a/include/linux/cred.h
73670 +++ b/include/linux/cred.h
73671 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
73672 static inline void validate_process_creds(void)
73673 {
73674 }
73675 +static inline void validate_task_creds(struct task_struct *task)
73676 +{
73677 +}
73678 #endif
73679
73680 /**
73681 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
73682 index b92eadf..b4ecdc1 100644
73683 --- a/include/linux/crypto.h
73684 +++ b/include/linux/crypto.h
73685 @@ -373,7 +373,7 @@ struct cipher_tfm {
73686 const u8 *key, unsigned int keylen);
73687 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73688 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73689 -};
73690 +} __no_const;
73691
73692 struct hash_tfm {
73693 int (*init)(struct hash_desc *desc);
73694 @@ -394,13 +394,13 @@ struct compress_tfm {
73695 int (*cot_decompress)(struct crypto_tfm *tfm,
73696 const u8 *src, unsigned int slen,
73697 u8 *dst, unsigned int *dlen);
73698 -};
73699 +} __no_const;
73700
73701 struct rng_tfm {
73702 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
73703 unsigned int dlen);
73704 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
73705 -};
73706 +} __no_const;
73707
73708 #define crt_ablkcipher crt_u.ablkcipher
73709 #define crt_aead crt_u.aead
73710 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
73711 index 653589e..4ef254a 100644
73712 --- a/include/linux/ctype.h
73713 +++ b/include/linux/ctype.h
73714 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
73715 * Fast implementation of tolower() for internal usage. Do not use in your
73716 * code.
73717 */
73718 -static inline char _tolower(const char c)
73719 +static inline unsigned char _tolower(const unsigned char c)
73720 {
73721 return c | 0x20;
73722 }
73723 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
73724 index 7925bf0..d5143d2 100644
73725 --- a/include/linux/decompress/mm.h
73726 +++ b/include/linux/decompress/mm.h
73727 @@ -77,7 +77,7 @@ static void free(void *where)
73728 * warnings when not needed (indeed large_malloc / large_free are not
73729 * needed by inflate */
73730
73731 -#define malloc(a) kmalloc(a, GFP_KERNEL)
73732 +#define malloc(a) kmalloc((a), GFP_KERNEL)
73733 #define free(a) kfree(a)
73734
73735 #define large_malloc(a) vmalloc(a)
73736 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
73737 index 5f1ab92..39c35ae 100644
73738 --- a/include/linux/devfreq.h
73739 +++ b/include/linux/devfreq.h
73740 @@ -114,7 +114,7 @@ struct devfreq_governor {
73741 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
73742 int (*event_handler)(struct devfreq *devfreq,
73743 unsigned int event, void *data);
73744 -};
73745 +} __do_const;
73746
73747 /**
73748 * struct devfreq - Device devfreq structure
73749 diff --git a/include/linux/device.h b/include/linux/device.h
73750 index 2a9d6ed..d14551e3 100644
73751 --- a/include/linux/device.h
73752 +++ b/include/linux/device.h
73753 @@ -313,7 +313,7 @@ struct subsys_interface {
73754 struct list_head node;
73755 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
73756 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
73757 -};
73758 +} __do_const;
73759
73760 int subsys_interface_register(struct subsys_interface *sif);
73761 void subsys_interface_unregister(struct subsys_interface *sif);
73762 @@ -501,7 +501,7 @@ struct device_type {
73763 void (*release)(struct device *dev);
73764
73765 const struct dev_pm_ops *pm;
73766 -};
73767 +} __do_const;
73768
73769 /* interface for exporting device attributes */
73770 struct device_attribute {
73771 @@ -511,11 +511,12 @@ struct device_attribute {
73772 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
73773 const char *buf, size_t count);
73774 };
73775 +typedef struct device_attribute __no_const device_attribute_no_const;
73776
73777 struct dev_ext_attribute {
73778 struct device_attribute attr;
73779 void *var;
73780 -};
73781 +} __do_const;
73782
73783 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
73784 char *buf);
73785 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
73786 index 3a8d0a2..c762be2 100644
73787 --- a/include/linux/dma-mapping.h
73788 +++ b/include/linux/dma-mapping.h
73789 @@ -54,7 +54,7 @@ struct dma_map_ops {
73790 u64 (*get_required_mask)(struct device *dev);
73791 #endif
73792 int is_phys;
73793 -};
73794 +} __do_const;
73795
73796 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
73797
73798 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
73799 index 0bc7275..4ccbf11 100644
73800 --- a/include/linux/dmaengine.h
73801 +++ b/include/linux/dmaengine.h
73802 @@ -1078,9 +1078,9 @@ struct dma_pinned_list {
73803 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
73804 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
73805
73806 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73807 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73808 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
73809 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73810 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73811 struct dma_pinned_list *pinned_list, struct page *page,
73812 unsigned int offset, size_t len);
73813
73814 diff --git a/include/linux/efi.h b/include/linux/efi.h
73815 index 5f8f176..62a0556 100644
73816 --- a/include/linux/efi.h
73817 +++ b/include/linux/efi.h
73818 @@ -745,6 +745,7 @@ struct efivar_operations {
73819 efi_set_variable_t *set_variable;
73820 efi_query_variable_store_t *query_variable_store;
73821 };
73822 +typedef struct efivar_operations __no_const efivar_operations_no_const;
73823
73824 struct efivars {
73825 /*
73826 diff --git a/include/linux/elf.h b/include/linux/elf.h
73827 index 40a3c0e..4c45a38 100644
73828 --- a/include/linux/elf.h
73829 +++ b/include/linux/elf.h
73830 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
73831 #define elf_note elf32_note
73832 #define elf_addr_t Elf32_Off
73833 #define Elf_Half Elf32_Half
73834 +#define elf_dyn Elf32_Dyn
73835
73836 #else
73837
73838 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
73839 #define elf_note elf64_note
73840 #define elf_addr_t Elf64_Off
73841 #define Elf_Half Elf64_Half
73842 +#define elf_dyn Elf64_Dyn
73843
73844 #endif
73845
73846 diff --git a/include/linux/err.h b/include/linux/err.h
73847 index 15f92e0..e825a8e 100644
73848 --- a/include/linux/err.h
73849 +++ b/include/linux/err.h
73850 @@ -19,12 +19,12 @@
73851
73852 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
73853
73854 -static inline void * __must_check ERR_PTR(long error)
73855 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
73856 {
73857 return (void *) error;
73858 }
73859
73860 -static inline long __must_check PTR_ERR(__force const void *ptr)
73861 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
73862 {
73863 return (long) ptr;
73864 }
73865 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
73866 index fcb51c8..bdafcf6 100644
73867 --- a/include/linux/extcon.h
73868 +++ b/include/linux/extcon.h
73869 @@ -134,7 +134,7 @@ struct extcon_dev {
73870 /* /sys/class/extcon/.../mutually_exclusive/... */
73871 struct attribute_group attr_g_muex;
73872 struct attribute **attrs_muex;
73873 - struct device_attribute *d_attrs_muex;
73874 + device_attribute_no_const *d_attrs_muex;
73875 };
73876
73877 /**
73878 diff --git a/include/linux/fb.h b/include/linux/fb.h
73879 index ffac70a..ca3e711 100644
73880 --- a/include/linux/fb.h
73881 +++ b/include/linux/fb.h
73882 @@ -304,7 +304,7 @@ struct fb_ops {
73883 /* called at KDB enter and leave time to prepare the console */
73884 int (*fb_debug_enter)(struct fb_info *info);
73885 int (*fb_debug_leave)(struct fb_info *info);
73886 -};
73887 +} __do_const;
73888
73889 #ifdef CONFIG_FB_TILEBLITTING
73890 #define FB_TILE_CURSOR_NONE 0
73891 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
73892 index 085197b..0fa6f0b 100644
73893 --- a/include/linux/fdtable.h
73894 +++ b/include/linux/fdtable.h
73895 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
73896 void put_files_struct(struct files_struct *fs);
73897 void reset_files_struct(struct files_struct *);
73898 int unshare_files(struct files_struct **);
73899 -struct files_struct *dup_fd(struct files_struct *, int *);
73900 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73901 void do_close_on_exec(struct files_struct *);
73902 int iterate_fd(struct files_struct *, unsigned,
73903 int (*)(const void *, struct file *, unsigned),
73904 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73905 index 8293262..2b3b8bd 100644
73906 --- a/include/linux/frontswap.h
73907 +++ b/include/linux/frontswap.h
73908 @@ -11,7 +11,7 @@ struct frontswap_ops {
73909 int (*load)(unsigned, pgoff_t, struct page *);
73910 void (*invalidate_page)(unsigned, pgoff_t);
73911 void (*invalidate_area)(unsigned);
73912 -};
73913 +} __no_const;
73914
73915 extern bool frontswap_enabled;
73916 extern struct frontswap_ops *
73917 diff --git a/include/linux/fs.h b/include/linux/fs.h
73918 index 3f40547..46f76eb 100644
73919 --- a/include/linux/fs.h
73920 +++ b/include/linux/fs.h
73921 @@ -1552,7 +1552,8 @@ struct file_operations {
73922 long (*fallocate)(struct file *file, int mode, loff_t offset,
73923 loff_t len);
73924 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73925 -};
73926 +} __do_const;
73927 +typedef struct file_operations __no_const file_operations_no_const;
73928
73929 struct inode_operations {
73930 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73931 @@ -2745,4 +2746,14 @@ static inline bool dir_relax(struct inode *inode)
73932 return !IS_DEADDIR(inode);
73933 }
73934
73935 +static inline bool is_sidechannel_device(const struct inode *inode)
73936 +{
73937 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73938 + umode_t mode = inode->i_mode;
73939 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73940 +#else
73941 + return false;
73942 +#endif
73943 +}
73944 +
73945 #endif /* _LINUX_FS_H */
73946 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73947 index 0efc3e6..e0e1e5f 100644
73948 --- a/include/linux/fs_struct.h
73949 +++ b/include/linux/fs_struct.h
73950 @@ -6,7 +6,7 @@
73951 #include <linux/seqlock.h>
73952
73953 struct fs_struct {
73954 - int users;
73955 + atomic_t users;
73956 spinlock_t lock;
73957 seqcount_t seq;
73958 int umask;
73959 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73960 index 7823e9e..56b6f2f 100644
73961 --- a/include/linux/fscache-cache.h
73962 +++ b/include/linux/fscache-cache.h
73963 @@ -113,7 +113,7 @@ struct fscache_operation {
73964 fscache_operation_release_t release;
73965 };
73966
73967 -extern atomic_t fscache_op_debug_id;
73968 +extern atomic_unchecked_t fscache_op_debug_id;
73969 extern void fscache_op_work_func(struct work_struct *work);
73970
73971 extern void fscache_enqueue_operation(struct fscache_operation *);
73972 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73973 INIT_WORK(&op->work, fscache_op_work_func);
73974 atomic_set(&op->usage, 1);
73975 op->state = FSCACHE_OP_ST_INITIALISED;
73976 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73977 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73978 op->processor = processor;
73979 op->release = release;
73980 INIT_LIST_HEAD(&op->pend_link);
73981 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73982 index 19b4645..3b73dfc 100644
73983 --- a/include/linux/fscache.h
73984 +++ b/include/linux/fscache.h
73985 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73986 * - this is mandatory for any object that may have data
73987 */
73988 void (*now_uncached)(void *cookie_netfs_data);
73989 -};
73990 +} __do_const;
73991
73992 /*
73993 * fscache cached network filesystem type
73994 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73995 index 1c804b0..1432c2b 100644
73996 --- a/include/linux/fsnotify.h
73997 +++ b/include/linux/fsnotify.h
73998 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73999 struct inode *inode = file_inode(file);
74000 __u32 mask = FS_ACCESS;
74001
74002 + if (is_sidechannel_device(inode))
74003 + return;
74004 +
74005 if (S_ISDIR(inode->i_mode))
74006 mask |= FS_ISDIR;
74007
74008 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
74009 struct inode *inode = file_inode(file);
74010 __u32 mask = FS_MODIFY;
74011
74012 + if (is_sidechannel_device(inode))
74013 + return;
74014 +
74015 if (S_ISDIR(inode->i_mode))
74016 mask |= FS_ISDIR;
74017
74018 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
74019 */
74020 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
74021 {
74022 - return kstrdup(name, GFP_KERNEL);
74023 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
74024 }
74025
74026 /*
74027 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
74028 index 9f3c275..8bdff5d 100644
74029 --- a/include/linux/genhd.h
74030 +++ b/include/linux/genhd.h
74031 @@ -194,7 +194,7 @@ struct gendisk {
74032 struct kobject *slave_dir;
74033
74034 struct timer_rand_state *random;
74035 - atomic_t sync_io; /* RAID */
74036 + atomic_unchecked_t sync_io; /* RAID */
74037 struct disk_events *ev;
74038 #ifdef CONFIG_BLK_DEV_INTEGRITY
74039 struct blk_integrity *integrity;
74040 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
74041 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
74042
74043 /* drivers/char/random.c */
74044 -extern void add_disk_randomness(struct gendisk *disk);
74045 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
74046 extern void rand_initialize_disk(struct gendisk *disk);
74047
74048 static inline sector_t get_start_sect(struct block_device *bdev)
74049 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
74050 index 023bc34..b02b46a 100644
74051 --- a/include/linux/genl_magic_func.h
74052 +++ b/include/linux/genl_magic_func.h
74053 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
74054 },
74055
74056 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
74057 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
74058 +static struct genl_ops ZZZ_genl_ops[] = {
74059 #include GENL_MAGIC_INCLUDE_FILE
74060 };
74061
74062 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
74063 index 9b4dd49..61fd41d 100644
74064 --- a/include/linux/gfp.h
74065 +++ b/include/linux/gfp.h
74066 @@ -35,6 +35,13 @@ struct vm_area_struct;
74067 #define ___GFP_NO_KSWAPD 0x400000u
74068 #define ___GFP_OTHER_NODE 0x800000u
74069 #define ___GFP_WRITE 0x1000000u
74070 +
74071 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74072 +#define ___GFP_USERCOPY 0x2000000u
74073 +#else
74074 +#define ___GFP_USERCOPY 0
74075 +#endif
74076 +
74077 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
74078
74079 /*
74080 @@ -92,6 +99,7 @@ struct vm_area_struct;
74081 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
74082 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
74083 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
74084 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
74085
74086 /*
74087 * This may seem redundant, but it's a way of annotating false positives vs.
74088 @@ -99,7 +107,7 @@ struct vm_area_struct;
74089 */
74090 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
74091
74092 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
74093 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
74094 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
74095
74096 /* This equals 0, but use constants in case they ever change */
74097 @@ -153,6 +161,8 @@ struct vm_area_struct;
74098 /* 4GB DMA on some platforms */
74099 #define GFP_DMA32 __GFP_DMA32
74100
74101 +#define GFP_USERCOPY __GFP_USERCOPY
74102 +
74103 /* Convert GFP flags to their corresponding migrate type */
74104 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
74105 {
74106 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
74107 new file mode 100644
74108 index 0000000..edb2cb6
74109 --- /dev/null
74110 +++ b/include/linux/gracl.h
74111 @@ -0,0 +1,340 @@
74112 +#ifndef GR_ACL_H
74113 +#define GR_ACL_H
74114 +
74115 +#include <linux/grdefs.h>
74116 +#include <linux/resource.h>
74117 +#include <linux/capability.h>
74118 +#include <linux/dcache.h>
74119 +#include <asm/resource.h>
74120 +
74121 +/* Major status information */
74122 +
74123 +#define GR_VERSION "grsecurity 3.0"
74124 +#define GRSECURITY_VERSION 0x3000
74125 +
74126 +enum {
74127 + GR_SHUTDOWN = 0,
74128 + GR_ENABLE = 1,
74129 + GR_SPROLE = 2,
74130 + GR_OLDRELOAD = 3,
74131 + GR_SEGVMOD = 4,
74132 + GR_STATUS = 5,
74133 + GR_UNSPROLE = 6,
74134 + GR_PASSSET = 7,
74135 + GR_SPROLEPAM = 8,
74136 + GR_RELOAD = 9,
74137 +};
74138 +
74139 +/* Password setup definitions
74140 + * kernel/grhash.c */
74141 +enum {
74142 + GR_PW_LEN = 128,
74143 + GR_SALT_LEN = 16,
74144 + GR_SHA_LEN = 32,
74145 +};
74146 +
74147 +enum {
74148 + GR_SPROLE_LEN = 64,
74149 +};
74150 +
74151 +enum {
74152 + GR_NO_GLOB = 0,
74153 + GR_REG_GLOB,
74154 + GR_CREATE_GLOB
74155 +};
74156 +
74157 +#define GR_NLIMITS 32
74158 +
74159 +/* Begin Data Structures */
74160 +
74161 +struct sprole_pw {
74162 + unsigned char *rolename;
74163 + unsigned char salt[GR_SALT_LEN];
74164 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
74165 +};
74166 +
74167 +struct name_entry {
74168 + __u32 key;
74169 + ino_t inode;
74170 + dev_t device;
74171 + char *name;
74172 + __u16 len;
74173 + __u8 deleted;
74174 + struct name_entry *prev;
74175 + struct name_entry *next;
74176 +};
74177 +
74178 +struct inodev_entry {
74179 + struct name_entry *nentry;
74180 + struct inodev_entry *prev;
74181 + struct inodev_entry *next;
74182 +};
74183 +
74184 +struct acl_role_db {
74185 + struct acl_role_label **r_hash;
74186 + __u32 r_size;
74187 +};
74188 +
74189 +struct inodev_db {
74190 + struct inodev_entry **i_hash;
74191 + __u32 i_size;
74192 +};
74193 +
74194 +struct name_db {
74195 + struct name_entry **n_hash;
74196 + __u32 n_size;
74197 +};
74198 +
74199 +struct crash_uid {
74200 + uid_t uid;
74201 + unsigned long expires;
74202 +};
74203 +
74204 +struct gr_hash_struct {
74205 + void **table;
74206 + void **nametable;
74207 + void *first;
74208 + __u32 table_size;
74209 + __u32 used_size;
74210 + int type;
74211 +};
74212 +
74213 +/* Userspace Grsecurity ACL data structures */
74214 +
74215 +struct acl_subject_label {
74216 + char *filename;
74217 + ino_t inode;
74218 + dev_t device;
74219 + __u32 mode;
74220 + kernel_cap_t cap_mask;
74221 + kernel_cap_t cap_lower;
74222 + kernel_cap_t cap_invert_audit;
74223 +
74224 + struct rlimit res[GR_NLIMITS];
74225 + __u32 resmask;
74226 +
74227 + __u8 user_trans_type;
74228 + __u8 group_trans_type;
74229 + uid_t *user_transitions;
74230 + gid_t *group_transitions;
74231 + __u16 user_trans_num;
74232 + __u16 group_trans_num;
74233 +
74234 + __u32 sock_families[2];
74235 + __u32 ip_proto[8];
74236 + __u32 ip_type;
74237 + struct acl_ip_label **ips;
74238 + __u32 ip_num;
74239 + __u32 inaddr_any_override;
74240 +
74241 + __u32 crashes;
74242 + unsigned long expires;
74243 +
74244 + struct acl_subject_label *parent_subject;
74245 + struct gr_hash_struct *hash;
74246 + struct acl_subject_label *prev;
74247 + struct acl_subject_label *next;
74248 +
74249 + struct acl_object_label **obj_hash;
74250 + __u32 obj_hash_size;
74251 + __u16 pax_flags;
74252 +};
74253 +
74254 +struct role_allowed_ip {
74255 + __u32 addr;
74256 + __u32 netmask;
74257 +
74258 + struct role_allowed_ip *prev;
74259 + struct role_allowed_ip *next;
74260 +};
74261 +
74262 +struct role_transition {
74263 + char *rolename;
74264 +
74265 + struct role_transition *prev;
74266 + struct role_transition *next;
74267 +};
74268 +
74269 +struct acl_role_label {
74270 + char *rolename;
74271 + uid_t uidgid;
74272 + __u16 roletype;
74273 +
74274 + __u16 auth_attempts;
74275 + unsigned long expires;
74276 +
74277 + struct acl_subject_label *root_label;
74278 + struct gr_hash_struct *hash;
74279 +
74280 + struct acl_role_label *prev;
74281 + struct acl_role_label *next;
74282 +
74283 + struct role_transition *transitions;
74284 + struct role_allowed_ip *allowed_ips;
74285 + uid_t *domain_children;
74286 + __u16 domain_child_num;
74287 +
74288 + umode_t umask;
74289 +
74290 + struct acl_subject_label **subj_hash;
74291 + __u32 subj_hash_size;
74292 +};
74293 +
74294 +struct user_acl_role_db {
74295 + struct acl_role_label **r_table;
74296 + __u32 num_pointers; /* Number of allocations to track */
74297 + __u32 num_roles; /* Number of roles */
74298 + __u32 num_domain_children; /* Number of domain children */
74299 + __u32 num_subjects; /* Number of subjects */
74300 + __u32 num_objects; /* Number of objects */
74301 +};
74302 +
74303 +struct acl_object_label {
74304 + char *filename;
74305 + ino_t inode;
74306 + dev_t device;
74307 + __u32 mode;
74308 +
74309 + struct acl_subject_label *nested;
74310 + struct acl_object_label *globbed;
74311 +
74312 + /* next two structures not used */
74313 +
74314 + struct acl_object_label *prev;
74315 + struct acl_object_label *next;
74316 +};
74317 +
74318 +struct acl_ip_label {
74319 + char *iface;
74320 + __u32 addr;
74321 + __u32 netmask;
74322 + __u16 low, high;
74323 + __u8 mode;
74324 + __u32 type;
74325 + __u32 proto[8];
74326 +
74327 + /* next two structures not used */
74328 +
74329 + struct acl_ip_label *prev;
74330 + struct acl_ip_label *next;
74331 +};
74332 +
74333 +struct gr_arg {
74334 + struct user_acl_role_db role_db;
74335 + unsigned char pw[GR_PW_LEN];
74336 + unsigned char salt[GR_SALT_LEN];
74337 + unsigned char sum[GR_SHA_LEN];
74338 + unsigned char sp_role[GR_SPROLE_LEN];
74339 + struct sprole_pw *sprole_pws;
74340 + dev_t segv_device;
74341 + ino_t segv_inode;
74342 + uid_t segv_uid;
74343 + __u16 num_sprole_pws;
74344 + __u16 mode;
74345 +};
74346 +
74347 +struct gr_arg_wrapper {
74348 + struct gr_arg *arg;
74349 + __u32 version;
74350 + __u32 size;
74351 +};
74352 +
74353 +struct subject_map {
74354 + struct acl_subject_label *user;
74355 + struct acl_subject_label *kernel;
74356 + struct subject_map *prev;
74357 + struct subject_map *next;
74358 +};
74359 +
74360 +struct acl_subj_map_db {
74361 + struct subject_map **s_hash;
74362 + __u32 s_size;
74363 +};
74364 +
74365 +struct gr_policy_state {
74366 + struct sprole_pw **acl_special_roles;
74367 + __u16 num_sprole_pws;
74368 + struct acl_role_label *kernel_role;
74369 + struct acl_role_label *role_list;
74370 + struct acl_role_label *default_role;
74371 + struct acl_role_db acl_role_set;
74372 + struct acl_subj_map_db subj_map_set;
74373 + struct name_db name_set;
74374 + struct inodev_db inodev_set;
74375 +};
74376 +
74377 +struct gr_alloc_state {
74378 + unsigned long alloc_stack_next;
74379 + unsigned long alloc_stack_size;
74380 + void **alloc_stack;
74381 +};
74382 +
74383 +struct gr_reload_state {
74384 + struct gr_policy_state oldpolicy;
74385 + struct gr_alloc_state oldalloc;
74386 + struct gr_policy_state newpolicy;
74387 + struct gr_alloc_state newalloc;
74388 + struct gr_policy_state *oldpolicy_ptr;
74389 + struct gr_alloc_state *oldalloc_ptr;
74390 + unsigned char oldmode;
74391 +};
74392 +
74393 +/* End Data Structures Section */
74394 +
74395 +/* Hash functions generated by empirical testing by Brad Spengler
74396 + Makes good use of the low bits of the inode. Generally 0-1 times
74397 + in loop for successful match. 0-3 for unsuccessful match.
74398 + Shift/add algorithm with modulus of table size and an XOR*/
74399 +
74400 +static __inline__ unsigned int
74401 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
74402 +{
74403 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
74404 +}
74405 +
74406 + static __inline__ unsigned int
74407 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
74408 +{
74409 + return ((const unsigned long)userp % sz);
74410 +}
74411 +
74412 +static __inline__ unsigned int
74413 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
74414 +{
74415 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
74416 +}
74417 +
74418 +static __inline__ unsigned int
74419 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
74420 +{
74421 + return full_name_hash((const unsigned char *)name, len) % sz;
74422 +}
74423 +
74424 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
74425 + subj = NULL; \
74426 + iter = 0; \
74427 + while (iter < role->subj_hash_size) { \
74428 + if (subj == NULL) \
74429 + subj = role->subj_hash[iter]; \
74430 + if (subj == NULL) { \
74431 + iter++; \
74432 + continue; \
74433 + }
74434 +
74435 +#define FOR_EACH_SUBJECT_END(subj,iter) \
74436 + subj = subj->next; \
74437 + if (subj == NULL) \
74438 + iter++; \
74439 + }
74440 +
74441 +
74442 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
74443 + subj = role->hash->first; \
74444 + while (subj != NULL) {
74445 +
74446 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
74447 + subj = subj->next; \
74448 + }
74449 +
74450 +#endif
74451 +
74452 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
74453 new file mode 100644
74454 index 0000000..33ebd1f
74455 --- /dev/null
74456 +++ b/include/linux/gracl_compat.h
74457 @@ -0,0 +1,156 @@
74458 +#ifndef GR_ACL_COMPAT_H
74459 +#define GR_ACL_COMPAT_H
74460 +
74461 +#include <linux/resource.h>
74462 +#include <asm/resource.h>
74463 +
74464 +struct sprole_pw_compat {
74465 + compat_uptr_t rolename;
74466 + unsigned char salt[GR_SALT_LEN];
74467 + unsigned char sum[GR_SHA_LEN];
74468 +};
74469 +
74470 +struct gr_hash_struct_compat {
74471 + compat_uptr_t table;
74472 + compat_uptr_t nametable;
74473 + compat_uptr_t first;
74474 + __u32 table_size;
74475 + __u32 used_size;
74476 + int type;
74477 +};
74478 +
74479 +struct acl_subject_label_compat {
74480 + compat_uptr_t filename;
74481 + compat_ino_t inode;
74482 + __u32 device;
74483 + __u32 mode;
74484 + kernel_cap_t cap_mask;
74485 + kernel_cap_t cap_lower;
74486 + kernel_cap_t cap_invert_audit;
74487 +
74488 + struct compat_rlimit res[GR_NLIMITS];
74489 + __u32 resmask;
74490 +
74491 + __u8 user_trans_type;
74492 + __u8 group_trans_type;
74493 + compat_uptr_t user_transitions;
74494 + compat_uptr_t group_transitions;
74495 + __u16 user_trans_num;
74496 + __u16 group_trans_num;
74497 +
74498 + __u32 sock_families[2];
74499 + __u32 ip_proto[8];
74500 + __u32 ip_type;
74501 + compat_uptr_t ips;
74502 + __u32 ip_num;
74503 + __u32 inaddr_any_override;
74504 +
74505 + __u32 crashes;
74506 + compat_ulong_t expires;
74507 +
74508 + compat_uptr_t parent_subject;
74509 + compat_uptr_t hash;
74510 + compat_uptr_t prev;
74511 + compat_uptr_t next;
74512 +
74513 + compat_uptr_t obj_hash;
74514 + __u32 obj_hash_size;
74515 + __u16 pax_flags;
74516 +};
74517 +
74518 +struct role_allowed_ip_compat {
74519 + __u32 addr;
74520 + __u32 netmask;
74521 +
74522 + compat_uptr_t prev;
74523 + compat_uptr_t next;
74524 +};
74525 +
74526 +struct role_transition_compat {
74527 + compat_uptr_t rolename;
74528 +
74529 + compat_uptr_t prev;
74530 + compat_uptr_t next;
74531 +};
74532 +
74533 +struct acl_role_label_compat {
74534 + compat_uptr_t rolename;
74535 + uid_t uidgid;
74536 + __u16 roletype;
74537 +
74538 + __u16 auth_attempts;
74539 + compat_ulong_t expires;
74540 +
74541 + compat_uptr_t root_label;
74542 + compat_uptr_t hash;
74543 +
74544 + compat_uptr_t prev;
74545 + compat_uptr_t next;
74546 +
74547 + compat_uptr_t transitions;
74548 + compat_uptr_t allowed_ips;
74549 + compat_uptr_t domain_children;
74550 + __u16 domain_child_num;
74551 +
74552 + umode_t umask;
74553 +
74554 + compat_uptr_t subj_hash;
74555 + __u32 subj_hash_size;
74556 +};
74557 +
74558 +struct user_acl_role_db_compat {
74559 + compat_uptr_t r_table;
74560 + __u32 num_pointers;
74561 + __u32 num_roles;
74562 + __u32 num_domain_children;
74563 + __u32 num_subjects;
74564 + __u32 num_objects;
74565 +};
74566 +
74567 +struct acl_object_label_compat {
74568 + compat_uptr_t filename;
74569 + compat_ino_t inode;
74570 + __u32 device;
74571 + __u32 mode;
74572 +
74573 + compat_uptr_t nested;
74574 + compat_uptr_t globbed;
74575 +
74576 + compat_uptr_t prev;
74577 + compat_uptr_t next;
74578 +};
74579 +
74580 +struct acl_ip_label_compat {
74581 + compat_uptr_t iface;
74582 + __u32 addr;
74583 + __u32 netmask;
74584 + __u16 low, high;
74585 + __u8 mode;
74586 + __u32 type;
74587 + __u32 proto[8];
74588 +
74589 + compat_uptr_t prev;
74590 + compat_uptr_t next;
74591 +};
74592 +
74593 +struct gr_arg_compat {
74594 + struct user_acl_role_db_compat role_db;
74595 + unsigned char pw[GR_PW_LEN];
74596 + unsigned char salt[GR_SALT_LEN];
74597 + unsigned char sum[GR_SHA_LEN];
74598 + unsigned char sp_role[GR_SPROLE_LEN];
74599 + compat_uptr_t sprole_pws;
74600 + __u32 segv_device;
74601 + compat_ino_t segv_inode;
74602 + uid_t segv_uid;
74603 + __u16 num_sprole_pws;
74604 + __u16 mode;
74605 +};
74606 +
74607 +struct gr_arg_wrapper_compat {
74608 + compat_uptr_t arg;
74609 + __u32 version;
74610 + __u32 size;
74611 +};
74612 +
74613 +#endif
74614 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
74615 new file mode 100644
74616 index 0000000..323ecf2
74617 --- /dev/null
74618 +++ b/include/linux/gralloc.h
74619 @@ -0,0 +1,9 @@
74620 +#ifndef __GRALLOC_H
74621 +#define __GRALLOC_H
74622 +
74623 +void acl_free_all(void);
74624 +int acl_alloc_stack_init(unsigned long size);
74625 +void *acl_alloc(unsigned long len);
74626 +void *acl_alloc_num(unsigned long num, unsigned long len);
74627 +
74628 +#endif
74629 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
74630 new file mode 100644
74631 index 0000000..be66033
74632 --- /dev/null
74633 +++ b/include/linux/grdefs.h
74634 @@ -0,0 +1,140 @@
74635 +#ifndef GRDEFS_H
74636 +#define GRDEFS_H
74637 +
74638 +/* Begin grsecurity status declarations */
74639 +
74640 +enum {
74641 + GR_READY = 0x01,
74642 + GR_STATUS_INIT = 0x00 // disabled state
74643 +};
74644 +
74645 +/* Begin ACL declarations */
74646 +
74647 +/* Role flags */
74648 +
74649 +enum {
74650 + GR_ROLE_USER = 0x0001,
74651 + GR_ROLE_GROUP = 0x0002,
74652 + GR_ROLE_DEFAULT = 0x0004,
74653 + GR_ROLE_SPECIAL = 0x0008,
74654 + GR_ROLE_AUTH = 0x0010,
74655 + GR_ROLE_NOPW = 0x0020,
74656 + GR_ROLE_GOD = 0x0040,
74657 + GR_ROLE_LEARN = 0x0080,
74658 + GR_ROLE_TPE = 0x0100,
74659 + GR_ROLE_DOMAIN = 0x0200,
74660 + GR_ROLE_PAM = 0x0400,
74661 + GR_ROLE_PERSIST = 0x0800
74662 +};
74663 +
74664 +/* ACL Subject and Object mode flags */
74665 +enum {
74666 + GR_DELETED = 0x80000000
74667 +};
74668 +
74669 +/* ACL Object-only mode flags */
74670 +enum {
74671 + GR_READ = 0x00000001,
74672 + GR_APPEND = 0x00000002,
74673 + GR_WRITE = 0x00000004,
74674 + GR_EXEC = 0x00000008,
74675 + GR_FIND = 0x00000010,
74676 + GR_INHERIT = 0x00000020,
74677 + GR_SETID = 0x00000040,
74678 + GR_CREATE = 0x00000080,
74679 + GR_DELETE = 0x00000100,
74680 + GR_LINK = 0x00000200,
74681 + GR_AUDIT_READ = 0x00000400,
74682 + GR_AUDIT_APPEND = 0x00000800,
74683 + GR_AUDIT_WRITE = 0x00001000,
74684 + GR_AUDIT_EXEC = 0x00002000,
74685 + GR_AUDIT_FIND = 0x00004000,
74686 + GR_AUDIT_INHERIT= 0x00008000,
74687 + GR_AUDIT_SETID = 0x00010000,
74688 + GR_AUDIT_CREATE = 0x00020000,
74689 + GR_AUDIT_DELETE = 0x00040000,
74690 + GR_AUDIT_LINK = 0x00080000,
74691 + GR_PTRACERD = 0x00100000,
74692 + GR_NOPTRACE = 0x00200000,
74693 + GR_SUPPRESS = 0x00400000,
74694 + GR_NOLEARN = 0x00800000,
74695 + GR_INIT_TRANSFER= 0x01000000
74696 +};
74697 +
74698 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
74699 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
74700 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
74701 +
74702 +/* ACL subject-only mode flags */
74703 +enum {
74704 + GR_KILL = 0x00000001,
74705 + GR_VIEW = 0x00000002,
74706 + GR_PROTECTED = 0x00000004,
74707 + GR_LEARN = 0x00000008,
74708 + GR_OVERRIDE = 0x00000010,
74709 + /* just a placeholder, this mode is only used in userspace */
74710 + GR_DUMMY = 0x00000020,
74711 + GR_PROTSHM = 0x00000040,
74712 + GR_KILLPROC = 0x00000080,
74713 + GR_KILLIPPROC = 0x00000100,
74714 + /* just a placeholder, this mode is only used in userspace */
74715 + GR_NOTROJAN = 0x00000200,
74716 + GR_PROTPROCFD = 0x00000400,
74717 + GR_PROCACCT = 0x00000800,
74718 + GR_RELAXPTRACE = 0x00001000,
74719 + //GR_NESTED = 0x00002000,
74720 + GR_INHERITLEARN = 0x00004000,
74721 + GR_PROCFIND = 0x00008000,
74722 + GR_POVERRIDE = 0x00010000,
74723 + GR_KERNELAUTH = 0x00020000,
74724 + GR_ATSECURE = 0x00040000,
74725 + GR_SHMEXEC = 0x00080000
74726 +};
74727 +
74728 +enum {
74729 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
74730 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
74731 + GR_PAX_ENABLE_MPROTECT = 0x0004,
74732 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
74733 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
74734 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
74735 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
74736 + GR_PAX_DISABLE_MPROTECT = 0x0400,
74737 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
74738 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
74739 +};
74740 +
74741 +enum {
74742 + GR_ID_USER = 0x01,
74743 + GR_ID_GROUP = 0x02,
74744 +};
74745 +
74746 +enum {
74747 + GR_ID_ALLOW = 0x01,
74748 + GR_ID_DENY = 0x02,
74749 +};
74750 +
74751 +#define GR_CRASH_RES 31
74752 +#define GR_UIDTABLE_MAX 500
74753 +
74754 +/* begin resource learning section */
74755 +enum {
74756 + GR_RLIM_CPU_BUMP = 60,
74757 + GR_RLIM_FSIZE_BUMP = 50000,
74758 + GR_RLIM_DATA_BUMP = 10000,
74759 + GR_RLIM_STACK_BUMP = 1000,
74760 + GR_RLIM_CORE_BUMP = 10000,
74761 + GR_RLIM_RSS_BUMP = 500000,
74762 + GR_RLIM_NPROC_BUMP = 1,
74763 + GR_RLIM_NOFILE_BUMP = 5,
74764 + GR_RLIM_MEMLOCK_BUMP = 50000,
74765 + GR_RLIM_AS_BUMP = 500000,
74766 + GR_RLIM_LOCKS_BUMP = 2,
74767 + GR_RLIM_SIGPENDING_BUMP = 5,
74768 + GR_RLIM_MSGQUEUE_BUMP = 10000,
74769 + GR_RLIM_NICE_BUMP = 1,
74770 + GR_RLIM_RTPRIO_BUMP = 1,
74771 + GR_RLIM_RTTIME_BUMP = 1000000
74772 +};
74773 +
74774 +#endif
74775 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
74776 new file mode 100644
74777 index 0000000..d25522e
74778 --- /dev/null
74779 +++ b/include/linux/grinternal.h
74780 @@ -0,0 +1,229 @@
74781 +#ifndef __GRINTERNAL_H
74782 +#define __GRINTERNAL_H
74783 +
74784 +#ifdef CONFIG_GRKERNSEC
74785 +
74786 +#include <linux/fs.h>
74787 +#include <linux/mnt_namespace.h>
74788 +#include <linux/nsproxy.h>
74789 +#include <linux/gracl.h>
74790 +#include <linux/grdefs.h>
74791 +#include <linux/grmsg.h>
74792 +
74793 +void gr_add_learn_entry(const char *fmt, ...)
74794 + __attribute__ ((format (printf, 1, 2)));
74795 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
74796 + const struct vfsmount *mnt);
74797 +__u32 gr_check_create(const struct dentry *new_dentry,
74798 + const struct dentry *parent,
74799 + const struct vfsmount *mnt, const __u32 mode);
74800 +int gr_check_protected_task(const struct task_struct *task);
74801 +__u32 to_gr_audit(const __u32 reqmode);
74802 +int gr_set_acls(const int type);
74803 +int gr_acl_is_enabled(void);
74804 +char gr_roletype_to_char(void);
74805 +
74806 +void gr_handle_alertkill(struct task_struct *task);
74807 +char *gr_to_filename(const struct dentry *dentry,
74808 + const struct vfsmount *mnt);
74809 +char *gr_to_filename1(const struct dentry *dentry,
74810 + const struct vfsmount *mnt);
74811 +char *gr_to_filename2(const struct dentry *dentry,
74812 + const struct vfsmount *mnt);
74813 +char *gr_to_filename3(const struct dentry *dentry,
74814 + const struct vfsmount *mnt);
74815 +
74816 +extern int grsec_enable_ptrace_readexec;
74817 +extern int grsec_enable_harden_ptrace;
74818 +extern int grsec_enable_link;
74819 +extern int grsec_enable_fifo;
74820 +extern int grsec_enable_execve;
74821 +extern int grsec_enable_shm;
74822 +extern int grsec_enable_execlog;
74823 +extern int grsec_enable_signal;
74824 +extern int grsec_enable_audit_ptrace;
74825 +extern int grsec_enable_forkfail;
74826 +extern int grsec_enable_time;
74827 +extern int grsec_enable_rofs;
74828 +extern int grsec_deny_new_usb;
74829 +extern int grsec_enable_chroot_shmat;
74830 +extern int grsec_enable_chroot_mount;
74831 +extern int grsec_enable_chroot_double;
74832 +extern int grsec_enable_chroot_pivot;
74833 +extern int grsec_enable_chroot_chdir;
74834 +extern int grsec_enable_chroot_chmod;
74835 +extern int grsec_enable_chroot_mknod;
74836 +extern int grsec_enable_chroot_fchdir;
74837 +extern int grsec_enable_chroot_nice;
74838 +extern int grsec_enable_chroot_execlog;
74839 +extern int grsec_enable_chroot_caps;
74840 +extern int grsec_enable_chroot_sysctl;
74841 +extern int grsec_enable_chroot_unix;
74842 +extern int grsec_enable_symlinkown;
74843 +extern kgid_t grsec_symlinkown_gid;
74844 +extern int grsec_enable_tpe;
74845 +extern kgid_t grsec_tpe_gid;
74846 +extern int grsec_enable_tpe_all;
74847 +extern int grsec_enable_tpe_invert;
74848 +extern int grsec_enable_socket_all;
74849 +extern kgid_t grsec_socket_all_gid;
74850 +extern int grsec_enable_socket_client;
74851 +extern kgid_t grsec_socket_client_gid;
74852 +extern int grsec_enable_socket_server;
74853 +extern kgid_t grsec_socket_server_gid;
74854 +extern kgid_t grsec_audit_gid;
74855 +extern int grsec_enable_group;
74856 +extern int grsec_enable_log_rwxmaps;
74857 +extern int grsec_enable_mount;
74858 +extern int grsec_enable_chdir;
74859 +extern int grsec_resource_logging;
74860 +extern int grsec_enable_blackhole;
74861 +extern int grsec_lastack_retries;
74862 +extern int grsec_enable_brute;
74863 +extern int grsec_enable_harden_ipc;
74864 +extern int grsec_lock;
74865 +
74866 +extern spinlock_t grsec_alert_lock;
74867 +extern unsigned long grsec_alert_wtime;
74868 +extern unsigned long grsec_alert_fyet;
74869 +
74870 +extern spinlock_t grsec_audit_lock;
74871 +
74872 +extern rwlock_t grsec_exec_file_lock;
74873 +
74874 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
74875 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
74876 + (tsk)->exec_file->f_path.mnt) : "/")
74877 +
74878 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
74879 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
74880 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74881 +
74882 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
74883 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
74884 + (tsk)->exec_file->f_path.mnt) : "/")
74885 +
74886 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
74887 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
74888 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74889 +
74890 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
74891 +
74892 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
74893 +
74894 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
74895 +{
74896 + if (file1 && file2) {
74897 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
74898 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
74899 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
74900 + return true;
74901 + }
74902 +
74903 + return false;
74904 +}
74905 +
74906 +#define GR_CHROOT_CAPS {{ \
74907 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
74908 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74909 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74910 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74911 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74912 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74913 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74914 +
74915 +#define security_learn(normal_msg,args...) \
74916 +({ \
74917 + read_lock(&grsec_exec_file_lock); \
74918 + gr_add_learn_entry(normal_msg "\n", ## args); \
74919 + read_unlock(&grsec_exec_file_lock); \
74920 +})
74921 +
74922 +enum {
74923 + GR_DO_AUDIT,
74924 + GR_DONT_AUDIT,
74925 + /* used for non-audit messages that we shouldn't kill the task on */
74926 + GR_DONT_AUDIT_GOOD
74927 +};
74928 +
74929 +enum {
74930 + GR_TTYSNIFF,
74931 + GR_RBAC,
74932 + GR_RBAC_STR,
74933 + GR_STR_RBAC,
74934 + GR_RBAC_MODE2,
74935 + GR_RBAC_MODE3,
74936 + GR_FILENAME,
74937 + GR_SYSCTL_HIDDEN,
74938 + GR_NOARGS,
74939 + GR_ONE_INT,
74940 + GR_ONE_INT_TWO_STR,
74941 + GR_ONE_STR,
74942 + GR_STR_INT,
74943 + GR_TWO_STR_INT,
74944 + GR_TWO_INT,
74945 + GR_TWO_U64,
74946 + GR_THREE_INT,
74947 + GR_FIVE_INT_TWO_STR,
74948 + GR_TWO_STR,
74949 + GR_THREE_STR,
74950 + GR_FOUR_STR,
74951 + GR_STR_FILENAME,
74952 + GR_FILENAME_STR,
74953 + GR_FILENAME_TWO_INT,
74954 + GR_FILENAME_TWO_INT_STR,
74955 + GR_TEXTREL,
74956 + GR_PTRACE,
74957 + GR_RESOURCE,
74958 + GR_CAP,
74959 + GR_SIG,
74960 + GR_SIG2,
74961 + GR_CRASH1,
74962 + GR_CRASH2,
74963 + GR_PSACCT,
74964 + GR_RWXMAP,
74965 + GR_RWXMAPVMA
74966 +};
74967 +
74968 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74969 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74970 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74971 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74972 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74973 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74974 +#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)
74975 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74976 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74977 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74978 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74979 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74980 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74981 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74982 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74983 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74984 +#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)
74985 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74986 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74987 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74988 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74989 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74990 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74991 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74992 +#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)
74993 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74994 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74995 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74996 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74997 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74998 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74999 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
75000 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
75001 +#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)
75002 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
75003 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
75004 +
75005 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
75006 +
75007 +#endif
75008 +
75009 +#endif
75010 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
75011 new file mode 100644
75012 index 0000000..378a81a
75013 --- /dev/null
75014 +++ b/include/linux/grmsg.h
75015 @@ -0,0 +1,114 @@
75016 +#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"
75017 +#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"
75018 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
75019 +#define GR_STOPMOD_MSG "denied modification of module state by "
75020 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
75021 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
75022 +#define GR_IOPERM_MSG "denied use of ioperm() by "
75023 +#define GR_IOPL_MSG "denied use of iopl() by "
75024 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
75025 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
75026 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
75027 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
75028 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
75029 +#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"
75030 +#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"
75031 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
75032 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
75033 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
75034 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
75035 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
75036 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
75037 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
75038 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
75039 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
75040 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
75041 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
75042 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
75043 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
75044 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
75045 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
75046 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
75047 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
75048 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
75049 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
75050 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
75051 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
75052 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
75053 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
75054 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
75055 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
75056 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
75057 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
75058 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
75059 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
75060 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
75061 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
75062 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
75063 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
75064 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
75065 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
75066 +#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"
75067 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
75068 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
75069 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
75070 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
75071 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
75072 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
75073 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
75074 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
75075 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
75076 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
75077 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
75078 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
75079 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
75080 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
75081 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
75082 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
75083 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
75084 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
75085 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
75086 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
75087 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
75088 +#define GR_NICE_CHROOT_MSG "denied priority change by "
75089 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
75090 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
75091 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
75092 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
75093 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
75094 +#define GR_TIME_MSG "time set by "
75095 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
75096 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
75097 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
75098 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
75099 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
75100 +#define GR_BIND_MSG "denied bind() by "
75101 +#define GR_CONNECT_MSG "denied connect() by "
75102 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
75103 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
75104 +#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"
75105 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
75106 +#define GR_CAP_ACL_MSG "use of %s denied for "
75107 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
75108 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
75109 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
75110 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
75111 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
75112 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
75113 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
75114 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
75115 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
75116 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
75117 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
75118 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
75119 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
75120 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
75121 +#define GR_VM86_MSG "denied use of vm86 by "
75122 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
75123 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
75124 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
75125 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
75126 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
75127 +#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 "
75128 +#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 "
75129 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
75130 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
75131 new file mode 100644
75132 index 0000000..b2edfb1
75133 --- /dev/null
75134 +++ b/include/linux/grsecurity.h
75135 @@ -0,0 +1,243 @@
75136 +#ifndef GR_SECURITY_H
75137 +#define GR_SECURITY_H
75138 +#include <linux/fs.h>
75139 +#include <linux/fs_struct.h>
75140 +#include <linux/binfmts.h>
75141 +#include <linux/gracl.h>
75142 +
75143 +/* notify of brain-dead configs */
75144 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75145 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
75146 +#endif
75147 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
75148 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
75149 +#endif
75150 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
75151 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
75152 +#endif
75153 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
75154 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
75155 +#endif
75156 +
75157 +int gr_handle_new_usb(void);
75158 +
75159 +void gr_handle_brute_attach(unsigned long mm_flags);
75160 +void gr_handle_brute_check(void);
75161 +void gr_handle_kernel_exploit(void);
75162 +
75163 +char gr_roletype_to_char(void);
75164 +
75165 +int gr_acl_enable_at_secure(void);
75166 +
75167 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
75168 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
75169 +
75170 +void gr_del_task_from_ip_table(struct task_struct *p);
75171 +
75172 +int gr_pid_is_chrooted(struct task_struct *p);
75173 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
75174 +int gr_handle_chroot_nice(void);
75175 +int gr_handle_chroot_sysctl(const int op);
75176 +int gr_handle_chroot_setpriority(struct task_struct *p,
75177 + const int niceval);
75178 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
75179 +int gr_handle_chroot_chroot(const struct dentry *dentry,
75180 + const struct vfsmount *mnt);
75181 +void gr_handle_chroot_chdir(const struct path *path);
75182 +int gr_handle_chroot_chmod(const struct dentry *dentry,
75183 + const struct vfsmount *mnt, const int mode);
75184 +int gr_handle_chroot_mknod(const struct dentry *dentry,
75185 + const struct vfsmount *mnt, const int mode);
75186 +int gr_handle_chroot_mount(const struct dentry *dentry,
75187 + const struct vfsmount *mnt,
75188 + const char *dev_name);
75189 +int gr_handle_chroot_pivot(void);
75190 +int gr_handle_chroot_unix(const pid_t pid);
75191 +
75192 +int gr_handle_rawio(const struct inode *inode);
75193 +
75194 +void gr_handle_ioperm(void);
75195 +void gr_handle_iopl(void);
75196 +
75197 +umode_t gr_acl_umask(void);
75198 +
75199 +int gr_tpe_allow(const struct file *file);
75200 +
75201 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
75202 +void gr_clear_chroot_entries(struct task_struct *task);
75203 +
75204 +void gr_log_forkfail(const int retval);
75205 +void gr_log_timechange(void);
75206 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
75207 +void gr_log_chdir(const struct dentry *dentry,
75208 + const struct vfsmount *mnt);
75209 +void gr_log_chroot_exec(const struct dentry *dentry,
75210 + const struct vfsmount *mnt);
75211 +void gr_log_remount(const char *devname, const int retval);
75212 +void gr_log_unmount(const char *devname, const int retval);
75213 +void gr_log_mount(const char *from, const char *to, const int retval);
75214 +void gr_log_textrel(struct vm_area_struct *vma);
75215 +void gr_log_ptgnustack(struct file *file);
75216 +void gr_log_rwxmmap(struct file *file);
75217 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
75218 +
75219 +int gr_handle_follow_link(const struct inode *parent,
75220 + const struct inode *inode,
75221 + const struct dentry *dentry,
75222 + const struct vfsmount *mnt);
75223 +int gr_handle_fifo(const struct dentry *dentry,
75224 + const struct vfsmount *mnt,
75225 + const struct dentry *dir, const int flag,
75226 + const int acc_mode);
75227 +int gr_handle_hardlink(const struct dentry *dentry,
75228 + const struct vfsmount *mnt,
75229 + struct inode *inode,
75230 + const int mode, const struct filename *to);
75231 +
75232 +int gr_is_capable(const int cap);
75233 +int gr_is_capable_nolog(const int cap);
75234 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
75235 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
75236 +
75237 +void gr_copy_label(struct task_struct *tsk);
75238 +void gr_handle_crash(struct task_struct *task, const int sig);
75239 +int gr_handle_signal(const struct task_struct *p, const int sig);
75240 +int gr_check_crash_uid(const kuid_t uid);
75241 +int gr_check_protected_task(const struct task_struct *task);
75242 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
75243 +int gr_acl_handle_mmap(const struct file *file,
75244 + const unsigned long prot);
75245 +int gr_acl_handle_mprotect(const struct file *file,
75246 + const unsigned long prot);
75247 +int gr_check_hidden_task(const struct task_struct *tsk);
75248 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
75249 + const struct vfsmount *mnt);
75250 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
75251 + const struct vfsmount *mnt);
75252 +__u32 gr_acl_handle_access(const struct dentry *dentry,
75253 + const struct vfsmount *mnt, const int fmode);
75254 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
75255 + const struct vfsmount *mnt, umode_t *mode);
75256 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
75257 + const struct vfsmount *mnt);
75258 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
75259 + const struct vfsmount *mnt);
75260 +int gr_handle_ptrace(struct task_struct *task, const long request);
75261 +int gr_handle_proc_ptrace(struct task_struct *task);
75262 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
75263 + const struct vfsmount *mnt);
75264 +int gr_check_crash_exec(const struct file *filp);
75265 +int gr_acl_is_enabled(void);
75266 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
75267 + const kgid_t gid);
75268 +int gr_set_proc_label(const struct dentry *dentry,
75269 + const struct vfsmount *mnt,
75270 + const int unsafe_flags);
75271 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
75272 + const struct vfsmount *mnt);
75273 +__u32 gr_acl_handle_open(const struct dentry *dentry,
75274 + const struct vfsmount *mnt, int acc_mode);
75275 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
75276 + const struct dentry *p_dentry,
75277 + const struct vfsmount *p_mnt,
75278 + int open_flags, int acc_mode, const int imode);
75279 +void gr_handle_create(const struct dentry *dentry,
75280 + const struct vfsmount *mnt);
75281 +void gr_handle_proc_create(const struct dentry *dentry,
75282 + const struct inode *inode);
75283 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
75284 + const struct dentry *parent_dentry,
75285 + const struct vfsmount *parent_mnt,
75286 + const int mode);
75287 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
75288 + const struct dentry *parent_dentry,
75289 + const struct vfsmount *parent_mnt);
75290 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
75291 + const struct vfsmount *mnt);
75292 +void gr_handle_delete(const ino_t ino, const dev_t dev);
75293 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
75294 + const struct vfsmount *mnt);
75295 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
75296 + const struct dentry *parent_dentry,
75297 + const struct vfsmount *parent_mnt,
75298 + const struct filename *from);
75299 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
75300 + const struct dentry *parent_dentry,
75301 + const struct vfsmount *parent_mnt,
75302 + const struct dentry *old_dentry,
75303 + const struct vfsmount *old_mnt, const struct filename *to);
75304 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
75305 +int gr_acl_handle_rename(struct dentry *new_dentry,
75306 + struct dentry *parent_dentry,
75307 + const struct vfsmount *parent_mnt,
75308 + struct dentry *old_dentry,
75309 + struct inode *old_parent_inode,
75310 + struct vfsmount *old_mnt, const struct filename *newname);
75311 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
75312 + struct dentry *old_dentry,
75313 + struct dentry *new_dentry,
75314 + struct vfsmount *mnt, const __u8 replace);
75315 +__u32 gr_check_link(const struct dentry *new_dentry,
75316 + const struct dentry *parent_dentry,
75317 + const struct vfsmount *parent_mnt,
75318 + const struct dentry *old_dentry,
75319 + const struct vfsmount *old_mnt);
75320 +int gr_acl_handle_filldir(const struct file *file, const char *name,
75321 + const unsigned int namelen, const ino_t ino);
75322 +
75323 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
75324 + const struct vfsmount *mnt);
75325 +void gr_acl_handle_exit(void);
75326 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
75327 +int gr_acl_handle_procpidmem(const struct task_struct *task);
75328 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
75329 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
75330 +void gr_audit_ptrace(struct task_struct *task);
75331 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
75332 +void gr_put_exec_file(struct task_struct *task);
75333 +
75334 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
75335 +
75336 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
75337 +extern void gr_learn_resource(const struct task_struct *task, const int res,
75338 + const unsigned long wanted, const int gt);
75339 +#else
75340 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
75341 + const unsigned long wanted, const int gt)
75342 +{
75343 +}
75344 +#endif
75345 +
75346 +#ifdef CONFIG_GRKERNSEC_RESLOG
75347 +extern void gr_log_resource(const struct task_struct *task, const int res,
75348 + const unsigned long wanted, const int gt);
75349 +#else
75350 +static inline void gr_log_resource(const struct task_struct *task, const int res,
75351 + const unsigned long wanted, const int gt)
75352 +{
75353 +}
75354 +#endif
75355 +
75356 +#ifdef CONFIG_GRKERNSEC
75357 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
75358 +void gr_handle_vm86(void);
75359 +void gr_handle_mem_readwrite(u64 from, u64 to);
75360 +
75361 +void gr_log_badprocpid(const char *entry);
75362 +
75363 +extern int grsec_enable_dmesg;
75364 +extern int grsec_disable_privio;
75365 +
75366 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
75367 +extern kgid_t grsec_proc_gid;
75368 +#endif
75369 +
75370 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
75371 +extern int grsec_enable_chroot_findtask;
75372 +#endif
75373 +#ifdef CONFIG_GRKERNSEC_SETXID
75374 +extern int grsec_enable_setxid;
75375 +#endif
75376 +#endif
75377 +
75378 +#endif
75379 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
75380 new file mode 100644
75381 index 0000000..e7ffaaf
75382 --- /dev/null
75383 +++ b/include/linux/grsock.h
75384 @@ -0,0 +1,19 @@
75385 +#ifndef __GRSOCK_H
75386 +#define __GRSOCK_H
75387 +
75388 +extern void gr_attach_curr_ip(const struct sock *sk);
75389 +extern int gr_handle_sock_all(const int family, const int type,
75390 + const int protocol);
75391 +extern int gr_handle_sock_server(const struct sockaddr *sck);
75392 +extern int gr_handle_sock_server_other(const struct sock *sck);
75393 +extern int gr_handle_sock_client(const struct sockaddr *sck);
75394 +extern int gr_search_connect(struct socket * sock,
75395 + struct sockaddr_in * addr);
75396 +extern int gr_search_bind(struct socket * sock,
75397 + struct sockaddr_in * addr);
75398 +extern int gr_search_listen(struct socket * sock);
75399 +extern int gr_search_accept(struct socket * sock);
75400 +extern int gr_search_socket(const int domain, const int type,
75401 + const int protocol);
75402 +
75403 +#endif
75404 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
75405 index 7fb31da..08b5114 100644
75406 --- a/include/linux/highmem.h
75407 +++ b/include/linux/highmem.h
75408 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
75409 kunmap_atomic(kaddr);
75410 }
75411
75412 +static inline void sanitize_highpage(struct page *page)
75413 +{
75414 + void *kaddr;
75415 + unsigned long flags;
75416 +
75417 + local_irq_save(flags);
75418 + kaddr = kmap_atomic(page);
75419 + clear_page(kaddr);
75420 + kunmap_atomic(kaddr);
75421 + local_irq_restore(flags);
75422 +}
75423 +
75424 static inline void zero_user_segments(struct page *page,
75425 unsigned start1, unsigned end1,
75426 unsigned start2, unsigned end2)
75427 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
75428 index 1c7b89a..7dda400 100644
75429 --- a/include/linux/hwmon-sysfs.h
75430 +++ b/include/linux/hwmon-sysfs.h
75431 @@ -25,7 +25,8 @@
75432 struct sensor_device_attribute{
75433 struct device_attribute dev_attr;
75434 int index;
75435 -};
75436 +} __do_const;
75437 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
75438 #define to_sensor_dev_attr(_dev_attr) \
75439 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
75440
75441 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
75442 struct device_attribute dev_attr;
75443 u8 index;
75444 u8 nr;
75445 -};
75446 +} __do_const;
75447 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
75448 #define to_sensor_dev_attr_2(_dev_attr) \
75449 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
75450
75451 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
75452 index 2ab11dc..663a3f2 100644
75453 --- a/include/linux/i2c.h
75454 +++ b/include/linux/i2c.h
75455 @@ -366,6 +366,7 @@ struct i2c_algorithm {
75456 /* To determine what the adapter supports */
75457 u32 (*functionality) (struct i2c_adapter *);
75458 };
75459 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
75460
75461 /**
75462 * struct i2c_bus_recovery_info - I2C bus recovery information
75463 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
75464 index d23c3c2..eb63c81 100644
75465 --- a/include/linux/i2o.h
75466 +++ b/include/linux/i2o.h
75467 @@ -565,7 +565,7 @@ struct i2o_controller {
75468 struct i2o_device *exec; /* Executive */
75469 #if BITS_PER_LONG == 64
75470 spinlock_t context_list_lock; /* lock for context_list */
75471 - atomic_t context_list_counter; /* needed for unique contexts */
75472 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
75473 struct list_head context_list; /* list of context id's
75474 and pointers */
75475 #endif
75476 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
75477 index aff7ad8..3942bbd 100644
75478 --- a/include/linux/if_pppox.h
75479 +++ b/include/linux/if_pppox.h
75480 @@ -76,7 +76,7 @@ struct pppox_proto {
75481 int (*ioctl)(struct socket *sock, unsigned int cmd,
75482 unsigned long arg);
75483 struct module *owner;
75484 -};
75485 +} __do_const;
75486
75487 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
75488 extern void unregister_pppox_proto(int proto_num);
75489 diff --git a/include/linux/init.h b/include/linux/init.h
75490 index f1c27a71..7d6010e 100644
75491 --- a/include/linux/init.h
75492 +++ b/include/linux/init.h
75493 @@ -39,9 +39,17 @@
75494 * Also note, that this data cannot be "const".
75495 */
75496
75497 +#define add_init_latent_entropy __latent_entropy
75498 +
75499 +#ifdef CONFIG_MEMORY_HOTPLUG
75500 +#define add_meminit_latent_entropy
75501 +#else
75502 +#define add_meminit_latent_entropy __latent_entropy
75503 +#endif
75504 +
75505 /* These are for everybody (although not all archs will actually
75506 discard it in modules) */
75507 -#define __init __section(.init.text) __cold notrace
75508 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
75509 #define __initdata __section(.init.data)
75510 #define __initconst __constsection(.init.rodata)
75511 #define __exitdata __section(.exit.data)
75512 @@ -102,7 +110,7 @@
75513 #define __cpuexitconst
75514
75515 /* Used for MEMORY_HOTPLUG */
75516 -#define __meminit __section(.meminit.text) __cold notrace
75517 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
75518 #define __meminitdata __section(.meminit.data)
75519 #define __meminitconst __constsection(.meminit.rodata)
75520 #define __memexit __section(.memexit.text) __exitused __cold notrace
75521 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
75522 index 5cd0f09..c9f67cc 100644
75523 --- a/include/linux/init_task.h
75524 +++ b/include/linux/init_task.h
75525 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
75526
75527 #define INIT_TASK_COMM "swapper"
75528
75529 +#ifdef CONFIG_X86
75530 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
75531 +#else
75532 +#define INIT_TASK_THREAD_INFO
75533 +#endif
75534 +
75535 /*
75536 * INIT_TASK is used to set up the first task table, touch at
75537 * your own risk!. Base=0, limit=0x1fffff (=2MB)
75538 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
75539 RCU_POINTER_INITIALIZER(cred, &init_cred), \
75540 .comm = INIT_TASK_COMM, \
75541 .thread = INIT_THREAD, \
75542 + INIT_TASK_THREAD_INFO \
75543 .fs = &init_fs, \
75544 .files = &init_files, \
75545 .signal = &init_signals, \
75546 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
75547 index 5e865b5..71bd258 100644
75548 --- a/include/linux/interrupt.h
75549 +++ b/include/linux/interrupt.h
75550 @@ -361,7 +361,7 @@ enum
75551 /* map softirq index to softirq name. update 'softirq_to_name' in
75552 * kernel/softirq.c when adding a new softirq.
75553 */
75554 -extern char *softirq_to_name[NR_SOFTIRQS];
75555 +extern const char * const softirq_to_name[NR_SOFTIRQS];
75556
75557 /* softirq mask and active fields moved to irq_cpustat_t in
75558 * asm/hardirq.h to get better cache usage. KAO
75559 @@ -369,12 +369,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
75560
75561 struct softirq_action
75562 {
75563 - void (*action)(struct softirq_action *);
75564 -};
75565 + void (*action)(void);
75566 +} __no_const;
75567
75568 asmlinkage void do_softirq(void);
75569 asmlinkage void __do_softirq(void);
75570 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
75571 +extern void open_softirq(int nr, void (*action)(void));
75572 extern void softirq_init(void);
75573 extern void __raise_softirq_irqoff(unsigned int nr);
75574
75575 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
75576 index 7ea319e..f9e971d 100644
75577 --- a/include/linux/iommu.h
75578 +++ b/include/linux/iommu.h
75579 @@ -129,7 +129,7 @@ struct iommu_ops {
75580 u32 (*domain_get_windows)(struct iommu_domain *domain);
75581
75582 unsigned long pgsize_bitmap;
75583 -};
75584 +} __do_const;
75585
75586 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
75587 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
75588 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
75589 index 89b7c24..382af74 100644
75590 --- a/include/linux/ioport.h
75591 +++ b/include/linux/ioport.h
75592 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
75593 int adjust_resource(struct resource *res, resource_size_t start,
75594 resource_size_t size);
75595 resource_size_t resource_alignment(struct resource *res);
75596 -static inline resource_size_t resource_size(const struct resource *res)
75597 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
75598 {
75599 return res->end - res->start + 1;
75600 }
75601 diff --git a/include/linux/irq.h b/include/linux/irq.h
75602 index 56bb0dc..8ae94d62 100644
75603 --- a/include/linux/irq.h
75604 +++ b/include/linux/irq.h
75605 @@ -333,7 +333,8 @@ struct irq_chip {
75606 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
75607
75608 unsigned long flags;
75609 -};
75610 +} __do_const;
75611 +typedef struct irq_chip __no_const irq_chip_no_const;
75612
75613 /*
75614 * irq_chip specific flags
75615 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
75616 index 0e5d9ec..46acb3a 100644
75617 --- a/include/linux/irqchip/arm-gic.h
75618 +++ b/include/linux/irqchip/arm-gic.h
75619 @@ -59,9 +59,11 @@
75620
75621 #ifndef __ASSEMBLY__
75622
75623 +#include <linux/irq.h>
75624 +
75625 struct device_node;
75626
75627 -extern struct irq_chip gic_arch_extn;
75628 +extern irq_chip_no_const gic_arch_extn;
75629
75630 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
75631 u32 offset, struct device_node *);
75632 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
75633 index d235e88..8ccbe74 100644
75634 --- a/include/linux/jiffies.h
75635 +++ b/include/linux/jiffies.h
75636 @@ -292,14 +292,14 @@ extern unsigned long preset_lpj;
75637 /*
75638 * Convert various time units to each other:
75639 */
75640 -extern unsigned int jiffies_to_msecs(const unsigned long j);
75641 -extern unsigned int jiffies_to_usecs(const unsigned long j);
75642 -extern unsigned long msecs_to_jiffies(const unsigned int m);
75643 -extern unsigned long usecs_to_jiffies(const unsigned int u);
75644 -extern unsigned long timespec_to_jiffies(const struct timespec *value);
75645 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
75646 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
75647 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
75648 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
75649 +extern unsigned long timespec_to_jiffies(const struct timespec *value) __intentional_overflow(-1);
75650 extern void jiffies_to_timespec(const unsigned long jiffies,
75651 struct timespec *value);
75652 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
75653 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
75654 extern void jiffies_to_timeval(const unsigned long jiffies,
75655 struct timeval *value);
75656
75657 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
75658 index 6883e19..e854fcb 100644
75659 --- a/include/linux/kallsyms.h
75660 +++ b/include/linux/kallsyms.h
75661 @@ -15,7 +15,8 @@
75662
75663 struct module;
75664
75665 -#ifdef CONFIG_KALLSYMS
75666 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
75667 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75668 /* Lookup the address for a symbol. Returns 0 if not found. */
75669 unsigned long kallsyms_lookup_name(const char *name);
75670
75671 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
75672 /* Stupid that this does nothing, but I didn't create this mess. */
75673 #define __print_symbol(fmt, addr)
75674 #endif /*CONFIG_KALLSYMS*/
75675 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
75676 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
75677 +extern unsigned long kallsyms_lookup_name(const char *name);
75678 +extern void __print_symbol(const char *fmt, unsigned long address);
75679 +extern int sprint_backtrace(char *buffer, unsigned long address);
75680 +extern int sprint_symbol(char *buffer, unsigned long address);
75681 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
75682 +const char *kallsyms_lookup(unsigned long addr,
75683 + unsigned long *symbolsize,
75684 + unsigned long *offset,
75685 + char **modname, char *namebuf);
75686 +extern int kallsyms_lookup_size_offset(unsigned long addr,
75687 + unsigned long *symbolsize,
75688 + unsigned long *offset);
75689 +#endif
75690
75691 /* This macro allows us to keep printk typechecking */
75692 static __printf(1, 2)
75693 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
75694 index 518a53a..5e28358 100644
75695 --- a/include/linux/key-type.h
75696 +++ b/include/linux/key-type.h
75697 @@ -125,7 +125,7 @@ struct key_type {
75698 /* internal fields */
75699 struct list_head link; /* link in types list */
75700 struct lock_class_key lock_class; /* key->sem lock class */
75701 -};
75702 +} __do_const;
75703
75704 extern struct key_type key_type_keyring;
75705
75706 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
75707 index c6e091b..a940adf 100644
75708 --- a/include/linux/kgdb.h
75709 +++ b/include/linux/kgdb.h
75710 @@ -52,7 +52,7 @@ extern int kgdb_connected;
75711 extern int kgdb_io_module_registered;
75712
75713 extern atomic_t kgdb_setting_breakpoint;
75714 -extern atomic_t kgdb_cpu_doing_single_step;
75715 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
75716
75717 extern struct task_struct *kgdb_usethread;
75718 extern struct task_struct *kgdb_contthread;
75719 @@ -254,7 +254,7 @@ struct kgdb_arch {
75720 void (*correct_hw_break)(void);
75721
75722 void (*enable_nmi)(bool on);
75723 -};
75724 +} __do_const;
75725
75726 /**
75727 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
75728 @@ -279,7 +279,7 @@ struct kgdb_io {
75729 void (*pre_exception) (void);
75730 void (*post_exception) (void);
75731 int is_console;
75732 -};
75733 +} __do_const;
75734
75735 extern struct kgdb_arch arch_kgdb_ops;
75736
75737 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
75738 index 0555cc6..40116ce 100644
75739 --- a/include/linux/kmod.h
75740 +++ b/include/linux/kmod.h
75741 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
75742 * usually useless though. */
75743 extern __printf(2, 3)
75744 int __request_module(bool wait, const char *name, ...);
75745 +extern __printf(3, 4)
75746 +int ___request_module(bool wait, char *param_name, const char *name, ...);
75747 #define request_module(mod...) __request_module(true, mod)
75748 #define request_module_nowait(mod...) __request_module(false, mod)
75749 #define try_then_request_module(x, mod...) \
75750 @@ -57,6 +59,9 @@ struct subprocess_info {
75751 struct work_struct work;
75752 struct completion *complete;
75753 char *path;
75754 +#ifdef CONFIG_GRKERNSEC
75755 + char *origpath;
75756 +#endif
75757 char **argv;
75758 char **envp;
75759 int wait;
75760 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
75761 index de6dcbcc..4735f88 100644
75762 --- a/include/linux/kobject.h
75763 +++ b/include/linux/kobject.h
75764 @@ -115,7 +115,7 @@ struct kobj_type {
75765 struct attribute **default_attrs;
75766 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
75767 const void *(*namespace)(struct kobject *kobj);
75768 -};
75769 +} __do_const;
75770
75771 struct kobj_uevent_env {
75772 char *envp[UEVENT_NUM_ENVP];
75773 @@ -138,6 +138,7 @@ struct kobj_attribute {
75774 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
75775 const char *buf, size_t count);
75776 };
75777 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
75778
75779 extern const struct sysfs_ops kobj_sysfs_ops;
75780
75781 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
75782 index df32d25..fb52e27 100644
75783 --- a/include/linux/kobject_ns.h
75784 +++ b/include/linux/kobject_ns.h
75785 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
75786 const void *(*netlink_ns)(struct sock *sk);
75787 const void *(*initial_ns)(void);
75788 void (*drop_ns)(void *);
75789 -};
75790 +} __do_const;
75791
75792 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
75793 int kobj_ns_type_registered(enum kobj_ns_type type);
75794 diff --git a/include/linux/kref.h b/include/linux/kref.h
75795 index 484604d..0f6c5b6 100644
75796 --- a/include/linux/kref.h
75797 +++ b/include/linux/kref.h
75798 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
75799 static inline int kref_sub(struct kref *kref, unsigned int count,
75800 void (*release)(struct kref *kref))
75801 {
75802 - WARN_ON(release == NULL);
75803 + BUG_ON(release == NULL);
75804
75805 if (atomic_sub_and_test((int) count, &kref->refcount)) {
75806 release(kref);
75807 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
75808 index 0fbbc7a..db081e3 100644
75809 --- a/include/linux/kvm_host.h
75810 +++ b/include/linux/kvm_host.h
75811 @@ -458,7 +458,7 @@ static inline void kvm_irqfd_exit(void)
75812 {
75813 }
75814 #endif
75815 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75816 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75817 struct module *module);
75818 void kvm_exit(void);
75819
75820 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
75821 struct kvm_guest_debug *dbg);
75822 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
75823
75824 -int kvm_arch_init(void *opaque);
75825 +int kvm_arch_init(const void *opaque);
75826 void kvm_arch_exit(void);
75827
75828 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
75829 diff --git a/include/linux/libata.h b/include/linux/libata.h
75830 index 0e23c26..6ad8c33 100644
75831 --- a/include/linux/libata.h
75832 +++ b/include/linux/libata.h
75833 @@ -972,7 +972,7 @@ struct ata_port_operations {
75834 * fields must be pointers.
75835 */
75836 const struct ata_port_operations *inherits;
75837 -};
75838 +} __do_const;
75839
75840 struct ata_port_info {
75841 unsigned long flags;
75842 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
75843 index d3e8ad2..a949f68 100644
75844 --- a/include/linux/linkage.h
75845 +++ b/include/linux/linkage.h
75846 @@ -31,6 +31,7 @@
75847 #endif
75848
75849 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
75850 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
75851 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
75852
75853 /*
75854 diff --git a/include/linux/list.h b/include/linux/list.h
75855 index f4d8a2f..38e6e46 100644
75856 --- a/include/linux/list.h
75857 +++ b/include/linux/list.h
75858 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
75859 extern void list_del(struct list_head *entry);
75860 #endif
75861
75862 +extern void __pax_list_add(struct list_head *new,
75863 + struct list_head *prev,
75864 + struct list_head *next);
75865 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
75866 +{
75867 + __pax_list_add(new, head, head->next);
75868 +}
75869 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
75870 +{
75871 + __pax_list_add(new, head->prev, head);
75872 +}
75873 +extern void pax_list_del(struct list_head *entry);
75874 +
75875 /**
75876 * list_replace - replace old entry by new one
75877 * @old : the element to be replaced
75878 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
75879 INIT_LIST_HEAD(entry);
75880 }
75881
75882 +extern void pax_list_del_init(struct list_head *entry);
75883 +
75884 /**
75885 * list_move - delete from one list and add as another's head
75886 * @list: the entry to move
75887 diff --git a/include/linux/math64.h b/include/linux/math64.h
75888 index 69ed5f5..243ed51 100644
75889 --- a/include/linux/math64.h
75890 +++ b/include/linux/math64.h
75891 @@ -15,7 +15,7 @@
75892 * This is commonly provided by 32bit archs to provide an optimized 64bit
75893 * divide.
75894 */
75895 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75896 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75897 {
75898 *remainder = dividend % divisor;
75899 return dividend / divisor;
75900 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
75901 /**
75902 * div64_u64 - unsigned 64bit divide with 64bit divisor
75903 */
75904 -static inline u64 div64_u64(u64 dividend, u64 divisor)
75905 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
75906 {
75907 return dividend / divisor;
75908 }
75909 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
75910 #define div64_ul(x, y) div_u64((x), (y))
75911
75912 #ifndef div_u64_rem
75913 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75914 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75915 {
75916 *remainder = do_div(dividend, divisor);
75917 return dividend;
75918 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
75919 #endif
75920
75921 #ifndef div64_u64
75922 -extern u64 div64_u64(u64 dividend, u64 divisor);
75923 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
75924 #endif
75925
75926 #ifndef div64_s64
75927 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
75928 * divide.
75929 */
75930 #ifndef div_u64
75931 -static inline u64 div_u64(u64 dividend, u32 divisor)
75932 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75933 {
75934 u32 remainder;
75935 return div_u64_rem(dividend, divisor, &remainder);
75936 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
75937 index da6716b..2e31db3 100644
75938 --- a/include/linux/mempolicy.h
75939 +++ b/include/linux/mempolicy.h
75940 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
75941 }
75942
75943 #define vma_policy(vma) ((vma)->vm_policy)
75944 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
75945 +{
75946 + vma->vm_policy = pol;
75947 +}
75948
75949 static inline void mpol_get(struct mempolicy *pol)
75950 {
75951 @@ -240,6 +244,9 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
75952 }
75953
75954 #define vma_policy(vma) NULL
75955 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
75956 +{
75957 +}
75958
75959 static inline int
75960 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
75961 diff --git a/include/linux/mm.h b/include/linux/mm.h
75962 index 8b6e55e..c4edf39 100644
75963 --- a/include/linux/mm.h
75964 +++ b/include/linux/mm.h
75965 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75966 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75967 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75968 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75969 +
75970 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75971 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75972 +#endif
75973 +
75974 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75975
75976 #ifdef CONFIG_MEM_SOFT_DIRTY
75977 @@ -215,8 +220,8 @@ struct vm_operations_struct {
75978 /* called by access_process_vm when get_user_pages() fails, typically
75979 * for use by special VMAs that can switch between memory and hardware
75980 */
75981 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75982 - void *buf, int len, int write);
75983 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75984 + void *buf, size_t len, int write);
75985 #ifdef CONFIG_NUMA
75986 /*
75987 * set_policy() op must add a reference to any non-NULL @new mempolicy
75988 @@ -246,6 +251,7 @@ struct vm_operations_struct {
75989 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75990 unsigned long size, pgoff_t pgoff);
75991 };
75992 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75993
75994 struct mmu_gather;
75995 struct inode;
75996 @@ -977,8 +983,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75997 unsigned long *pfn);
75998 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75999 unsigned int flags, unsigned long *prot, resource_size_t *phys);
76000 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76001 - void *buf, int len, int write);
76002 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76003 + void *buf, size_t len, int write);
76004
76005 static inline void unmap_shared_mapping_range(struct address_space *mapping,
76006 loff_t const holebegin, loff_t const holelen)
76007 @@ -1017,9 +1023,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
76008 }
76009 #endif
76010
76011 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
76012 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
76013 - void *buf, int len, int write);
76014 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
76015 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
76016 + void *buf, size_t len, int write);
76017
76018 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
76019 unsigned long start, unsigned long nr_pages,
76020 @@ -1051,34 +1057,6 @@ int set_page_dirty(struct page *page);
76021 int set_page_dirty_lock(struct page *page);
76022 int clear_page_dirty_for_io(struct page *page);
76023
76024 -/* Is the vma a continuation of the stack vma above it? */
76025 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
76026 -{
76027 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
76028 -}
76029 -
76030 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
76031 - unsigned long addr)
76032 -{
76033 - return (vma->vm_flags & VM_GROWSDOWN) &&
76034 - (vma->vm_start == addr) &&
76035 - !vma_growsdown(vma->vm_prev, addr);
76036 -}
76037 -
76038 -/* Is the vma a continuation of the stack vma below it? */
76039 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
76040 -{
76041 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
76042 -}
76043 -
76044 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
76045 - unsigned long addr)
76046 -{
76047 - return (vma->vm_flags & VM_GROWSUP) &&
76048 - (vma->vm_end == addr) &&
76049 - !vma_growsup(vma->vm_next, addr);
76050 -}
76051 -
76052 extern pid_t
76053 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
76054
76055 @@ -1178,6 +1156,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
76056 }
76057 #endif
76058
76059 +#ifdef CONFIG_MMU
76060 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
76061 +#else
76062 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
76063 +{
76064 + return __pgprot(0);
76065 +}
76066 +#endif
76067 +
76068 int vma_wants_writenotify(struct vm_area_struct *vma);
76069
76070 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
76071 @@ -1196,8 +1183,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
76072 {
76073 return 0;
76074 }
76075 +
76076 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
76077 + unsigned long address)
76078 +{
76079 + return 0;
76080 +}
76081 #else
76082 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76083 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76084 #endif
76085
76086 #ifdef __PAGETABLE_PMD_FOLDED
76087 @@ -1206,8 +1200,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
76088 {
76089 return 0;
76090 }
76091 +
76092 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
76093 + unsigned long address)
76094 +{
76095 + return 0;
76096 +}
76097 #else
76098 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
76099 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
76100 #endif
76101
76102 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
76103 @@ -1225,11 +1226,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
76104 NULL: pud_offset(pgd, address);
76105 }
76106
76107 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
76108 +{
76109 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
76110 + NULL: pud_offset(pgd, address);
76111 +}
76112 +
76113 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
76114 {
76115 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
76116 NULL: pmd_offset(pud, address);
76117 }
76118 +
76119 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
76120 +{
76121 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
76122 + NULL: pmd_offset(pud, address);
76123 +}
76124 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
76125
76126 #if USE_SPLIT_PTLOCKS
76127 @@ -1517,7 +1530,7 @@ extern int install_special_mapping(struct mm_struct *mm,
76128 unsigned long addr, unsigned long len,
76129 unsigned long flags, struct page **pages);
76130
76131 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
76132 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
76133
76134 extern unsigned long mmap_region(struct file *file, unsigned long addr,
76135 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
76136 @@ -1525,6 +1538,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
76137 unsigned long len, unsigned long prot, unsigned long flags,
76138 unsigned long pgoff, unsigned long *populate);
76139 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
76140 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
76141
76142 #ifdef CONFIG_MMU
76143 extern int __mm_populate(unsigned long addr, unsigned long len,
76144 @@ -1553,10 +1567,11 @@ struct vm_unmapped_area_info {
76145 unsigned long high_limit;
76146 unsigned long align_mask;
76147 unsigned long align_offset;
76148 + unsigned long threadstack_offset;
76149 };
76150
76151 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
76152 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76153 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
76154 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
76155
76156 /*
76157 * Search for an unmapped address range.
76158 @@ -1568,7 +1583,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76159 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
76160 */
76161 static inline unsigned long
76162 -vm_unmapped_area(struct vm_unmapped_area_info *info)
76163 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
76164 {
76165 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
76166 return unmapped_area(info);
76167 @@ -1631,6 +1646,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
76168 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
76169 struct vm_area_struct **pprev);
76170
76171 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
76172 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
76173 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
76174 +
76175 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
76176 NULL if none. Assume start_addr < end_addr. */
76177 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
76178 @@ -1659,15 +1678,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
76179 return vma;
76180 }
76181
76182 -#ifdef CONFIG_MMU
76183 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
76184 -#else
76185 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
76186 -{
76187 - return __pgprot(0);
76188 -}
76189 -#endif
76190 -
76191 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
76192 unsigned long change_prot_numa(struct vm_area_struct *vma,
76193 unsigned long start, unsigned long end);
76194 @@ -1719,6 +1729,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
76195 static inline void vm_stat_account(struct mm_struct *mm,
76196 unsigned long flags, struct file *file, long pages)
76197 {
76198 +
76199 +#ifdef CONFIG_PAX_RANDMMAP
76200 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
76201 +#endif
76202 +
76203 mm->total_vm += pages;
76204 }
76205 #endif /* CONFIG_PROC_FS */
76206 @@ -1800,7 +1815,7 @@ extern int unpoison_memory(unsigned long pfn);
76207 extern int sysctl_memory_failure_early_kill;
76208 extern int sysctl_memory_failure_recovery;
76209 extern void shake_page(struct page *p, int access);
76210 -extern atomic_long_t num_poisoned_pages;
76211 +extern atomic_long_unchecked_t num_poisoned_pages;
76212 extern int soft_offline_page(struct page *page, int flags);
76213
76214 extern void dump_page(struct page *page);
76215 @@ -1837,5 +1852,11 @@ void __init setup_nr_node_ids(void);
76216 static inline void setup_nr_node_ids(void) {}
76217 #endif
76218
76219 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
76220 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
76221 +#else
76222 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
76223 +#endif
76224 +
76225 #endif /* __KERNEL__ */
76226 #endif /* _LINUX_MM_H */
76227 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
76228 index d9851ee..619492d 100644
76229 --- a/include/linux/mm_types.h
76230 +++ b/include/linux/mm_types.h
76231 @@ -289,6 +289,8 @@ struct vm_area_struct {
76232 #ifdef CONFIG_NUMA
76233 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
76234 #endif
76235 +
76236 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
76237 };
76238
76239 struct core_thread {
76240 @@ -436,6 +438,24 @@ struct mm_struct {
76241 int first_nid;
76242 #endif
76243 struct uprobes_state uprobes_state;
76244 +
76245 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76246 + unsigned long pax_flags;
76247 +#endif
76248 +
76249 +#ifdef CONFIG_PAX_DLRESOLVE
76250 + unsigned long call_dl_resolve;
76251 +#endif
76252 +
76253 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
76254 + unsigned long call_syscall;
76255 +#endif
76256 +
76257 +#ifdef CONFIG_PAX_ASLR
76258 + unsigned long delta_mmap; /* randomized offset */
76259 + unsigned long delta_stack; /* randomized offset */
76260 +#endif
76261 +
76262 };
76263
76264 /* first nid will either be a valid NID or one of these values */
76265 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
76266 index c5d5278..f0b68c8 100644
76267 --- a/include/linux/mmiotrace.h
76268 +++ b/include/linux/mmiotrace.h
76269 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
76270 /* Called from ioremap.c */
76271 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
76272 void __iomem *addr);
76273 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
76274 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
76275
76276 /* For anyone to insert markers. Remember trailing newline. */
76277 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
76278 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
76279 {
76280 }
76281
76282 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
76283 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
76284 {
76285 }
76286
76287 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
76288 index bd791e4..8617c34f 100644
76289 --- a/include/linux/mmzone.h
76290 +++ b/include/linux/mmzone.h
76291 @@ -396,7 +396,7 @@ struct zone {
76292 unsigned long flags; /* zone flags, see below */
76293
76294 /* Zone statistics */
76295 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76296 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76297
76298 /*
76299 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
76300 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
76301 index 45e9214..a7227d6 100644
76302 --- a/include/linux/mod_devicetable.h
76303 +++ b/include/linux/mod_devicetable.h
76304 @@ -13,7 +13,7 @@
76305 typedef unsigned long kernel_ulong_t;
76306 #endif
76307
76308 -#define PCI_ANY_ID (~0)
76309 +#define PCI_ANY_ID ((__u16)~0)
76310
76311 struct pci_device_id {
76312 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
76313 @@ -139,7 +139,7 @@ struct usb_device_id {
76314 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
76315 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
76316
76317 -#define HID_ANY_ID (~0)
76318 +#define HID_ANY_ID (~0U)
76319 #define HID_BUS_ANY 0xffff
76320 #define HID_GROUP_ANY 0x0000
76321
76322 @@ -467,7 +467,7 @@ struct dmi_system_id {
76323 const char *ident;
76324 struct dmi_strmatch matches[4];
76325 void *driver_data;
76326 -};
76327 +} __do_const;
76328 /*
76329 * struct dmi_device_id appears during expansion of
76330 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
76331 diff --git a/include/linux/module.h b/include/linux/module.h
76332 index 05f2447..2aee07c 100644
76333 --- a/include/linux/module.h
76334 +++ b/include/linux/module.h
76335 @@ -17,9 +17,11 @@
76336 #include <linux/moduleparam.h>
76337 #include <linux/tracepoint.h>
76338 #include <linux/export.h>
76339 +#include <linux/fs.h>
76340
76341 #include <linux/percpu.h>
76342 #include <asm/module.h>
76343 +#include <asm/pgtable.h>
76344
76345 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
76346 #define MODULE_SIG_STRING "~Module signature appended~\n"
76347 @@ -55,12 +57,13 @@ struct module_attribute {
76348 int (*test)(struct module *);
76349 void (*free)(struct module *);
76350 };
76351 +typedef struct module_attribute __no_const module_attribute_no_const;
76352
76353 struct module_version_attribute {
76354 struct module_attribute mattr;
76355 const char *module_name;
76356 const char *version;
76357 -} __attribute__ ((__aligned__(sizeof(void *))));
76358 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
76359
76360 extern ssize_t __modver_version_show(struct module_attribute *,
76361 struct module_kobject *, char *);
76362 @@ -238,7 +241,7 @@ struct module
76363
76364 /* Sysfs stuff. */
76365 struct module_kobject mkobj;
76366 - struct module_attribute *modinfo_attrs;
76367 + module_attribute_no_const *modinfo_attrs;
76368 const char *version;
76369 const char *srcversion;
76370 struct kobject *holders_dir;
76371 @@ -287,19 +290,16 @@ struct module
76372 int (*init)(void);
76373
76374 /* If this is non-NULL, vfree after init() returns */
76375 - void *module_init;
76376 + void *module_init_rx, *module_init_rw;
76377
76378 /* Here is the actual code + data, vfree'd on unload. */
76379 - void *module_core;
76380 + void *module_core_rx, *module_core_rw;
76381
76382 /* Here are the sizes of the init and core sections */
76383 - unsigned int init_size, core_size;
76384 + unsigned int init_size_rw, core_size_rw;
76385
76386 /* The size of the executable code in each section. */
76387 - unsigned int init_text_size, core_text_size;
76388 -
76389 - /* Size of RO sections of the module (text+rodata) */
76390 - unsigned int init_ro_size, core_ro_size;
76391 + unsigned int init_size_rx, core_size_rx;
76392
76393 /* Arch-specific module values */
76394 struct mod_arch_specific arch;
76395 @@ -355,6 +355,10 @@ struct module
76396 #ifdef CONFIG_EVENT_TRACING
76397 struct ftrace_event_call **trace_events;
76398 unsigned int num_trace_events;
76399 + struct file_operations trace_id;
76400 + struct file_operations trace_enable;
76401 + struct file_operations trace_format;
76402 + struct file_operations trace_filter;
76403 #endif
76404 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
76405 unsigned int num_ftrace_callsites;
76406 @@ -402,16 +406,46 @@ bool is_module_address(unsigned long addr);
76407 bool is_module_percpu_address(unsigned long addr);
76408 bool is_module_text_address(unsigned long addr);
76409
76410 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
76411 +{
76412 +
76413 +#ifdef CONFIG_PAX_KERNEXEC
76414 + if (ktla_ktva(addr) >= (unsigned long)start &&
76415 + ktla_ktva(addr) < (unsigned long)start + size)
76416 + return 1;
76417 +#endif
76418 +
76419 + return ((void *)addr >= start && (void *)addr < start + size);
76420 +}
76421 +
76422 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
76423 +{
76424 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
76425 +}
76426 +
76427 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
76428 +{
76429 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
76430 +}
76431 +
76432 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
76433 +{
76434 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
76435 +}
76436 +
76437 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
76438 +{
76439 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
76440 +}
76441 +
76442 static inline int within_module_core(unsigned long addr, const struct module *mod)
76443 {
76444 - return (unsigned long)mod->module_core <= addr &&
76445 - addr < (unsigned long)mod->module_core + mod->core_size;
76446 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
76447 }
76448
76449 static inline int within_module_init(unsigned long addr, const struct module *mod)
76450 {
76451 - return (unsigned long)mod->module_init <= addr &&
76452 - addr < (unsigned long)mod->module_init + mod->init_size;
76453 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
76454 }
76455
76456 /* Search for module by name: must hold module_mutex. */
76457 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
76458 index 560ca53..ef621ef 100644
76459 --- a/include/linux/moduleloader.h
76460 +++ b/include/linux/moduleloader.h
76461 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
76462 sections. Returns NULL on failure. */
76463 void *module_alloc(unsigned long size);
76464
76465 +#ifdef CONFIG_PAX_KERNEXEC
76466 +void *module_alloc_exec(unsigned long size);
76467 +#else
76468 +#define module_alloc_exec(x) module_alloc(x)
76469 +#endif
76470 +
76471 /* Free memory returned from module_alloc. */
76472 void module_free(struct module *mod, void *module_region);
76473
76474 +#ifdef CONFIG_PAX_KERNEXEC
76475 +void module_free_exec(struct module *mod, void *module_region);
76476 +#else
76477 +#define module_free_exec(x, y) module_free((x), (y))
76478 +#endif
76479 +
76480 /*
76481 * Apply the given relocation to the (simplified) ELF. Return -error
76482 * or 0.
76483 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
76484 unsigned int relsec,
76485 struct module *me)
76486 {
76487 +#ifdef CONFIG_MODULES
76488 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76489 +#endif
76490 return -ENOEXEC;
76491 }
76492 #endif
76493 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
76494 unsigned int relsec,
76495 struct module *me)
76496 {
76497 +#ifdef CONFIG_MODULES
76498 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76499 +#endif
76500 return -ENOEXEC;
76501 }
76502 #endif
76503 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
76504 index c3eb102..073c4a6 100644
76505 --- a/include/linux/moduleparam.h
76506 +++ b/include/linux/moduleparam.h
76507 @@ -295,7 +295,7 @@ static inline void __kernel_param_unlock(void)
76508 * @len is usually just sizeof(string).
76509 */
76510 #define module_param_string(name, string, len, perm) \
76511 - static const struct kparam_string __param_string_##name \
76512 + static const struct kparam_string __param_string_##name __used \
76513 = { len, string }; \
76514 __module_param_call(MODULE_PARAM_PREFIX, name, \
76515 &param_ops_string, \
76516 @@ -434,7 +434,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
76517 */
76518 #define module_param_array_named(name, array, type, nump, perm) \
76519 param_check_##type(name, &(array)[0]); \
76520 - static const struct kparam_array __param_arr_##name \
76521 + static const struct kparam_array __param_arr_##name __used \
76522 = { .max = ARRAY_SIZE(array), .num = nump, \
76523 .ops = &param_ops_##type, \
76524 .elemsize = sizeof(array[0]), .elem = array }; \
76525 diff --git a/include/linux/namei.h b/include/linux/namei.h
76526 index 8e47bc7..c70fd73 100644
76527 --- a/include/linux/namei.h
76528 +++ b/include/linux/namei.h
76529 @@ -19,7 +19,7 @@ struct nameidata {
76530 unsigned seq;
76531 int last_type;
76532 unsigned depth;
76533 - char *saved_names[MAX_NESTED_LINKS + 1];
76534 + const char *saved_names[MAX_NESTED_LINKS + 1];
76535 };
76536
76537 /*
76538 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
76539
76540 extern void nd_jump_link(struct nameidata *nd, struct path *path);
76541
76542 -static inline void nd_set_link(struct nameidata *nd, char *path)
76543 +static inline void nd_set_link(struct nameidata *nd, const char *path)
76544 {
76545 nd->saved_names[nd->depth] = path;
76546 }
76547
76548 -static inline char *nd_get_link(struct nameidata *nd)
76549 +static inline const char *nd_get_link(const struct nameidata *nd)
76550 {
76551 return nd->saved_names[nd->depth];
76552 }
76553 diff --git a/include/linux/net.h b/include/linux/net.h
76554 index 4f27575..fc8a65f 100644
76555 --- a/include/linux/net.h
76556 +++ b/include/linux/net.h
76557 @@ -183,7 +183,7 @@ struct net_proto_family {
76558 int (*create)(struct net *net, struct socket *sock,
76559 int protocol, int kern);
76560 struct module *owner;
76561 -};
76562 +} __do_const;
76563
76564 struct iovec;
76565 struct kvec;
76566 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
76567 index 25f5d2d1..5cf2120 100644
76568 --- a/include/linux/netdevice.h
76569 +++ b/include/linux/netdevice.h
76570 @@ -1098,6 +1098,7 @@ struct net_device_ops {
76571 sa_family_t sa_family,
76572 __be16 port);
76573 };
76574 +typedef struct net_device_ops __no_const net_device_ops_no_const;
76575
76576 /*
76577 * The DEVICE structure.
76578 @@ -1169,7 +1170,7 @@ struct net_device {
76579 int iflink;
76580
76581 struct net_device_stats stats;
76582 - atomic_long_t rx_dropped; /* dropped packets by core network
76583 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
76584 * Do not use this in drivers.
76585 */
76586
76587 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
76588 index 708fe72ab9..77084a3 100644
76589 --- a/include/linux/netfilter.h
76590 +++ b/include/linux/netfilter.h
76591 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
76592 #endif
76593 /* Use the module struct to lock set/get code in place */
76594 struct module *owner;
76595 -};
76596 +} __do_const;
76597
76598 /* Function to register/unregister hook points. */
76599 int nf_register_hook(struct nf_hook_ops *reg);
76600 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
76601 index 9ac9fbd..f92edb4 100644
76602 --- a/include/linux/netfilter/ipset/ip_set.h
76603 +++ b/include/linux/netfilter/ipset/ip_set.h
76604 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
76605 /* Return true if "b" set is the same as "a"
76606 * according to the create set parameters */
76607 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
76608 -};
76609 +} __do_const;
76610
76611 /* The core set type structure */
76612 struct ip_set_type {
76613 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
76614 index cadb740..d7c37c0 100644
76615 --- a/include/linux/netfilter/nfnetlink.h
76616 +++ b/include/linux/netfilter/nfnetlink.h
76617 @@ -16,7 +16,7 @@ struct nfnl_callback {
76618 const struct nlattr * const cda[]);
76619 const struct nla_policy *policy; /* netlink attribute policy */
76620 const u_int16_t attr_count; /* number of nlattr's */
76621 -};
76622 +} __do_const;
76623
76624 struct nfnetlink_subsystem {
76625 const char *name;
76626 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
76627 new file mode 100644
76628 index 0000000..33f4af8
76629 --- /dev/null
76630 +++ b/include/linux/netfilter/xt_gradm.h
76631 @@ -0,0 +1,9 @@
76632 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
76633 +#define _LINUX_NETFILTER_XT_GRADM_H 1
76634 +
76635 +struct xt_gradm_mtinfo {
76636 + __u16 flags;
76637 + __u16 invflags;
76638 +};
76639 +
76640 +#endif
76641 diff --git a/include/linux/nls.h b/include/linux/nls.h
76642 index 5dc635f..35f5e11 100644
76643 --- a/include/linux/nls.h
76644 +++ b/include/linux/nls.h
76645 @@ -31,7 +31,7 @@ struct nls_table {
76646 const unsigned char *charset2upper;
76647 struct module *owner;
76648 struct nls_table *next;
76649 -};
76650 +} __do_const;
76651
76652 /* this value hold the maximum octet of charset */
76653 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
76654 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
76655 index d14a4c3..a078786 100644
76656 --- a/include/linux/notifier.h
76657 +++ b/include/linux/notifier.h
76658 @@ -54,7 +54,8 @@ struct notifier_block {
76659 notifier_fn_t notifier_call;
76660 struct notifier_block __rcu *next;
76661 int priority;
76662 -};
76663 +} __do_const;
76664 +typedef struct notifier_block __no_const notifier_block_no_const;
76665
76666 struct atomic_notifier_head {
76667 spinlock_t lock;
76668 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
76669 index b2a0f15..4d7da32 100644
76670 --- a/include/linux/oprofile.h
76671 +++ b/include/linux/oprofile.h
76672 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
76673 int oprofilefs_create_ro_ulong(struct dentry * root,
76674 char const * name, ulong * val);
76675
76676 -/** Create a file for read-only access to an atomic_t. */
76677 +/** Create a file for read-only access to an atomic_unchecked_t. */
76678 int oprofilefs_create_ro_atomic(struct dentry * root,
76679 - char const * name, atomic_t * val);
76680 + char const * name, atomic_unchecked_t * val);
76681
76682 /** create a directory */
76683 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
76684 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
76685 index 430dd96..544e26e 100644
76686 --- a/include/linux/pci_hotplug.h
76687 +++ b/include/linux/pci_hotplug.h
76688 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
76689 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
76690 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
76691 int (*reset_slot) (struct hotplug_slot *slot, int probe);
76692 -};
76693 +} __do_const;
76694 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
76695
76696 /**
76697 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
76698 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
76699 index c8ba627..24bdfa8 100644
76700 --- a/include/linux/perf_event.h
76701 +++ b/include/linux/perf_event.h
76702 @@ -327,8 +327,8 @@ struct perf_event {
76703
76704 enum perf_event_active_state state;
76705 unsigned int attach_state;
76706 - local64_t count;
76707 - atomic64_t child_count;
76708 + local64_t count; /* PaX: fix it one day */
76709 + atomic64_unchecked_t child_count;
76710
76711 /*
76712 * These are the total time in nanoseconds that the event
76713 @@ -379,8 +379,8 @@ struct perf_event {
76714 * These accumulate total time (in nanoseconds) that children
76715 * events have been enabled and running, respectively.
76716 */
76717 - atomic64_t child_total_time_enabled;
76718 - atomic64_t child_total_time_running;
76719 + atomic64_unchecked_t child_total_time_enabled;
76720 + atomic64_unchecked_t child_total_time_running;
76721
76722 /*
76723 * Protect attach/detach and child_list:
76724 @@ -702,7 +702,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
76725 entry->ip[entry->nr++] = ip;
76726 }
76727
76728 -extern int sysctl_perf_event_paranoid;
76729 +extern int sysctl_perf_event_legitimately_concerned;
76730 extern int sysctl_perf_event_mlock;
76731 extern int sysctl_perf_event_sample_rate;
76732 extern int sysctl_perf_cpu_time_max_percent;
76733 @@ -717,19 +717,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
76734 loff_t *ppos);
76735
76736
76737 +static inline bool perf_paranoid_any(void)
76738 +{
76739 + return sysctl_perf_event_legitimately_concerned > 2;
76740 +}
76741 +
76742 static inline bool perf_paranoid_tracepoint_raw(void)
76743 {
76744 - return sysctl_perf_event_paranoid > -1;
76745 + return sysctl_perf_event_legitimately_concerned > -1;
76746 }
76747
76748 static inline bool perf_paranoid_cpu(void)
76749 {
76750 - return sysctl_perf_event_paranoid > 0;
76751 + return sysctl_perf_event_legitimately_concerned > 0;
76752 }
76753
76754 static inline bool perf_paranoid_kernel(void)
76755 {
76756 - return sysctl_perf_event_paranoid > 1;
76757 + return sysctl_perf_event_legitimately_concerned > 1;
76758 }
76759
76760 extern void perf_event_init(void);
76761 @@ -845,7 +850,7 @@ struct perf_pmu_events_attr {
76762 struct device_attribute attr;
76763 u64 id;
76764 const char *event_str;
76765 -};
76766 +} __do_const;
76767
76768 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
76769 static struct perf_pmu_events_attr _var = { \
76770 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
76771 index b8809fe..ae4ccd0 100644
76772 --- a/include/linux/pipe_fs_i.h
76773 +++ b/include/linux/pipe_fs_i.h
76774 @@ -47,10 +47,10 @@ struct pipe_inode_info {
76775 struct mutex mutex;
76776 wait_queue_head_t wait;
76777 unsigned int nrbufs, curbuf, buffers;
76778 - unsigned int readers;
76779 - unsigned int writers;
76780 - unsigned int files;
76781 - unsigned int waiting_writers;
76782 + atomic_t readers;
76783 + atomic_t writers;
76784 + atomic_t files;
76785 + atomic_t waiting_writers;
76786 unsigned int r_counter;
76787 unsigned int w_counter;
76788 struct page *tmp_page;
76789 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
76790 index 5f28cae..3d23723 100644
76791 --- a/include/linux/platform_data/usb-ehci-s5p.h
76792 +++ b/include/linux/platform_data/usb-ehci-s5p.h
76793 @@ -14,7 +14,7 @@
76794 struct s5p_ehci_platdata {
76795 int (*phy_init)(struct platform_device *pdev, int type);
76796 int (*phy_exit)(struct platform_device *pdev, int type);
76797 -};
76798 +} __no_const;
76799
76800 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
76801
76802 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
76803 index c256c59..8ea94c7 100644
76804 --- a/include/linux/platform_data/usb-ohci-exynos.h
76805 +++ b/include/linux/platform_data/usb-ohci-exynos.h
76806 @@ -14,7 +14,7 @@
76807 struct exynos4_ohci_platdata {
76808 int (*phy_init)(struct platform_device *pdev, int type);
76809 int (*phy_exit)(struct platform_device *pdev, int type);
76810 -};
76811 +} __no_const;
76812
76813 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
76814
76815 diff --git a/include/linux/pm.h b/include/linux/pm.h
76816 index a224c7f..92d8a97 100644
76817 --- a/include/linux/pm.h
76818 +++ b/include/linux/pm.h
76819 @@ -576,6 +576,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
76820 struct dev_pm_domain {
76821 struct dev_pm_ops ops;
76822 };
76823 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
76824
76825 /*
76826 * The PM_EVENT_ messages are also used by drivers implementing the legacy
76827 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
76828 index 7c1d252..c5c773e 100644
76829 --- a/include/linux/pm_domain.h
76830 +++ b/include/linux/pm_domain.h
76831 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
76832
76833 struct gpd_cpu_data {
76834 unsigned int saved_exit_latency;
76835 - struct cpuidle_state *idle_state;
76836 + cpuidle_state_no_const *idle_state;
76837 };
76838
76839 struct generic_pm_domain {
76840 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
76841 index 6fa7cea..7bf6415 100644
76842 --- a/include/linux/pm_runtime.h
76843 +++ b/include/linux/pm_runtime.h
76844 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
76845
76846 static inline void pm_runtime_mark_last_busy(struct device *dev)
76847 {
76848 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
76849 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
76850 }
76851
76852 #else /* !CONFIG_PM_RUNTIME */
76853 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
76854 index 195aafc..49a7bc2 100644
76855 --- a/include/linux/pnp.h
76856 +++ b/include/linux/pnp.h
76857 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
76858 struct pnp_fixup {
76859 char id[7];
76860 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
76861 -};
76862 +} __do_const;
76863
76864 /* config parameters */
76865 #define PNP_CONFIG_NORMAL 0x0001
76866 diff --git a/include/linux/poison.h b/include/linux/poison.h
76867 index 2110a81..13a11bb 100644
76868 --- a/include/linux/poison.h
76869 +++ b/include/linux/poison.h
76870 @@ -19,8 +19,8 @@
76871 * under normal circumstances, used to verify that nobody uses
76872 * non-initialized list entries.
76873 */
76874 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
76875 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
76876 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
76877 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
76878
76879 /********** include/linux/timer.h **********/
76880 /*
76881 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
76882 index d8b187c3..9a9257a 100644
76883 --- a/include/linux/power/smartreflex.h
76884 +++ b/include/linux/power/smartreflex.h
76885 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
76886 int (*notify)(struct omap_sr *sr, u32 status);
76887 u8 notify_flags;
76888 u8 class_type;
76889 -};
76890 +} __do_const;
76891
76892 /**
76893 * struct omap_sr_nvalue_table - Smartreflex n-target value info
76894 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
76895 index 4ea1d37..80f4b33 100644
76896 --- a/include/linux/ppp-comp.h
76897 +++ b/include/linux/ppp-comp.h
76898 @@ -84,7 +84,7 @@ struct compressor {
76899 struct module *owner;
76900 /* Extra skb space needed by the compressor algorithm */
76901 unsigned int comp_extra;
76902 -};
76903 +} __do_const;
76904
76905 /*
76906 * The return value from decompress routine is the length of the
76907 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
76908 index f5d4723..a6ea2fa 100644
76909 --- a/include/linux/preempt.h
76910 +++ b/include/linux/preempt.h
76911 @@ -18,8 +18,13 @@
76912 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76913 #endif
76914
76915 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
76916 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76917 +
76918 #define inc_preempt_count() add_preempt_count(1)
76919 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
76920 #define dec_preempt_count() sub_preempt_count(1)
76921 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
76922
76923 #define preempt_count() (current_thread_info()->preempt_count)
76924
76925 @@ -64,6 +69,12 @@ do { \
76926 barrier(); \
76927 } while (0)
76928
76929 +#define raw_preempt_disable() \
76930 +do { \
76931 + raw_inc_preempt_count(); \
76932 + barrier(); \
76933 +} while (0)
76934 +
76935 #define sched_preempt_enable_no_resched() \
76936 do { \
76937 barrier(); \
76938 @@ -72,6 +83,12 @@ do { \
76939
76940 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
76941
76942 +#define raw_preempt_enable_no_resched() \
76943 +do { \
76944 + barrier(); \
76945 + raw_dec_preempt_count(); \
76946 +} while (0)
76947 +
76948 #define preempt_enable() \
76949 do { \
76950 preempt_enable_no_resched(); \
76951 @@ -116,8 +133,10 @@ do { \
76952 * region.
76953 */
76954 #define preempt_disable() barrier()
76955 +#define raw_preempt_disable() barrier()
76956 #define sched_preempt_enable_no_resched() barrier()
76957 #define preempt_enable_no_resched() barrier()
76958 +#define raw_preempt_enable_no_resched() barrier()
76959 #define preempt_enable() barrier()
76960
76961 #define preempt_disable_notrace() barrier()
76962 diff --git a/include/linux/printk.h b/include/linux/printk.h
76963 index e6131a78..8e9fb61 100644
76964 --- a/include/linux/printk.h
76965 +++ b/include/linux/printk.h
76966 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
76967 void early_printk(const char *s, ...) { }
76968 #endif
76969
76970 +extern int kptr_restrict;
76971 +
76972 #ifdef CONFIG_PRINTK
76973 asmlinkage __printf(5, 0)
76974 int vprintk_emit(int facility, int level,
76975 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
76976
76977 extern int printk_delay_msec;
76978 extern int dmesg_restrict;
76979 -extern int kptr_restrict;
76980
76981 extern void wake_up_klogd(void);
76982
76983 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76984 index 608e60a..c26f864 100644
76985 --- a/include/linux/proc_fs.h
76986 +++ b/include/linux/proc_fs.h
76987 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76988 return proc_create_data(name, mode, parent, proc_fops, NULL);
76989 }
76990
76991 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76992 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76993 +{
76994 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76995 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76996 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76997 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76998 +#else
76999 + return proc_create_data(name, mode, parent, proc_fops, NULL);
77000 +#endif
77001 +}
77002 +
77003 +
77004 extern void proc_set_size(struct proc_dir_entry *, loff_t);
77005 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
77006 extern void *PDE_DATA(const struct inode *);
77007 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
77008 index 34a1e10..03a6d03 100644
77009 --- a/include/linux/proc_ns.h
77010 +++ b/include/linux/proc_ns.h
77011 @@ -14,7 +14,7 @@ struct proc_ns_operations {
77012 void (*put)(void *ns);
77013 int (*install)(struct nsproxy *nsproxy, void *ns);
77014 unsigned int (*inum)(void *ns);
77015 -};
77016 +} __do_const;
77017
77018 struct proc_ns {
77019 void *ns;
77020 diff --git a/include/linux/quota.h b/include/linux/quota.h
77021 index cc7494a..1e27036 100644
77022 --- a/include/linux/quota.h
77023 +++ b/include/linux/quota.h
77024 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
77025
77026 extern bool qid_eq(struct kqid left, struct kqid right);
77027 extern bool qid_lt(struct kqid left, struct kqid right);
77028 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
77029 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
77030 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
77031 extern bool qid_valid(struct kqid qid);
77032
77033 diff --git a/include/linux/random.h b/include/linux/random.h
77034 index 6312dd9..2561947 100644
77035 --- a/include/linux/random.h
77036 +++ b/include/linux/random.h
77037 @@ -10,9 +10,19 @@
77038
77039
77040 extern void add_device_randomness(const void *, unsigned int);
77041 +
77042 +static inline void add_latent_entropy(void)
77043 +{
77044 +
77045 +#ifdef LATENT_ENTROPY_PLUGIN
77046 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77047 +#endif
77048 +
77049 +}
77050 +
77051 extern void add_input_randomness(unsigned int type, unsigned int code,
77052 - unsigned int value);
77053 -extern void add_interrupt_randomness(int irq, int irq_flags);
77054 + unsigned int value) __latent_entropy;
77055 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
77056
77057 extern void get_random_bytes(void *buf, int nbytes);
77058 extern void get_random_bytes_arch(void *buf, int nbytes);
77059 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
77060 u32 prandom_u32_state(struct rnd_state *);
77061 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
77062
77063 +static inline unsigned long pax_get_random_long(void)
77064 +{
77065 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
77066 +}
77067 +
77068 /*
77069 * Handle minimum values for seeds
77070 */
77071 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
77072 index 4106721..132d42c 100644
77073 --- a/include/linux/rculist.h
77074 +++ b/include/linux/rculist.h
77075 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
77076 struct list_head *prev, struct list_head *next);
77077 #endif
77078
77079 +extern void __pax_list_add_rcu(struct list_head *new,
77080 + struct list_head *prev, struct list_head *next);
77081 +
77082 /**
77083 * list_add_rcu - add a new entry to rcu-protected list
77084 * @new: new entry to be added
77085 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
77086 __list_add_rcu(new, head, head->next);
77087 }
77088
77089 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
77090 +{
77091 + __pax_list_add_rcu(new, head, head->next);
77092 +}
77093 +
77094 /**
77095 * list_add_tail_rcu - add a new entry to rcu-protected list
77096 * @new: new entry to be added
77097 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
77098 __list_add_rcu(new, head->prev, head);
77099 }
77100
77101 +static inline void pax_list_add_tail_rcu(struct list_head *new,
77102 + struct list_head *head)
77103 +{
77104 + __pax_list_add_rcu(new, head->prev, head);
77105 +}
77106 +
77107 /**
77108 * list_del_rcu - deletes entry from list without re-initialization
77109 * @entry: the element to delete from the list.
77110 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
77111 entry->prev = LIST_POISON2;
77112 }
77113
77114 +extern void pax_list_del_rcu(struct list_head *entry);
77115 +
77116 /**
77117 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
77118 * @n: the element to delete from the hash list.
77119 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
77120 index 8e00f9f..9449b55 100644
77121 --- a/include/linux/reboot.h
77122 +++ b/include/linux/reboot.h
77123 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
77124 * Architecture-specific implementations of sys_reboot commands.
77125 */
77126
77127 -extern void machine_restart(char *cmd);
77128 -extern void machine_halt(void);
77129 -extern void machine_power_off(void);
77130 +extern void machine_restart(char *cmd) __noreturn;
77131 +extern void machine_halt(void) __noreturn;
77132 +extern void machine_power_off(void) __noreturn;
77133
77134 extern void machine_shutdown(void);
77135 struct pt_regs;
77136 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
77137 */
77138
77139 extern void kernel_restart_prepare(char *cmd);
77140 -extern void kernel_restart(char *cmd);
77141 -extern void kernel_halt(void);
77142 -extern void kernel_power_off(void);
77143 +extern void kernel_restart(char *cmd) __noreturn;
77144 +extern void kernel_halt(void) __noreturn;
77145 +extern void kernel_power_off(void) __noreturn;
77146
77147 extern int C_A_D; /* for sysctl */
77148 void ctrl_alt_del(void);
77149 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
77150 * Emergency restart, callable from an interrupt handler.
77151 */
77152
77153 -extern void emergency_restart(void);
77154 +extern void emergency_restart(void) __noreturn;
77155 #include <asm/emergency-restart.h>
77156
77157 #endif /* _LINUX_REBOOT_H */
77158 diff --git a/include/linux/regset.h b/include/linux/regset.h
77159 index 8e0c9fe..ac4d221 100644
77160 --- a/include/linux/regset.h
77161 +++ b/include/linux/regset.h
77162 @@ -161,7 +161,8 @@ struct user_regset {
77163 unsigned int align;
77164 unsigned int bias;
77165 unsigned int core_note_type;
77166 -};
77167 +} __do_const;
77168 +typedef struct user_regset __no_const user_regset_no_const;
77169
77170 /**
77171 * struct user_regset_view - available regsets
77172 diff --git a/include/linux/relay.h b/include/linux/relay.h
77173 index d7c8359..818daf5 100644
77174 --- a/include/linux/relay.h
77175 +++ b/include/linux/relay.h
77176 @@ -157,7 +157,7 @@ struct rchan_callbacks
77177 * The callback should return 0 if successful, negative if not.
77178 */
77179 int (*remove_buf_file)(struct dentry *dentry);
77180 -};
77181 +} __no_const;
77182
77183 /*
77184 * CONFIG_RELAY kernel API, kernel/relay.c
77185 diff --git a/include/linux/rio.h b/include/linux/rio.h
77186 index b71d573..2f940bd 100644
77187 --- a/include/linux/rio.h
77188 +++ b/include/linux/rio.h
77189 @@ -355,7 +355,7 @@ struct rio_ops {
77190 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
77191 u64 rstart, u32 size, u32 flags);
77192 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
77193 -};
77194 +} __no_const;
77195
77196 #define RIO_RESOURCE_MEM 0x00000100
77197 #define RIO_RESOURCE_DOORBELL 0x00000200
77198 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
77199 index 6dacb93..6174423 100644
77200 --- a/include/linux/rmap.h
77201 +++ b/include/linux/rmap.h
77202 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
77203 void anon_vma_init(void); /* create anon_vma_cachep */
77204 int anon_vma_prepare(struct vm_area_struct *);
77205 void unlink_anon_vmas(struct vm_area_struct *);
77206 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
77207 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
77208 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
77209 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
77210
77211 static inline void anon_vma_merge(struct vm_area_struct *vma,
77212 struct vm_area_struct *next)
77213 diff --git a/include/linux/sched.h b/include/linux/sched.h
77214 index e27baee..aaef421 100644
77215 --- a/include/linux/sched.h
77216 +++ b/include/linux/sched.h
77217 @@ -62,6 +62,7 @@ struct bio_list;
77218 struct fs_struct;
77219 struct perf_event_context;
77220 struct blk_plug;
77221 +struct linux_binprm;
77222
77223 /*
77224 * List of flags we want to share for kernel threads,
77225 @@ -295,7 +296,7 @@ extern char __sched_text_start[], __sched_text_end[];
77226 extern int in_sched_functions(unsigned long addr);
77227
77228 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
77229 -extern signed long schedule_timeout(signed long timeout);
77230 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
77231 extern signed long schedule_timeout_interruptible(signed long timeout);
77232 extern signed long schedule_timeout_killable(signed long timeout);
77233 extern signed long schedule_timeout_uninterruptible(signed long timeout);
77234 @@ -306,6 +307,19 @@ struct nsproxy;
77235 struct user_namespace;
77236
77237 #ifdef CONFIG_MMU
77238 +
77239 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
77240 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
77241 +#else
77242 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
77243 +{
77244 + return 0;
77245 +}
77246 +#endif
77247 +
77248 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
77249 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
77250 +
77251 extern void arch_pick_mmap_layout(struct mm_struct *mm);
77252 extern unsigned long
77253 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
77254 @@ -581,6 +595,17 @@ struct signal_struct {
77255 #ifdef CONFIG_TASKSTATS
77256 struct taskstats *stats;
77257 #endif
77258 +
77259 +#ifdef CONFIG_GRKERNSEC
77260 + u32 curr_ip;
77261 + u32 saved_ip;
77262 + u32 gr_saddr;
77263 + u32 gr_daddr;
77264 + u16 gr_sport;
77265 + u16 gr_dport;
77266 + u8 used_accept:1;
77267 +#endif
77268 +
77269 #ifdef CONFIG_AUDIT
77270 unsigned audit_tty;
77271 unsigned audit_tty_log_passwd;
77272 @@ -661,6 +686,14 @@ struct user_struct {
77273 struct key *session_keyring; /* UID's default session keyring */
77274 #endif
77275
77276 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
77277 + unsigned char kernel_banned;
77278 +#endif
77279 +#ifdef CONFIG_GRKERNSEC_BRUTE
77280 + unsigned char suid_banned;
77281 + unsigned long suid_ban_expires;
77282 +#endif
77283 +
77284 /* Hash table maintenance information */
77285 struct hlist_node uidhash_node;
77286 kuid_t uid;
77287 @@ -1146,8 +1179,8 @@ struct task_struct {
77288 struct list_head thread_group;
77289
77290 struct completion *vfork_done; /* for vfork() */
77291 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
77292 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77293 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
77294 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77295
77296 cputime_t utime, stime, utimescaled, stimescaled;
77297 cputime_t gtime;
77298 @@ -1172,11 +1205,6 @@ struct task_struct {
77299 struct task_cputime cputime_expires;
77300 struct list_head cpu_timers[3];
77301
77302 -/* process credentials */
77303 - const struct cred __rcu *real_cred; /* objective and real subjective task
77304 - * credentials (COW) */
77305 - const struct cred __rcu *cred; /* effective (overridable) subjective task
77306 - * credentials (COW) */
77307 char comm[TASK_COMM_LEN]; /* executable name excluding path
77308 - access with [gs]et_task_comm (which lock
77309 it with task_lock())
77310 @@ -1193,6 +1221,10 @@ struct task_struct {
77311 #endif
77312 /* CPU-specific state of this task */
77313 struct thread_struct thread;
77314 +/* thread_info moved to task_struct */
77315 +#ifdef CONFIG_X86
77316 + struct thread_info tinfo;
77317 +#endif
77318 /* filesystem information */
77319 struct fs_struct *fs;
77320 /* open file information */
77321 @@ -1266,6 +1298,10 @@ struct task_struct {
77322 gfp_t lockdep_reclaim_gfp;
77323 #endif
77324
77325 +/* process credentials */
77326 + const struct cred __rcu *real_cred; /* objective and real subjective task
77327 + * credentials (COW) */
77328 +
77329 /* journalling filesystem info */
77330 void *journal_info;
77331
77332 @@ -1304,6 +1340,10 @@ struct task_struct {
77333 /* cg_list protected by css_set_lock and tsk->alloc_lock */
77334 struct list_head cg_list;
77335 #endif
77336 +
77337 + const struct cred __rcu *cred; /* effective (overridable) subjective task
77338 + * credentials (COW) */
77339 +
77340 #ifdef CONFIG_FUTEX
77341 struct robust_list_head __user *robust_list;
77342 #ifdef CONFIG_COMPAT
77343 @@ -1407,8 +1447,78 @@ struct task_struct {
77344 unsigned int sequential_io;
77345 unsigned int sequential_io_avg;
77346 #endif
77347 +
77348 +#ifdef CONFIG_GRKERNSEC
77349 + /* grsecurity */
77350 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77351 + u64 exec_id;
77352 +#endif
77353 +#ifdef CONFIG_GRKERNSEC_SETXID
77354 + const struct cred *delayed_cred;
77355 +#endif
77356 + struct dentry *gr_chroot_dentry;
77357 + struct acl_subject_label *acl;
77358 + struct acl_subject_label *tmpacl;
77359 + struct acl_role_label *role;
77360 + struct file *exec_file;
77361 + unsigned long brute_expires;
77362 + u16 acl_role_id;
77363 + u8 inherited;
77364 + /* is this the task that authenticated to the special role */
77365 + u8 acl_sp_role;
77366 + u8 is_writable;
77367 + u8 brute;
77368 + u8 gr_is_chrooted;
77369 +#endif
77370 +
77371 };
77372
77373 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
77374 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
77375 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
77376 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
77377 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
77378 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
77379 +
77380 +#ifdef CONFIG_PAX_SOFTMODE
77381 +extern int pax_softmode;
77382 +#endif
77383 +
77384 +extern int pax_check_flags(unsigned long *);
77385 +
77386 +/* if tsk != current then task_lock must be held on it */
77387 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77388 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
77389 +{
77390 + if (likely(tsk->mm))
77391 + return tsk->mm->pax_flags;
77392 + else
77393 + return 0UL;
77394 +}
77395 +
77396 +/* if tsk != current then task_lock must be held on it */
77397 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
77398 +{
77399 + if (likely(tsk->mm)) {
77400 + tsk->mm->pax_flags = flags;
77401 + return 0;
77402 + }
77403 + return -EINVAL;
77404 +}
77405 +#endif
77406 +
77407 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
77408 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
77409 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
77410 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
77411 +#endif
77412 +
77413 +struct path;
77414 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
77415 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
77416 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
77417 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
77418 +
77419 /* Future-safe accessor for struct task_struct's cpus_allowed. */
77420 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
77421
77422 @@ -1467,7 +1577,7 @@ struct pid_namespace;
77423 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
77424 struct pid_namespace *ns);
77425
77426 -static inline pid_t task_pid_nr(struct task_struct *tsk)
77427 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
77428 {
77429 return tsk->pid;
77430 }
77431 @@ -1917,7 +2027,9 @@ void yield(void);
77432 extern struct exec_domain default_exec_domain;
77433
77434 union thread_union {
77435 +#ifndef CONFIG_X86
77436 struct thread_info thread_info;
77437 +#endif
77438 unsigned long stack[THREAD_SIZE/sizeof(long)];
77439 };
77440
77441 @@ -1950,6 +2062,7 @@ extern struct pid_namespace init_pid_ns;
77442 */
77443
77444 extern struct task_struct *find_task_by_vpid(pid_t nr);
77445 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
77446 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
77447 struct pid_namespace *ns);
77448
77449 @@ -2114,7 +2227,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
77450 extern void exit_itimers(struct signal_struct *);
77451 extern void flush_itimer_signals(void);
77452
77453 -extern void do_group_exit(int);
77454 +extern __noreturn void do_group_exit(int);
77455
77456 extern int allow_signal(int);
77457 extern int disallow_signal(int);
77458 @@ -2305,9 +2418,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
77459
77460 #endif
77461
77462 -static inline int object_is_on_stack(void *obj)
77463 +static inline int object_starts_on_stack(void *obj)
77464 {
77465 - void *stack = task_stack_page(current);
77466 + const void *stack = task_stack_page(current);
77467
77468 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
77469 }
77470 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
77471 index bf8086b..962b035 100644
77472 --- a/include/linux/sched/sysctl.h
77473 +++ b/include/linux/sched/sysctl.h
77474 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
77475 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
77476
77477 extern int sysctl_max_map_count;
77478 +extern unsigned long sysctl_heap_stack_gap;
77479
77480 extern unsigned int sysctl_sched_latency;
77481 extern unsigned int sysctl_sched_min_granularity;
77482 diff --git a/include/linux/security.h b/include/linux/security.h
77483 index 9d37e2b..43368e4 100644
77484 --- a/include/linux/security.h
77485 +++ b/include/linux/security.h
77486 @@ -27,6 +27,7 @@
77487 #include <linux/slab.h>
77488 #include <linux/err.h>
77489 #include <linux/string.h>
77490 +#include <linux/grsecurity.h>
77491
77492 struct linux_binprm;
77493 struct cred;
77494 @@ -116,8 +117,6 @@ struct seq_file;
77495
77496 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
77497
77498 -void reset_security_ops(void);
77499 -
77500 #ifdef CONFIG_MMU
77501 extern unsigned long mmap_min_addr;
77502 extern unsigned long dac_mmap_min_addr;
77503 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
77504 index dc368b8..e895209 100644
77505 --- a/include/linux/semaphore.h
77506 +++ b/include/linux/semaphore.h
77507 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
77508 }
77509
77510 extern void down(struct semaphore *sem);
77511 -extern int __must_check down_interruptible(struct semaphore *sem);
77512 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
77513 extern int __must_check down_killable(struct semaphore *sem);
77514 extern int __must_check down_trylock(struct semaphore *sem);
77515 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
77516 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
77517 index 4e32edc..f8f2d18 100644
77518 --- a/include/linux/seq_file.h
77519 +++ b/include/linux/seq_file.h
77520 @@ -26,6 +26,9 @@ struct seq_file {
77521 struct mutex lock;
77522 const struct seq_operations *op;
77523 int poll_event;
77524 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77525 + u64 exec_id;
77526 +#endif
77527 #ifdef CONFIG_USER_NS
77528 struct user_namespace *user_ns;
77529 #endif
77530 @@ -38,6 +41,7 @@ struct seq_operations {
77531 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
77532 int (*show) (struct seq_file *m, void *v);
77533 };
77534 +typedef struct seq_operations __no_const seq_operations_no_const;
77535
77536 #define SEQ_SKIP 1
77537
77538 diff --git a/include/linux/shm.h b/include/linux/shm.h
77539 index 429c199..4d42e38 100644
77540 --- a/include/linux/shm.h
77541 +++ b/include/linux/shm.h
77542 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
77543
77544 /* The task created the shm object. NULL if the task is dead. */
77545 struct task_struct *shm_creator;
77546 +#ifdef CONFIG_GRKERNSEC
77547 + time_t shm_createtime;
77548 + pid_t shm_lapid;
77549 +#endif
77550 };
77551
77552 /* shm_mode upper byte flags */
77553 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
77554 index c2d8933..b2b4ed6 100644
77555 --- a/include/linux/skbuff.h
77556 +++ b/include/linux/skbuff.h
77557 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
77558 extern struct sk_buff *__alloc_skb(unsigned int size,
77559 gfp_t priority, int flags, int node);
77560 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
77561 -static inline struct sk_buff *alloc_skb(unsigned int size,
77562 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
77563 gfp_t priority)
77564 {
77565 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
77566 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
77567 */
77568 static inline int skb_queue_empty(const struct sk_buff_head *list)
77569 {
77570 - return list->next == (struct sk_buff *)list;
77571 + return list->next == (const struct sk_buff *)list;
77572 }
77573
77574 /**
77575 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
77576 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77577 const struct sk_buff *skb)
77578 {
77579 - return skb->next == (struct sk_buff *)list;
77580 + return skb->next == (const struct sk_buff *)list;
77581 }
77582
77583 /**
77584 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77585 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
77586 const struct sk_buff *skb)
77587 {
77588 - return skb->prev == (struct sk_buff *)list;
77589 + return skb->prev == (const struct sk_buff *)list;
77590 }
77591
77592 /**
77593 @@ -1750,7 +1750,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
77594 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
77595 */
77596 #ifndef NET_SKB_PAD
77597 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
77598 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
77599 #endif
77600
77601 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
77602 @@ -2348,7 +2348,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
77603 int noblock, int *err);
77604 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
77605 struct poll_table_struct *wait);
77606 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
77607 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
77608 int offset, struct iovec *to,
77609 int size);
77610 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
77611 @@ -2643,6 +2643,9 @@ static inline void nf_reset(struct sk_buff *skb)
77612 nf_bridge_put(skb->nf_bridge);
77613 skb->nf_bridge = NULL;
77614 #endif
77615 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
77616 + skb->nf_trace = 0;
77617 +#endif
77618 }
77619
77620 static inline void nf_reset_trace(struct sk_buff *skb)
77621 diff --git a/include/linux/slab.h b/include/linux/slab.h
77622 index 74f1058..914b7da 100644
77623 --- a/include/linux/slab.h
77624 +++ b/include/linux/slab.h
77625 @@ -14,15 +14,29 @@
77626 #include <linux/gfp.h>
77627 #include <linux/types.h>
77628 #include <linux/workqueue.h>
77629 -
77630 +#include <linux/err.h>
77631
77632 /*
77633 * Flags to pass to kmem_cache_create().
77634 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
77635 */
77636 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
77637 +
77638 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77639 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
77640 +#else
77641 +#define SLAB_USERCOPY 0x00000000UL
77642 +#endif
77643 +
77644 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
77645 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
77646 +
77647 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77648 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
77649 +#else
77650 +#define SLAB_NO_SANITIZE 0x00000000UL
77651 +#endif
77652 +
77653 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
77654 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
77655 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
77656 @@ -91,10 +105,13 @@
77657 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
77658 * Both make kfree a no-op.
77659 */
77660 -#define ZERO_SIZE_PTR ((void *)16)
77661 +#define ZERO_SIZE_PTR \
77662 +({ \
77663 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
77664 + (void *)(-MAX_ERRNO-1L); \
77665 +})
77666
77667 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
77668 - (unsigned long)ZERO_SIZE_PTR)
77669 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
77670
77671 #include <linux/kmemleak.h>
77672
77673 @@ -135,6 +152,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
77674 void kfree(const void *);
77675 void kzfree(const void *);
77676 size_t ksize(const void *);
77677 +const char *check_heap_object(const void *ptr, unsigned long n);
77678 +bool is_usercopy_object(const void *ptr);
77679
77680 /*
77681 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
77682 @@ -167,7 +186,7 @@ struct kmem_cache {
77683 unsigned int align; /* Alignment as calculated */
77684 unsigned long flags; /* Active flags on the slab */
77685 const char *name; /* Slab name for sysfs */
77686 - int refcount; /* Use counter */
77687 + atomic_t refcount; /* Use counter */
77688 void (*ctor)(void *); /* Called on object slot creation */
77689 struct list_head list; /* List of all slab caches on the system */
77690 };
77691 @@ -241,6 +260,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
77692 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77693 #endif
77694
77695 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77696 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
77697 +#endif
77698 +
77699 /*
77700 * Figure out which kmalloc slab an allocation of a certain size
77701 * belongs to.
77702 @@ -249,7 +272,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77703 * 2 = 120 .. 192 bytes
77704 * n = 2^(n-1) .. 2^n -1
77705 */
77706 -static __always_inline int kmalloc_index(size_t size)
77707 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
77708 {
77709 if (!size)
77710 return 0;
77711 @@ -292,11 +315,11 @@ static __always_inline int kmalloc_index(size_t size)
77712 }
77713 #endif /* !CONFIG_SLOB */
77714
77715 -void *__kmalloc(size_t size, gfp_t flags);
77716 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
77717 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
77718
77719 #ifdef CONFIG_NUMA
77720 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
77721 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
77722 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
77723 #else
77724 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
77725 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
77726 index e9346b4..1494959 100644
77727 --- a/include/linux/slab_def.h
77728 +++ b/include/linux/slab_def.h
77729 @@ -36,7 +36,7 @@ struct kmem_cache {
77730 /* 4) cache creation/removal */
77731 const char *name;
77732 struct list_head list;
77733 - int refcount;
77734 + atomic_t refcount;
77735 int object_size;
77736 int align;
77737
77738 @@ -52,10 +52,14 @@ struct kmem_cache {
77739 unsigned long node_allocs;
77740 unsigned long node_frees;
77741 unsigned long node_overflow;
77742 - atomic_t allochit;
77743 - atomic_t allocmiss;
77744 - atomic_t freehit;
77745 - atomic_t freemiss;
77746 + atomic_unchecked_t allochit;
77747 + atomic_unchecked_t allocmiss;
77748 + atomic_unchecked_t freehit;
77749 + atomic_unchecked_t freemiss;
77750 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77751 + atomic_unchecked_t sanitized;
77752 + atomic_unchecked_t not_sanitized;
77753 +#endif
77754
77755 /*
77756 * If debugging is enabled, then the allocator can add additional
77757 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
77758 index cc0b67e..a0329b1 100644
77759 --- a/include/linux/slub_def.h
77760 +++ b/include/linux/slub_def.h
77761 @@ -74,7 +74,7 @@ struct kmem_cache {
77762 struct kmem_cache_order_objects max;
77763 struct kmem_cache_order_objects min;
77764 gfp_t allocflags; /* gfp flags to use on each alloc */
77765 - int refcount; /* Refcount for slab cache destroy */
77766 + atomic_t refcount; /* Refcount for slab cache destroy */
77767 void (*ctor)(void *);
77768 int inuse; /* Offset to metadata */
77769 int align; /* Alignment */
77770 diff --git a/include/linux/smp.h b/include/linux/smp.h
77771 index 731f523..3340268 100644
77772 --- a/include/linux/smp.h
77773 +++ b/include/linux/smp.h
77774 @@ -186,7 +186,9 @@ static inline void __smp_call_function_single(int cpuid,
77775 #endif
77776
77777 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
77778 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
77779 #define put_cpu() preempt_enable()
77780 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
77781
77782 /*
77783 * Callback to arch code if there's nosmp or maxcpus=0 on the
77784 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
77785 index 54f91d3..be2c379 100644
77786 --- a/include/linux/sock_diag.h
77787 +++ b/include/linux/sock_diag.h
77788 @@ -11,7 +11,7 @@ struct sock;
77789 struct sock_diag_handler {
77790 __u8 family;
77791 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
77792 -};
77793 +} __do_const;
77794
77795 int sock_diag_register(const struct sock_diag_handler *h);
77796 void sock_diag_unregister(const struct sock_diag_handler *h);
77797 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
77798 index 680f9a3..f13aeb0 100644
77799 --- a/include/linux/sonet.h
77800 +++ b/include/linux/sonet.h
77801 @@ -7,7 +7,7 @@
77802 #include <uapi/linux/sonet.h>
77803
77804 struct k_sonet_stats {
77805 -#define __HANDLE_ITEM(i) atomic_t i
77806 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
77807 __SONET_ITEMS
77808 #undef __HANDLE_ITEM
77809 };
77810 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
77811 index 07d8e53..dc934c9 100644
77812 --- a/include/linux/sunrpc/addr.h
77813 +++ b/include/linux/sunrpc/addr.h
77814 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
77815 {
77816 switch (sap->sa_family) {
77817 case AF_INET:
77818 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
77819 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
77820 case AF_INET6:
77821 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
77822 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
77823 }
77824 return 0;
77825 }
77826 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
77827 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
77828 const struct sockaddr *src)
77829 {
77830 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
77831 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
77832 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
77833
77834 dsin->sin_family = ssin->sin_family;
77835 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
77836 if (sa->sa_family != AF_INET6)
77837 return 0;
77838
77839 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
77840 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
77841 }
77842
77843 #endif /* _LINUX_SUNRPC_ADDR_H */
77844 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
77845 index 6740801..c535f27 100644
77846 --- a/include/linux/sunrpc/clnt.h
77847 +++ b/include/linux/sunrpc/clnt.h
77848 @@ -96,7 +96,7 @@ struct rpc_procinfo {
77849 unsigned int p_timer; /* Which RTT timer to use */
77850 u32 p_statidx; /* Which procedure to account */
77851 const char * p_name; /* name of procedure */
77852 -};
77853 +} __do_const;
77854
77855 #ifdef __KERNEL__
77856
77857 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
77858 index 6eecfc2..7ada79d 100644
77859 --- a/include/linux/sunrpc/svc.h
77860 +++ b/include/linux/sunrpc/svc.h
77861 @@ -410,7 +410,7 @@ struct svc_procedure {
77862 unsigned int pc_count; /* call count */
77863 unsigned int pc_cachetype; /* cache info (NFS) */
77864 unsigned int pc_xdrressize; /* maximum size of XDR reply */
77865 -};
77866 +} __do_const;
77867
77868 /*
77869 * Function prototypes.
77870 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
77871 index 0b8e3e6..33e0a01 100644
77872 --- a/include/linux/sunrpc/svc_rdma.h
77873 +++ b/include/linux/sunrpc/svc_rdma.h
77874 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
77875 extern unsigned int svcrdma_max_requests;
77876 extern unsigned int svcrdma_max_req_size;
77877
77878 -extern atomic_t rdma_stat_recv;
77879 -extern atomic_t rdma_stat_read;
77880 -extern atomic_t rdma_stat_write;
77881 -extern atomic_t rdma_stat_sq_starve;
77882 -extern atomic_t rdma_stat_rq_starve;
77883 -extern atomic_t rdma_stat_rq_poll;
77884 -extern atomic_t rdma_stat_rq_prod;
77885 -extern atomic_t rdma_stat_sq_poll;
77886 -extern atomic_t rdma_stat_sq_prod;
77887 +extern atomic_unchecked_t rdma_stat_recv;
77888 +extern atomic_unchecked_t rdma_stat_read;
77889 +extern atomic_unchecked_t rdma_stat_write;
77890 +extern atomic_unchecked_t rdma_stat_sq_starve;
77891 +extern atomic_unchecked_t rdma_stat_rq_starve;
77892 +extern atomic_unchecked_t rdma_stat_rq_poll;
77893 +extern atomic_unchecked_t rdma_stat_rq_prod;
77894 +extern atomic_unchecked_t rdma_stat_sq_poll;
77895 +extern atomic_unchecked_t rdma_stat_sq_prod;
77896
77897 #define RPCRDMA_VERSION 1
77898
77899 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
77900 index 8d71d65..f79586e 100644
77901 --- a/include/linux/sunrpc/svcauth.h
77902 +++ b/include/linux/sunrpc/svcauth.h
77903 @@ -120,7 +120,7 @@ struct auth_ops {
77904 int (*release)(struct svc_rqst *rq);
77905 void (*domain_release)(struct auth_domain *);
77906 int (*set_client)(struct svc_rqst *rq);
77907 -};
77908 +} __do_const;
77909
77910 #define SVC_GARBAGE 1
77911 #define SVC_SYSERR 2
77912 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77913 index a5ffd32..0935dea 100644
77914 --- a/include/linux/swiotlb.h
77915 +++ b/include/linux/swiotlb.h
77916 @@ -60,7 +60,8 @@ extern void
77917
77918 extern void
77919 swiotlb_free_coherent(struct device *hwdev, size_t size,
77920 - void *vaddr, dma_addr_t dma_handle);
77921 + void *vaddr, dma_addr_t dma_handle,
77922 + struct dma_attrs *attrs);
77923
77924 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77925 unsigned long offset, size_t size,
77926 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77927 index 7fac04e..de57300 100644
77928 --- a/include/linux/syscalls.h
77929 +++ b/include/linux/syscalls.h
77930 @@ -97,8 +97,14 @@ struct sigaltstack;
77931 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77932
77933 #define __SC_DECL(t, a) t a
77934 +#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))
77935 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77936 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77937 +#define __SC_LONG(t, a) __typeof( \
77938 + __builtin_choose_expr( \
77939 + sizeof(t) > sizeof(int), \
77940 + (t) 0, \
77941 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77942 + )) a
77943 #define __SC_CAST(t, a) (t) a
77944 #define __SC_ARGS(t, a) a
77945 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77946 @@ -363,11 +369,11 @@ asmlinkage long sys_sync(void);
77947 asmlinkage long sys_fsync(unsigned int fd);
77948 asmlinkage long sys_fdatasync(unsigned int fd);
77949 asmlinkage long sys_bdflush(int func, long data);
77950 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77951 - char __user *type, unsigned long flags,
77952 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77953 + const char __user *type, unsigned long flags,
77954 void __user *data);
77955 -asmlinkage long sys_umount(char __user *name, int flags);
77956 -asmlinkage long sys_oldumount(char __user *name);
77957 +asmlinkage long sys_umount(const char __user *name, int flags);
77958 +asmlinkage long sys_oldumount(const char __user *name);
77959 asmlinkage long sys_truncate(const char __user *path, long length);
77960 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77961 asmlinkage long sys_stat(const char __user *filename,
77962 @@ -579,7 +585,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77963 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77964 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77965 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77966 - struct sockaddr __user *, int);
77967 + struct sockaddr __user *, int) __intentional_overflow(0);
77968 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77969 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77970 unsigned int vlen, unsigned flags);
77971 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77972 index 27b3b0b..e093dd9 100644
77973 --- a/include/linux/syscore_ops.h
77974 +++ b/include/linux/syscore_ops.h
77975 @@ -16,7 +16,7 @@ struct syscore_ops {
77976 int (*suspend)(void);
77977 void (*resume)(void);
77978 void (*shutdown)(void);
77979 -};
77980 +} __do_const;
77981
77982 extern void register_syscore_ops(struct syscore_ops *ops);
77983 extern void unregister_syscore_ops(struct syscore_ops *ops);
77984 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77985 index 14a8ff2..af52bad 100644
77986 --- a/include/linux/sysctl.h
77987 +++ b/include/linux/sysctl.h
77988 @@ -34,13 +34,13 @@ struct ctl_table_root;
77989 struct ctl_table_header;
77990 struct ctl_dir;
77991
77992 -typedef struct ctl_table ctl_table;
77993 -
77994 typedef int proc_handler (struct ctl_table *ctl, int write,
77995 void __user *buffer, size_t *lenp, loff_t *ppos);
77996
77997 extern int proc_dostring(struct ctl_table *, int,
77998 void __user *, size_t *, loff_t *);
77999 +extern int proc_dostring_modpriv(struct ctl_table *, int,
78000 + void __user *, size_t *, loff_t *);
78001 extern int proc_dointvec(struct ctl_table *, int,
78002 void __user *, size_t *, loff_t *);
78003 extern int proc_dointvec_minmax(struct ctl_table *, int,
78004 @@ -115,7 +115,9 @@ struct ctl_table
78005 struct ctl_table_poll *poll;
78006 void *extra1;
78007 void *extra2;
78008 -};
78009 +} __do_const;
78010 +typedef struct ctl_table __no_const ctl_table_no_const;
78011 +typedef struct ctl_table ctl_table;
78012
78013 struct ctl_node {
78014 struct rb_node node;
78015 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
78016 index 11baec7..706f99f 100644
78017 --- a/include/linux/sysfs.h
78018 +++ b/include/linux/sysfs.h
78019 @@ -33,7 +33,8 @@ struct attribute {
78020 struct lock_class_key *key;
78021 struct lock_class_key skey;
78022 #endif
78023 -};
78024 +} __do_const;
78025 +typedef struct attribute __no_const attribute_no_const;
78026
78027 /**
78028 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
78029 @@ -62,7 +63,8 @@ struct attribute_group {
78030 struct attribute *, int);
78031 struct attribute **attrs;
78032 struct bin_attribute **bin_attrs;
78033 -};
78034 +} __do_const;
78035 +typedef struct attribute_group __no_const attribute_group_no_const;
78036
78037 /**
78038 * Use these macros to make defining attributes easier. See include/linux/device.h
78039 @@ -126,7 +128,8 @@ struct bin_attribute {
78040 char *, loff_t, size_t);
78041 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
78042 struct vm_area_struct *vma);
78043 -};
78044 +} __do_const;
78045 +typedef struct bin_attribute __no_const bin_attribute_no_const;
78046
78047 /**
78048 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
78049 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
78050 index 7faf933..9b85a0c 100644
78051 --- a/include/linux/sysrq.h
78052 +++ b/include/linux/sysrq.h
78053 @@ -16,6 +16,7 @@
78054
78055 #include <linux/errno.h>
78056 #include <linux/types.h>
78057 +#include <linux/compiler.h>
78058
78059 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
78060 #define SYSRQ_DEFAULT_ENABLE 1
78061 @@ -36,7 +37,7 @@ struct sysrq_key_op {
78062 char *help_msg;
78063 char *action_msg;
78064 int enable_mask;
78065 -};
78066 +} __do_const;
78067
78068 #ifdef CONFIG_MAGIC_SYSRQ
78069
78070 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
78071 index e7e0473..7989295 100644
78072 --- a/include/linux/thread_info.h
78073 +++ b/include/linux/thread_info.h
78074 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
78075 #error "no set_restore_sigmask() provided and default one won't work"
78076 #endif
78077
78078 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
78079 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
78080 +{
78081 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
78082 + if (!__builtin_constant_p(n))
78083 +#endif
78084 + __check_object_size(ptr, n, to_user);
78085 +}
78086 +
78087 #endif /* __KERNEL__ */
78088
78089 #endif /* _LINUX_THREAD_INFO_H */
78090 diff --git a/include/linux/tty.h b/include/linux/tty.h
78091 index 64f8646..1515fc7 100644
78092 --- a/include/linux/tty.h
78093 +++ b/include/linux/tty.h
78094 @@ -197,7 +197,7 @@ struct tty_port {
78095 const struct tty_port_operations *ops; /* Port operations */
78096 spinlock_t lock; /* Lock protecting tty field */
78097 int blocked_open; /* Waiting to open */
78098 - int count; /* Usage count */
78099 + atomic_t count; /* Usage count */
78100 wait_queue_head_t open_wait; /* Open waiters */
78101 wait_queue_head_t close_wait; /* Close waiters */
78102 wait_queue_head_t delta_msr_wait; /* Modem status change */
78103 @@ -546,7 +546,7 @@ extern int tty_port_open(struct tty_port *port,
78104 struct tty_struct *tty, struct file *filp);
78105 static inline int tty_port_users(struct tty_port *port)
78106 {
78107 - return port->count + port->blocked_open;
78108 + return atomic_read(&port->count) + port->blocked_open;
78109 }
78110
78111 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
78112 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
78113 index 756a609..b302dd6 100644
78114 --- a/include/linux/tty_driver.h
78115 +++ b/include/linux/tty_driver.h
78116 @@ -285,7 +285,7 @@ struct tty_operations {
78117 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
78118 #endif
78119 const struct file_operations *proc_fops;
78120 -};
78121 +} __do_const;
78122
78123 struct tty_driver {
78124 int magic; /* magic number for this structure */
78125 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
78126 index f15c898..207b7d1 100644
78127 --- a/include/linux/tty_ldisc.h
78128 +++ b/include/linux/tty_ldisc.h
78129 @@ -211,7 +211,7 @@ struct tty_ldisc_ops {
78130
78131 struct module *owner;
78132
78133 - int refcount;
78134 + atomic_t refcount;
78135 };
78136
78137 struct tty_ldisc {
78138 diff --git a/include/linux/types.h b/include/linux/types.h
78139 index 4d118ba..c3ee9bf 100644
78140 --- a/include/linux/types.h
78141 +++ b/include/linux/types.h
78142 @@ -176,10 +176,26 @@ typedef struct {
78143 int counter;
78144 } atomic_t;
78145
78146 +#ifdef CONFIG_PAX_REFCOUNT
78147 +typedef struct {
78148 + int counter;
78149 +} atomic_unchecked_t;
78150 +#else
78151 +typedef atomic_t atomic_unchecked_t;
78152 +#endif
78153 +
78154 #ifdef CONFIG_64BIT
78155 typedef struct {
78156 long counter;
78157 } atomic64_t;
78158 +
78159 +#ifdef CONFIG_PAX_REFCOUNT
78160 +typedef struct {
78161 + long counter;
78162 +} atomic64_unchecked_t;
78163 +#else
78164 +typedef atomic64_t atomic64_unchecked_t;
78165 +#endif
78166 #endif
78167
78168 struct list_head {
78169 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
78170 index 5ca0951..ab496a5 100644
78171 --- a/include/linux/uaccess.h
78172 +++ b/include/linux/uaccess.h
78173 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78174 long ret; \
78175 mm_segment_t old_fs = get_fs(); \
78176 \
78177 - set_fs(KERNEL_DS); \
78178 pagefault_disable(); \
78179 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
78180 - pagefault_enable(); \
78181 + set_fs(KERNEL_DS); \
78182 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
78183 set_fs(old_fs); \
78184 + pagefault_enable(); \
78185 ret; \
78186 })
78187
78188 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
78189 index 8e522cbc..aa8572d 100644
78190 --- a/include/linux/uidgid.h
78191 +++ b/include/linux/uidgid.h
78192 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
78193
78194 #endif /* CONFIG_USER_NS */
78195
78196 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
78197 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
78198 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
78199 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
78200 +
78201 #endif /* _LINUX_UIDGID_H */
78202 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
78203 index 99c1b4d..562e6f3 100644
78204 --- a/include/linux/unaligned/access_ok.h
78205 +++ b/include/linux/unaligned/access_ok.h
78206 @@ -4,34 +4,34 @@
78207 #include <linux/kernel.h>
78208 #include <asm/byteorder.h>
78209
78210 -static inline u16 get_unaligned_le16(const void *p)
78211 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
78212 {
78213 - return le16_to_cpup((__le16 *)p);
78214 + return le16_to_cpup((const __le16 *)p);
78215 }
78216
78217 -static inline u32 get_unaligned_le32(const void *p)
78218 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
78219 {
78220 - return le32_to_cpup((__le32 *)p);
78221 + return le32_to_cpup((const __le32 *)p);
78222 }
78223
78224 -static inline u64 get_unaligned_le64(const void *p)
78225 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
78226 {
78227 - return le64_to_cpup((__le64 *)p);
78228 + return le64_to_cpup((const __le64 *)p);
78229 }
78230
78231 -static inline u16 get_unaligned_be16(const void *p)
78232 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
78233 {
78234 - return be16_to_cpup((__be16 *)p);
78235 + return be16_to_cpup((const __be16 *)p);
78236 }
78237
78238 -static inline u32 get_unaligned_be32(const void *p)
78239 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
78240 {
78241 - return be32_to_cpup((__be32 *)p);
78242 + return be32_to_cpup((const __be32 *)p);
78243 }
78244
78245 -static inline u64 get_unaligned_be64(const void *p)
78246 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
78247 {
78248 - return be64_to_cpup((__be64 *)p);
78249 + return be64_to_cpup((const __be64 *)p);
78250 }
78251
78252 static inline void put_unaligned_le16(u16 val, void *p)
78253 diff --git a/include/linux/usb.h b/include/linux/usb.h
78254 index 001629c..7c1cc9b 100644
78255 --- a/include/linux/usb.h
78256 +++ b/include/linux/usb.h
78257 @@ -561,7 +561,7 @@ struct usb_device {
78258 int maxchild;
78259
78260 u32 quirks;
78261 - atomic_t urbnum;
78262 + atomic_unchecked_t urbnum;
78263
78264 unsigned long active_duration;
78265
78266 @@ -1635,7 +1635,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
78267
78268 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
78269 __u8 request, __u8 requesttype, __u16 value, __u16 index,
78270 - void *data, __u16 size, int timeout);
78271 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
78272 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
78273 void *data, int len, int *actual_length, int timeout);
78274 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
78275 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
78276 index e452ba6..78f8e80 100644
78277 --- a/include/linux/usb/renesas_usbhs.h
78278 +++ b/include/linux/usb/renesas_usbhs.h
78279 @@ -39,7 +39,7 @@ enum {
78280 */
78281 struct renesas_usbhs_driver_callback {
78282 int (*notify_hotplug)(struct platform_device *pdev);
78283 -};
78284 +} __no_const;
78285
78286 /*
78287 * callback functions for platform
78288 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
78289 index 6f8fbcf..8259001 100644
78290 --- a/include/linux/vermagic.h
78291 +++ b/include/linux/vermagic.h
78292 @@ -25,9 +25,35 @@
78293 #define MODULE_ARCH_VERMAGIC ""
78294 #endif
78295
78296 +#ifdef CONFIG_PAX_REFCOUNT
78297 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
78298 +#else
78299 +#define MODULE_PAX_REFCOUNT ""
78300 +#endif
78301 +
78302 +#ifdef CONSTIFY_PLUGIN
78303 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
78304 +#else
78305 +#define MODULE_CONSTIFY_PLUGIN ""
78306 +#endif
78307 +
78308 +#ifdef STACKLEAK_PLUGIN
78309 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
78310 +#else
78311 +#define MODULE_STACKLEAK_PLUGIN ""
78312 +#endif
78313 +
78314 +#ifdef CONFIG_GRKERNSEC
78315 +#define MODULE_GRSEC "GRSEC "
78316 +#else
78317 +#define MODULE_GRSEC ""
78318 +#endif
78319 +
78320 #define VERMAGIC_STRING \
78321 UTS_RELEASE " " \
78322 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
78323 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
78324 - MODULE_ARCH_VERMAGIC
78325 + MODULE_ARCH_VERMAGIC \
78326 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
78327 + MODULE_GRSEC
78328
78329 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
78330 index 502073a..a7de024 100644
78331 --- a/include/linux/vga_switcheroo.h
78332 +++ b/include/linux/vga_switcheroo.h
78333 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
78334
78335 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
78336
78337 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
78338 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
78339 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
78340 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
78341 #else
78342
78343 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
78344 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
78345
78346 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
78347
78348 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
78349 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
78350 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
78351 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
78352
78353 #endif
78354 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
78355 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
78356 index 4b8a891..cc929b4 100644
78357 --- a/include/linux/vmalloc.h
78358 +++ b/include/linux/vmalloc.h
78359 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
78360 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
78361 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
78362 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
78363 +
78364 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
78365 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
78366 +#endif
78367 +
78368 /* bits [20..32] reserved for arch specific ioremap internals */
78369
78370 /*
78371 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
78372 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
78373 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
78374 unsigned long start, unsigned long end, gfp_t gfp_mask,
78375 - pgprot_t prot, int node, const void *caller);
78376 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
78377 extern void vfree(const void *addr);
78378
78379 extern void *vmap(struct page **pages, unsigned int count,
78380 @@ -142,7 +147,7 @@ extern void free_vm_area(struct vm_struct *area);
78381
78382 /* for /dev/kmem */
78383 extern long vread(char *buf, char *addr, unsigned long count);
78384 -extern long vwrite(char *buf, char *addr, unsigned long count);
78385 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
78386
78387 /*
78388 * Internals. Dont't use..
78389 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
78390 index e4b9480..b96d5ab 100644
78391 --- a/include/linux/vmstat.h
78392 +++ b/include/linux/vmstat.h
78393 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
78394 /*
78395 * Zone based page accounting with per cpu differentials.
78396 */
78397 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78398 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78399
78400 static inline void zone_page_state_add(long x, struct zone *zone,
78401 enum zone_stat_item item)
78402 {
78403 - atomic_long_add(x, &zone->vm_stat[item]);
78404 - atomic_long_add(x, &vm_stat[item]);
78405 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
78406 + atomic_long_add_unchecked(x, &vm_stat[item]);
78407 }
78408
78409 static inline unsigned long global_page_state(enum zone_stat_item item)
78410 {
78411 - long x = atomic_long_read(&vm_stat[item]);
78412 + long x = atomic_long_read_unchecked(&vm_stat[item]);
78413 #ifdef CONFIG_SMP
78414 if (x < 0)
78415 x = 0;
78416 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
78417 static inline unsigned long zone_page_state(struct zone *zone,
78418 enum zone_stat_item item)
78419 {
78420 - long x = atomic_long_read(&zone->vm_stat[item]);
78421 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78422 #ifdef CONFIG_SMP
78423 if (x < 0)
78424 x = 0;
78425 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
78426 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
78427 enum zone_stat_item item)
78428 {
78429 - long x = atomic_long_read(&zone->vm_stat[item]);
78430 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78431
78432 #ifdef CONFIG_SMP
78433 int cpu;
78434 @@ -220,8 +220,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
78435
78436 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
78437 {
78438 - atomic_long_inc(&zone->vm_stat[item]);
78439 - atomic_long_inc(&vm_stat[item]);
78440 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
78441 + atomic_long_inc_unchecked(&vm_stat[item]);
78442 }
78443
78444 static inline void __inc_zone_page_state(struct page *page,
78445 @@ -232,8 +232,8 @@ static inline void __inc_zone_page_state(struct page *page,
78446
78447 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
78448 {
78449 - atomic_long_dec(&zone->vm_stat[item]);
78450 - atomic_long_dec(&vm_stat[item]);
78451 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
78452 + atomic_long_dec_unchecked(&vm_stat[item]);
78453 }
78454
78455 static inline void __dec_zone_page_state(struct page *page,
78456 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
78457 index 91b0a68..0e9adf6 100644
78458 --- a/include/linux/xattr.h
78459 +++ b/include/linux/xattr.h
78460 @@ -28,7 +28,7 @@ struct xattr_handler {
78461 size_t size, int handler_flags);
78462 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
78463 size_t size, int flags, int handler_flags);
78464 -};
78465 +} __do_const;
78466
78467 struct xattr {
78468 const char *name;
78469 @@ -37,6 +37,9 @@ struct xattr {
78470 };
78471
78472 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
78473 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
78474 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
78475 +#endif
78476 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
78477 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
78478 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
78479 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
78480 index 9c5a6b4..09c9438 100644
78481 --- a/include/linux/zlib.h
78482 +++ b/include/linux/zlib.h
78483 @@ -31,6 +31,7 @@
78484 #define _ZLIB_H
78485
78486 #include <linux/zconf.h>
78487 +#include <linux/compiler.h>
78488
78489 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
78490 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
78491 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
78492
78493 /* basic functions */
78494
78495 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
78496 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
78497 /*
78498 Returns the number of bytes that needs to be allocated for a per-
78499 stream workspace with the specified parameters. A pointer to this
78500 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
78501 index c768c9f..bdcaa5a 100644
78502 --- a/include/media/v4l2-dev.h
78503 +++ b/include/media/v4l2-dev.h
78504 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
78505 int (*mmap) (struct file *, struct vm_area_struct *);
78506 int (*open) (struct file *);
78507 int (*release) (struct file *);
78508 -};
78509 +} __do_const;
78510
78511 /*
78512 * Newer version of video_device, handled by videodev2.c
78513 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
78514 index c9b1593..a572459 100644
78515 --- a/include/media/v4l2-device.h
78516 +++ b/include/media/v4l2-device.h
78517 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
78518 this function returns 0. If the name ends with a digit (e.g. cx18),
78519 then the name will be set to cx18-0 since cx180 looks really odd. */
78520 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
78521 - atomic_t *instance);
78522 + atomic_unchecked_t *instance);
78523
78524 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
78525 Since the parent disappears this ensures that v4l2_dev doesn't have an
78526 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
78527 index 9a36d92..0aafe2a 100644
78528 --- a/include/net/9p/transport.h
78529 +++ b/include/net/9p/transport.h
78530 @@ -60,7 +60,7 @@ struct p9_trans_module {
78531 int (*cancel) (struct p9_client *, struct p9_req_t *req);
78532 int (*zc_request)(struct p9_client *, struct p9_req_t *,
78533 char *, char *, int , int, int, int);
78534 -};
78535 +} __do_const;
78536
78537 void v9fs_register_trans(struct p9_trans_module *m);
78538 void v9fs_unregister_trans(struct p9_trans_module *m);
78539 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
78540 index 1a966af..2767cf6 100644
78541 --- a/include/net/bluetooth/l2cap.h
78542 +++ b/include/net/bluetooth/l2cap.h
78543 @@ -551,7 +551,7 @@ struct l2cap_ops {
78544 void (*defer) (struct l2cap_chan *chan);
78545 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
78546 unsigned long len, int nb);
78547 -};
78548 +} __do_const;
78549
78550 struct l2cap_conn {
78551 struct hci_conn *hcon;
78552 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
78553 index f2ae33d..c457cf0 100644
78554 --- a/include/net/caif/cfctrl.h
78555 +++ b/include/net/caif/cfctrl.h
78556 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
78557 void (*radioset_rsp)(void);
78558 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
78559 struct cflayer *client_layer);
78560 -};
78561 +} __no_const;
78562
78563 /* Link Setup Parameters for CAIF-Links. */
78564 struct cfctrl_link_param {
78565 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
78566 struct cfctrl {
78567 struct cfsrvl serv;
78568 struct cfctrl_rsp res;
78569 - atomic_t req_seq_no;
78570 - atomic_t rsp_seq_no;
78571 + atomic_unchecked_t req_seq_no;
78572 + atomic_unchecked_t rsp_seq_no;
78573 struct list_head list;
78574 /* Protects from simultaneous access to first_req list */
78575 spinlock_t info_list_lock;
78576 diff --git a/include/net/flow.h b/include/net/flow.h
78577 index 628e11b..4c475df 100644
78578 --- a/include/net/flow.h
78579 +++ b/include/net/flow.h
78580 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
78581
78582 extern void flow_cache_flush(void);
78583 extern void flow_cache_flush_deferred(void);
78584 -extern atomic_t flow_cache_genid;
78585 +extern atomic_unchecked_t flow_cache_genid;
78586
78587 #endif
78588 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
78589 index 8e0b6c8..73cf605 100644
78590 --- a/include/net/genetlink.h
78591 +++ b/include/net/genetlink.h
78592 @@ -120,7 +120,7 @@ struct genl_ops {
78593 struct netlink_callback *cb);
78594 int (*done)(struct netlink_callback *cb);
78595 struct list_head ops_list;
78596 -};
78597 +} __do_const;
78598
78599 extern int __genl_register_family(struct genl_family *family);
78600
78601 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
78602 index 734d9b5..48a9a4b 100644
78603 --- a/include/net/gro_cells.h
78604 +++ b/include/net/gro_cells.h
78605 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
78606 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
78607
78608 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
78609 - atomic_long_inc(&dev->rx_dropped);
78610 + atomic_long_inc_unchecked(&dev->rx_dropped);
78611 kfree_skb(skb);
78612 return;
78613 }
78614 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
78615 index de2c785..0588a6b 100644
78616 --- a/include/net/inet_connection_sock.h
78617 +++ b/include/net/inet_connection_sock.h
78618 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
78619 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
78620 int (*bind_conflict)(const struct sock *sk,
78621 const struct inet_bind_bucket *tb, bool relax);
78622 -};
78623 +} __do_const;
78624
78625 /** inet_connection_sock - INET connection oriented sock
78626 *
78627 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
78628 index 53f464d..0bd0b49 100644
78629 --- a/include/net/inetpeer.h
78630 +++ b/include/net/inetpeer.h
78631 @@ -47,8 +47,8 @@ struct inet_peer {
78632 */
78633 union {
78634 struct {
78635 - atomic_t rid; /* Frag reception counter */
78636 - atomic_t ip_id_count; /* IP ID for the next packet */
78637 + atomic_unchecked_t rid; /* Frag reception counter */
78638 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
78639 };
78640 struct rcu_head rcu;
78641 struct inet_peer *gc_next;
78642 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
78643 /* can be called with or without local BH being disabled */
78644 static inline int inet_getid(struct inet_peer *p, int more)
78645 {
78646 - int old, new;
78647 + int id;
78648 more++;
78649 inet_peer_refcheck(p);
78650 - do {
78651 - old = atomic_read(&p->ip_id_count);
78652 - new = old + more;
78653 - if (!new)
78654 - new = 1;
78655 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
78656 - return new;
78657 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
78658 + if (!id)
78659 + id = atomic_inc_return_unchecked(&p->ip_id_count);
78660 + return id;
78661 }
78662
78663 #endif /* _NET_INETPEER_H */
78664 diff --git a/include/net/ip.h b/include/net/ip.h
78665 index 5e52688..f181e95 100644
78666 --- a/include/net/ip.h
78667 +++ b/include/net/ip.h
78668 @@ -212,7 +212,7 @@ extern struct local_ports {
78669 } sysctl_local_ports;
78670 extern void inet_get_local_port_range(int *low, int *high);
78671
78672 -extern unsigned long *sysctl_local_reserved_ports;
78673 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
78674 static inline int inet_is_reserved_local_port(int port)
78675 {
78676 return test_bit(port, sysctl_local_reserved_ports);
78677 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
78678 index cbf2be3..3683f6d 100644
78679 --- a/include/net/ip_fib.h
78680 +++ b/include/net/ip_fib.h
78681 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
78682
78683 #define FIB_RES_SADDR(net, res) \
78684 ((FIB_RES_NH(res).nh_saddr_genid == \
78685 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
78686 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
78687 FIB_RES_NH(res).nh_saddr : \
78688 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
78689 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
78690 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
78691 index 9c4d37e..eed6d41 100644
78692 --- a/include/net/ip_vs.h
78693 +++ b/include/net/ip_vs.h
78694 @@ -588,7 +588,7 @@ struct ip_vs_conn {
78695 struct ip_vs_conn *control; /* Master control connection */
78696 atomic_t n_control; /* Number of controlled ones */
78697 struct ip_vs_dest *dest; /* real server */
78698 - atomic_t in_pkts; /* incoming packet counter */
78699 + atomic_unchecked_t in_pkts; /* incoming packet counter */
78700
78701 /* packet transmitter for different forwarding methods. If it
78702 mangles the packet, it must return NF_DROP or better NF_STOLEN,
78703 @@ -735,7 +735,7 @@ struct ip_vs_dest {
78704 __be16 port; /* port number of the server */
78705 union nf_inet_addr addr; /* IP address of the server */
78706 volatile unsigned int flags; /* dest status flags */
78707 - atomic_t conn_flags; /* flags to copy to conn */
78708 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
78709 atomic_t weight; /* server weight */
78710
78711 atomic_t refcnt; /* reference counter */
78712 @@ -990,11 +990,11 @@ struct netns_ipvs {
78713 /* ip_vs_lblc */
78714 int sysctl_lblc_expiration;
78715 struct ctl_table_header *lblc_ctl_header;
78716 - struct ctl_table *lblc_ctl_table;
78717 + ctl_table_no_const *lblc_ctl_table;
78718 /* ip_vs_lblcr */
78719 int sysctl_lblcr_expiration;
78720 struct ctl_table_header *lblcr_ctl_header;
78721 - struct ctl_table *lblcr_ctl_table;
78722 + ctl_table_no_const *lblcr_ctl_table;
78723 /* ip_vs_est */
78724 struct list_head est_list; /* estimator list */
78725 spinlock_t est_lock;
78726 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
78727 index 80ffde3..968b0f4 100644
78728 --- a/include/net/irda/ircomm_tty.h
78729 +++ b/include/net/irda/ircomm_tty.h
78730 @@ -35,6 +35,7 @@
78731 #include <linux/termios.h>
78732 #include <linux/timer.h>
78733 #include <linux/tty.h> /* struct tty_struct */
78734 +#include <asm/local.h>
78735
78736 #include <net/irda/irias_object.h>
78737 #include <net/irda/ircomm_core.h>
78738 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
78739 index 714cc9a..ea05f3e 100644
78740 --- a/include/net/iucv/af_iucv.h
78741 +++ b/include/net/iucv/af_iucv.h
78742 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
78743 struct iucv_sock_list {
78744 struct hlist_head head;
78745 rwlock_t lock;
78746 - atomic_t autobind_name;
78747 + atomic_unchecked_t autobind_name;
78748 };
78749
78750 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
78751 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
78752 index df83f69..9b640b8 100644
78753 --- a/include/net/llc_c_ac.h
78754 +++ b/include/net/llc_c_ac.h
78755 @@ -87,7 +87,7 @@
78756 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
78757 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
78758
78759 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78760 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78761
78762 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
78763 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
78764 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
78765 index 6ca3113..f8026dd 100644
78766 --- a/include/net/llc_c_ev.h
78767 +++ b/include/net/llc_c_ev.h
78768 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
78769 return (struct llc_conn_state_ev *)skb->cb;
78770 }
78771
78772 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78773 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78774 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78775 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78776
78777 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
78778 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
78779 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
78780 index 0e79cfb..f46db31 100644
78781 --- a/include/net/llc_c_st.h
78782 +++ b/include/net/llc_c_st.h
78783 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
78784 u8 next_state;
78785 llc_conn_ev_qfyr_t *ev_qualifiers;
78786 llc_conn_action_t *ev_actions;
78787 -};
78788 +} __do_const;
78789
78790 struct llc_conn_state {
78791 u8 current_state;
78792 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
78793 index 37a3bbd..55a4241 100644
78794 --- a/include/net/llc_s_ac.h
78795 +++ b/include/net/llc_s_ac.h
78796 @@ -23,7 +23,7 @@
78797 #define SAP_ACT_TEST_IND 9
78798
78799 /* All action functions must look like this */
78800 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78801 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78802
78803 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
78804 struct sk_buff *skb);
78805 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
78806 index 567c681..cd73ac0 100644
78807 --- a/include/net/llc_s_st.h
78808 +++ b/include/net/llc_s_st.h
78809 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
78810 llc_sap_ev_t ev;
78811 u8 next_state;
78812 llc_sap_action_t *ev_actions;
78813 -};
78814 +} __do_const;
78815
78816 struct llc_sap_state {
78817 u8 curr_state;
78818 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
78819 index cc6035f..a8406fc 100644
78820 --- a/include/net/mac80211.h
78821 +++ b/include/net/mac80211.h
78822 @@ -4361,7 +4361,7 @@ struct rate_control_ops {
78823 void (*add_sta_debugfs)(void *priv, void *priv_sta,
78824 struct dentry *dir);
78825 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
78826 -};
78827 +} __do_const;
78828
78829 static inline int rate_supported(struct ieee80211_sta *sta,
78830 enum ieee80211_band band,
78831 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
78832 index 536501a..7c6193c 100644
78833 --- a/include/net/neighbour.h
78834 +++ b/include/net/neighbour.h
78835 @@ -123,7 +123,7 @@ struct neigh_ops {
78836 void (*error_report)(struct neighbour *, struct sk_buff *);
78837 int (*output)(struct neighbour *, struct sk_buff *);
78838 int (*connected_output)(struct neighbour *, struct sk_buff *);
78839 -};
78840 +} __do_const;
78841
78842 struct pneigh_entry {
78843 struct pneigh_entry *next;
78844 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
78845 index 9d22f08..980fbf8 100644
78846 --- a/include/net/net_namespace.h
78847 +++ b/include/net/net_namespace.h
78848 @@ -120,7 +120,7 @@ struct net {
78849 struct netns_ipvs *ipvs;
78850 #endif
78851 struct sock *diag_nlsk;
78852 - atomic_t fnhe_genid;
78853 + atomic_unchecked_t fnhe_genid;
78854 };
78855
78856 /*
78857 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
78858 #define __net_init __init
78859 #define __net_exit __exit_refok
78860 #define __net_initdata __initdata
78861 +#ifdef CONSTIFY_PLUGIN
78862 #define __net_initconst __initconst
78863 +#else
78864 +#define __net_initconst __initdata
78865 +#endif
78866 #endif
78867
78868 struct pernet_operations {
78869 @@ -287,7 +291,7 @@ struct pernet_operations {
78870 void (*exit_batch)(struct list_head *net_exit_list);
78871 int *id;
78872 size_t size;
78873 -};
78874 +} __do_const;
78875
78876 /*
78877 * Use these carefully. If you implement a network device and it
78878 @@ -335,23 +339,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
78879
78880 static inline int rt_genid_ipv4(struct net *net)
78881 {
78882 - return atomic_read(&net->ipv4.rt_genid);
78883 + return atomic_read_unchecked(&net->ipv4.rt_genid);
78884 }
78885
78886 static inline void rt_genid_bump_ipv4(struct net *net)
78887 {
78888 - atomic_inc(&net->ipv4.rt_genid);
78889 + atomic_inc_unchecked(&net->ipv4.rt_genid);
78890 }
78891
78892 #if IS_ENABLED(CONFIG_IPV6)
78893 static inline int rt_genid_ipv6(struct net *net)
78894 {
78895 - return atomic_read(&net->ipv6.rt_genid);
78896 + return atomic_read_unchecked(&net->ipv6.rt_genid);
78897 }
78898
78899 static inline void rt_genid_bump_ipv6(struct net *net)
78900 {
78901 - atomic_inc(&net->ipv6.rt_genid);
78902 + atomic_inc_unchecked(&net->ipv6.rt_genid);
78903 }
78904 #else
78905 static inline int rt_genid_ipv6(struct net *net)
78906 @@ -373,12 +377,12 @@ static inline void rt_genid_bump_all(struct net *net)
78907
78908 static inline int fnhe_genid(struct net *net)
78909 {
78910 - return atomic_read(&net->fnhe_genid);
78911 + return atomic_read_unchecked(&net->fnhe_genid);
78912 }
78913
78914 static inline void fnhe_genid_bump(struct net *net)
78915 {
78916 - atomic_inc(&net->fnhe_genid);
78917 + atomic_inc_unchecked(&net->fnhe_genid);
78918 }
78919
78920 #endif /* __NET_NET_NAMESPACE_H */
78921 diff --git a/include/net/netdma.h b/include/net/netdma.h
78922 index 8ba8ce2..99b7fff 100644
78923 --- a/include/net/netdma.h
78924 +++ b/include/net/netdma.h
78925 @@ -24,7 +24,7 @@
78926 #include <linux/dmaengine.h>
78927 #include <linux/skbuff.h>
78928
78929 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78930 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78931 struct sk_buff *skb, int offset, struct iovec *to,
78932 size_t len, struct dma_pinned_list *pinned_list);
78933
78934 diff --git a/include/net/netlink.h b/include/net/netlink.h
78935 index 9690b0f..87aded7 100644
78936 --- a/include/net/netlink.h
78937 +++ b/include/net/netlink.h
78938 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78939 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78940 {
78941 if (mark)
78942 - skb_trim(skb, (unsigned char *) mark - skb->data);
78943 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78944 }
78945
78946 /**
78947 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78948 index c9c0c53..53f24c3 100644
78949 --- a/include/net/netns/conntrack.h
78950 +++ b/include/net/netns/conntrack.h
78951 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78952 struct nf_proto_net {
78953 #ifdef CONFIG_SYSCTL
78954 struct ctl_table_header *ctl_table_header;
78955 - struct ctl_table *ctl_table;
78956 + ctl_table_no_const *ctl_table;
78957 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78958 struct ctl_table_header *ctl_compat_header;
78959 - struct ctl_table *ctl_compat_table;
78960 + ctl_table_no_const *ctl_compat_table;
78961 #endif
78962 #endif
78963 unsigned int users;
78964 @@ -58,7 +58,7 @@ struct nf_ip_net {
78965 struct nf_icmp_net icmpv6;
78966 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78967 struct ctl_table_header *ctl_table_header;
78968 - struct ctl_table *ctl_table;
78969 + ctl_table_no_const *ctl_table;
78970 #endif
78971 };
78972
78973 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78974 index bf2ec22..5e7f9d9 100644
78975 --- a/include/net/netns/ipv4.h
78976 +++ b/include/net/netns/ipv4.h
78977 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78978 kgid_t sysctl_ping_group_range[2];
78979 long sysctl_tcp_mem[3];
78980
78981 - atomic_t dev_addr_genid;
78982 + atomic_unchecked_t dev_addr_genid;
78983
78984 #ifdef CONFIG_IP_MROUTE
78985 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78986 @@ -77,6 +77,6 @@ struct netns_ipv4 {
78987 struct fib_rules_ops *mr_rules_ops;
78988 #endif
78989 #endif
78990 - atomic_t rt_genid;
78991 + atomic_unchecked_t rt_genid;
78992 };
78993 #endif
78994 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78995 index 0fb2401..477d81c 100644
78996 --- a/include/net/netns/ipv6.h
78997 +++ b/include/net/netns/ipv6.h
78998 @@ -71,8 +71,8 @@ struct netns_ipv6 {
78999 struct fib_rules_ops *mr6_rules_ops;
79000 #endif
79001 #endif
79002 - atomic_t dev_addr_genid;
79003 - atomic_t rt_genid;
79004 + atomic_unchecked_t dev_addr_genid;
79005 + atomic_unchecked_t rt_genid;
79006 };
79007
79008 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
79009 diff --git a/include/net/ping.h b/include/net/ping.h
79010 index 5db0224..0d65365 100644
79011 --- a/include/net/ping.h
79012 +++ b/include/net/ping.h
79013 @@ -55,7 +55,7 @@ struct ping_iter_state {
79014 extern struct proto ping_prot;
79015 extern struct ping_table ping_table;
79016 #if IS_ENABLED(CONFIG_IPV6)
79017 -extern struct pingv6_ops pingv6_ops;
79018 +extern struct pingv6_ops *pingv6_ops;
79019 #endif
79020
79021 struct pingfakehdr {
79022 diff --git a/include/net/protocol.h b/include/net/protocol.h
79023 index 047c047..b9dad15 100644
79024 --- a/include/net/protocol.h
79025 +++ b/include/net/protocol.h
79026 @@ -44,7 +44,7 @@ struct net_protocol {
79027 void (*err_handler)(struct sk_buff *skb, u32 info);
79028 unsigned int no_policy:1,
79029 netns_ok:1;
79030 -};
79031 +} __do_const;
79032
79033 #if IS_ENABLED(CONFIG_IPV6)
79034 struct inet6_protocol {
79035 @@ -57,7 +57,7 @@ struct inet6_protocol {
79036 u8 type, u8 code, int offset,
79037 __be32 info);
79038 unsigned int flags; /* INET6_PROTO_xxx */
79039 -};
79040 +} __do_const;
79041
79042 #define INET6_PROTO_NOPOLICY 0x1
79043 #define INET6_PROTO_FINAL 0x2
79044 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
79045 index 7026648..584cc8c 100644
79046 --- a/include/net/rtnetlink.h
79047 +++ b/include/net/rtnetlink.h
79048 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
79049 const struct net_device *dev);
79050 unsigned int (*get_num_tx_queues)(void);
79051 unsigned int (*get_num_rx_queues)(void);
79052 -};
79053 +} __do_const;
79054
79055 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
79056 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
79057 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
79058 index 4ef75af..5aa073a 100644
79059 --- a/include/net/sctp/sm.h
79060 +++ b/include/net/sctp/sm.h
79061 @@ -81,7 +81,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
79062 typedef struct {
79063 sctp_state_fn_t *fn;
79064 const char *name;
79065 -} sctp_sm_table_entry_t;
79066 +} __do_const sctp_sm_table_entry_t;
79067
79068 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
79069 * currently in use.
79070 @@ -293,7 +293,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
79071 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
79072
79073 /* Extern declarations for major data structures. */
79074 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79075 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79076
79077
79078 /* Get the size of a DATA chunk payload. */
79079 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
79080 index 2174d8d..71d5257 100644
79081 --- a/include/net/sctp/structs.h
79082 +++ b/include/net/sctp/structs.h
79083 @@ -508,7 +508,7 @@ struct sctp_pf {
79084 struct sctp_association *asoc);
79085 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
79086 struct sctp_af *af;
79087 -};
79088 +} __do_const;
79089
79090
79091 /* Structure to track chunk fragments that have been acked, but peer
79092 diff --git a/include/net/sock.h b/include/net/sock.h
79093 index 808cbc2..f6f6ac3 100644
79094 --- a/include/net/sock.h
79095 +++ b/include/net/sock.h
79096 @@ -332,7 +332,7 @@ struct sock {
79097 unsigned int sk_napi_id;
79098 unsigned int sk_ll_usec;
79099 #endif
79100 - atomic_t sk_drops;
79101 + atomic_unchecked_t sk_drops;
79102 int sk_rcvbuf;
79103
79104 struct sk_filter __rcu *sk_filter;
79105 @@ -1821,7 +1821,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
79106 }
79107
79108 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
79109 - char __user *from, char *to,
79110 + char __user *from, unsigned char *to,
79111 int copy, int offset)
79112 {
79113 if (skb->ip_summed == CHECKSUM_NONE) {
79114 @@ -2083,7 +2083,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
79115 }
79116 }
79117
79118 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79119 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79120
79121 /**
79122 * sk_page_frag - return an appropriate page_frag
79123 diff --git a/include/net/tcp.h b/include/net/tcp.h
79124 index b1aa324..b8530ea 100644
79125 --- a/include/net/tcp.h
79126 +++ b/include/net/tcp.h
79127 @@ -527,7 +527,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
79128 extern void tcp_xmit_retransmit_queue(struct sock *);
79129 extern void tcp_simple_retransmit(struct sock *);
79130 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
79131 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79132 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79133
79134 extern void tcp_send_probe0(struct sock *);
79135 extern void tcp_send_partial(struct sock *);
79136 @@ -699,8 +699,8 @@ struct tcp_skb_cb {
79137 struct inet6_skb_parm h6;
79138 #endif
79139 } header; /* For incoming frames */
79140 - __u32 seq; /* Starting sequence number */
79141 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
79142 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
79143 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
79144 __u32 when; /* used to compute rtt's */
79145 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
79146
79147 @@ -714,7 +714,7 @@ struct tcp_skb_cb {
79148
79149 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
79150 /* 1 byte hole */
79151 - __u32 ack_seq; /* Sequence number ACK'd */
79152 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
79153 };
79154
79155 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
79156 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
79157 index e253bf0..2278b4b 100644
79158 --- a/include/net/xfrm.h
79159 +++ b/include/net/xfrm.h
79160 @@ -287,7 +287,6 @@ struct xfrm_dst;
79161 struct xfrm_policy_afinfo {
79162 unsigned short family;
79163 struct dst_ops *dst_ops;
79164 - void (*garbage_collect)(struct net *net);
79165 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
79166 const xfrm_address_t *saddr,
79167 const xfrm_address_t *daddr);
79168 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
79169 struct net_device *dev,
79170 const struct flowi *fl);
79171 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
79172 -};
79173 +} __do_const;
79174
79175 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
79176 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
79177 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
79178 int (*transport_finish)(struct sk_buff *skb,
79179 int async);
79180 void (*local_error)(struct sk_buff *skb, u32 mtu);
79181 -};
79182 +} __do_const;
79183
79184 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
79185 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
79186 @@ -427,7 +426,7 @@ struct xfrm_mode {
79187 struct module *owner;
79188 unsigned int encap;
79189 int flags;
79190 -};
79191 +} __do_const;
79192
79193 /* Flags for xfrm_mode. */
79194 enum {
79195 @@ -524,7 +523,7 @@ struct xfrm_policy {
79196 struct timer_list timer;
79197
79198 struct flow_cache_object flo;
79199 - atomic_t genid;
79200 + atomic_unchecked_t genid;
79201 u32 priority;
79202 u32 index;
79203 struct xfrm_mark mark;
79204 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
79205 }
79206
79207 extern void xfrm_garbage_collect(struct net *net);
79208 +extern void xfrm_garbage_collect_deferred(struct net *net);
79209
79210 #else
79211
79212 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
79213 static inline void xfrm_garbage_collect(struct net *net)
79214 {
79215 }
79216 +static inline void xfrm_garbage_collect_deferred(struct net *net)
79217 +{
79218 +}
79219 #endif
79220
79221 static __inline__
79222 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
79223 index 1017e0b..227aa4d 100644
79224 --- a/include/rdma/iw_cm.h
79225 +++ b/include/rdma/iw_cm.h
79226 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
79227 int backlog);
79228
79229 int (*destroy_listen)(struct iw_cm_id *cm_id);
79230 -};
79231 +} __no_const;
79232
79233 /**
79234 * iw_create_cm_id - Create an IW CM identifier.
79235 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
79236 index e1379b4..67eafbe 100644
79237 --- a/include/scsi/libfc.h
79238 +++ b/include/scsi/libfc.h
79239 @@ -762,6 +762,7 @@ struct libfc_function_template {
79240 */
79241 void (*disc_stop_final) (struct fc_lport *);
79242 };
79243 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
79244
79245 /**
79246 * struct fc_disc - Discovery context
79247 @@ -866,7 +867,7 @@ struct fc_lport {
79248 struct fc_vport *vport;
79249
79250 /* Operational Information */
79251 - struct libfc_function_template tt;
79252 + libfc_function_template_no_const tt;
79253 u8 link_up;
79254 u8 qfull;
79255 enum fc_lport_state state;
79256 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
79257 index d65fbec..f80fef2 100644
79258 --- a/include/scsi/scsi_device.h
79259 +++ b/include/scsi/scsi_device.h
79260 @@ -180,9 +180,9 @@ struct scsi_device {
79261 unsigned int max_device_blocked; /* what device_blocked counts down from */
79262 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
79263
79264 - atomic_t iorequest_cnt;
79265 - atomic_t iodone_cnt;
79266 - atomic_t ioerr_cnt;
79267 + atomic_unchecked_t iorequest_cnt;
79268 + atomic_unchecked_t iodone_cnt;
79269 + atomic_unchecked_t ioerr_cnt;
79270
79271 struct device sdev_gendev,
79272 sdev_dev;
79273 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
79274 index b797e8f..8e2c3aa 100644
79275 --- a/include/scsi/scsi_transport_fc.h
79276 +++ b/include/scsi/scsi_transport_fc.h
79277 @@ -751,7 +751,8 @@ struct fc_function_template {
79278 unsigned long show_host_system_hostname:1;
79279
79280 unsigned long disable_target_scan:1;
79281 -};
79282 +} __do_const;
79283 +typedef struct fc_function_template __no_const fc_function_template_no_const;
79284
79285
79286 /**
79287 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
79288 index 9031a26..750d592 100644
79289 --- a/include/sound/compress_driver.h
79290 +++ b/include/sound/compress_driver.h
79291 @@ -128,7 +128,7 @@ struct snd_compr_ops {
79292 struct snd_compr_caps *caps);
79293 int (*get_codec_caps) (struct snd_compr_stream *stream,
79294 struct snd_compr_codec_caps *codec);
79295 -};
79296 +} __no_const;
79297
79298 /**
79299 * struct snd_compr: Compressed device
79300 diff --git a/include/sound/soc.h b/include/sound/soc.h
79301 index d22cb0a..c6ba150 100644
79302 --- a/include/sound/soc.h
79303 +++ b/include/sound/soc.h
79304 @@ -780,7 +780,7 @@ struct snd_soc_codec_driver {
79305 /* probe ordering - for components with runtime dependencies */
79306 int probe_order;
79307 int remove_order;
79308 -};
79309 +} __do_const;
79310
79311 /* SoC platform interface */
79312 struct snd_soc_platform_driver {
79313 @@ -826,7 +826,7 @@ struct snd_soc_platform_driver {
79314 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
79315 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
79316 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
79317 -};
79318 +} __do_const;
79319
79320 struct snd_soc_platform {
79321 const char *name;
79322 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
79323 index 5bdb8b7..bb1096c 100644
79324 --- a/include/target/target_core_base.h
79325 +++ b/include/target/target_core_base.h
79326 @@ -663,7 +663,7 @@ struct se_device {
79327 spinlock_t stats_lock;
79328 /* Active commands on this virtual SE device */
79329 atomic_t simple_cmds;
79330 - atomic_t dev_ordered_id;
79331 + atomic_unchecked_t dev_ordered_id;
79332 atomic_t dev_ordered_sync;
79333 atomic_t dev_qf_count;
79334 int export_count;
79335 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
79336 new file mode 100644
79337 index 0000000..fb634b7
79338 --- /dev/null
79339 +++ b/include/trace/events/fs.h
79340 @@ -0,0 +1,53 @@
79341 +#undef TRACE_SYSTEM
79342 +#define TRACE_SYSTEM fs
79343 +
79344 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
79345 +#define _TRACE_FS_H
79346 +
79347 +#include <linux/fs.h>
79348 +#include <linux/tracepoint.h>
79349 +
79350 +TRACE_EVENT(do_sys_open,
79351 +
79352 + TP_PROTO(const char *filename, int flags, int mode),
79353 +
79354 + TP_ARGS(filename, flags, mode),
79355 +
79356 + TP_STRUCT__entry(
79357 + __string( filename, filename )
79358 + __field( int, flags )
79359 + __field( int, mode )
79360 + ),
79361 +
79362 + TP_fast_assign(
79363 + __assign_str(filename, filename);
79364 + __entry->flags = flags;
79365 + __entry->mode = mode;
79366 + ),
79367 +
79368 + TP_printk("\"%s\" %x %o",
79369 + __get_str(filename), __entry->flags, __entry->mode)
79370 +);
79371 +
79372 +TRACE_EVENT(open_exec,
79373 +
79374 + TP_PROTO(const char *filename),
79375 +
79376 + TP_ARGS(filename),
79377 +
79378 + TP_STRUCT__entry(
79379 + __string( filename, filename )
79380 + ),
79381 +
79382 + TP_fast_assign(
79383 + __assign_str(filename, filename);
79384 + ),
79385 +
79386 + TP_printk("\"%s\"",
79387 + __get_str(filename))
79388 +);
79389 +
79390 +#endif /* _TRACE_FS_H */
79391 +
79392 +/* This part must be outside protection */
79393 +#include <trace/define_trace.h>
79394 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
79395 index 1c09820..7f5ec79 100644
79396 --- a/include/trace/events/irq.h
79397 +++ b/include/trace/events/irq.h
79398 @@ -36,7 +36,7 @@ struct softirq_action;
79399 */
79400 TRACE_EVENT(irq_handler_entry,
79401
79402 - TP_PROTO(int irq, struct irqaction *action),
79403 + TP_PROTO(int irq, const struct irqaction *action),
79404
79405 TP_ARGS(irq, action),
79406
79407 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
79408 */
79409 TRACE_EVENT(irq_handler_exit,
79410
79411 - TP_PROTO(int irq, struct irqaction *action, int ret),
79412 + TP_PROTO(int irq, const struct irqaction *action, int ret),
79413
79414 TP_ARGS(irq, action, ret),
79415
79416 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
79417 index 7caf44c..23c6f27 100644
79418 --- a/include/uapi/linux/a.out.h
79419 +++ b/include/uapi/linux/a.out.h
79420 @@ -39,6 +39,14 @@ enum machine_type {
79421 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
79422 };
79423
79424 +/* Constants for the N_FLAGS field */
79425 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79426 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
79427 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
79428 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
79429 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79430 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79431 +
79432 #if !defined (N_MAGIC)
79433 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
79434 #endif
79435 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
79436 index d876736..ccce5c0 100644
79437 --- a/include/uapi/linux/byteorder/little_endian.h
79438 +++ b/include/uapi/linux/byteorder/little_endian.h
79439 @@ -42,51 +42,51 @@
79440
79441 static inline __le64 __cpu_to_le64p(const __u64 *p)
79442 {
79443 - return (__force __le64)*p;
79444 + return (__force const __le64)*p;
79445 }
79446 -static inline __u64 __le64_to_cpup(const __le64 *p)
79447 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
79448 {
79449 - return (__force __u64)*p;
79450 + return (__force const __u64)*p;
79451 }
79452 static inline __le32 __cpu_to_le32p(const __u32 *p)
79453 {
79454 - return (__force __le32)*p;
79455 + return (__force const __le32)*p;
79456 }
79457 static inline __u32 __le32_to_cpup(const __le32 *p)
79458 {
79459 - return (__force __u32)*p;
79460 + return (__force const __u32)*p;
79461 }
79462 static inline __le16 __cpu_to_le16p(const __u16 *p)
79463 {
79464 - return (__force __le16)*p;
79465 + return (__force const __le16)*p;
79466 }
79467 static inline __u16 __le16_to_cpup(const __le16 *p)
79468 {
79469 - return (__force __u16)*p;
79470 + return (__force const __u16)*p;
79471 }
79472 static inline __be64 __cpu_to_be64p(const __u64 *p)
79473 {
79474 - return (__force __be64)__swab64p(p);
79475 + return (__force const __be64)__swab64p(p);
79476 }
79477 static inline __u64 __be64_to_cpup(const __be64 *p)
79478 {
79479 - return __swab64p((__u64 *)p);
79480 + return __swab64p((const __u64 *)p);
79481 }
79482 static inline __be32 __cpu_to_be32p(const __u32 *p)
79483 {
79484 - return (__force __be32)__swab32p(p);
79485 + return (__force const __be32)__swab32p(p);
79486 }
79487 -static inline __u32 __be32_to_cpup(const __be32 *p)
79488 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
79489 {
79490 - return __swab32p((__u32 *)p);
79491 + return __swab32p((const __u32 *)p);
79492 }
79493 static inline __be16 __cpu_to_be16p(const __u16 *p)
79494 {
79495 - return (__force __be16)__swab16p(p);
79496 + return (__force const __be16)__swab16p(p);
79497 }
79498 static inline __u16 __be16_to_cpup(const __be16 *p)
79499 {
79500 - return __swab16p((__u16 *)p);
79501 + return __swab16p((const __u16 *)p);
79502 }
79503 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
79504 #define __le64_to_cpus(x) do { (void)(x); } while (0)
79505 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
79506 index ef6103b..d4e65dd 100644
79507 --- a/include/uapi/linux/elf.h
79508 +++ b/include/uapi/linux/elf.h
79509 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
79510 #define PT_GNU_EH_FRAME 0x6474e550
79511
79512 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
79513 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
79514 +
79515 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
79516 +
79517 +/* Constants for the e_flags field */
79518 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79519 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
79520 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
79521 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
79522 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79523 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79524
79525 /*
79526 * Extended Numbering
79527 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
79528 #define DT_DEBUG 21
79529 #define DT_TEXTREL 22
79530 #define DT_JMPREL 23
79531 +#define DT_FLAGS 30
79532 + #define DF_TEXTREL 0x00000004
79533 #define DT_ENCODING 32
79534 #define OLD_DT_LOOS 0x60000000
79535 #define DT_LOOS 0x6000000d
79536 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
79537 #define PF_W 0x2
79538 #define PF_X 0x1
79539
79540 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
79541 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
79542 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
79543 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
79544 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
79545 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
79546 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
79547 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
79548 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
79549 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
79550 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
79551 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
79552 +
79553 typedef struct elf32_phdr{
79554 Elf32_Word p_type;
79555 Elf32_Off p_offset;
79556 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
79557 #define EI_OSABI 7
79558 #define EI_PAD 8
79559
79560 +#define EI_PAX 14
79561 +
79562 #define ELFMAG0 0x7f /* EI_MAG */
79563 #define ELFMAG1 'E'
79564 #define ELFMAG2 'L'
79565 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
79566 index aa169c4..6a2771d 100644
79567 --- a/include/uapi/linux/personality.h
79568 +++ b/include/uapi/linux/personality.h
79569 @@ -30,6 +30,7 @@ enum {
79570 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
79571 ADDR_NO_RANDOMIZE | \
79572 ADDR_COMPAT_LAYOUT | \
79573 + ADDR_LIMIT_3GB | \
79574 MMAP_PAGE_ZERO)
79575
79576 /*
79577 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
79578 index 7530e74..e714828 100644
79579 --- a/include/uapi/linux/screen_info.h
79580 +++ b/include/uapi/linux/screen_info.h
79581 @@ -43,7 +43,8 @@ struct screen_info {
79582 __u16 pages; /* 0x32 */
79583 __u16 vesa_attributes; /* 0x34 */
79584 __u32 capabilities; /* 0x36 */
79585 - __u8 _reserved[6]; /* 0x3a */
79586 + __u16 vesapm_size; /* 0x3a */
79587 + __u8 _reserved[4]; /* 0x3c */
79588 } __attribute__((packed));
79589
79590 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
79591 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
79592 index 0e011eb..82681b1 100644
79593 --- a/include/uapi/linux/swab.h
79594 +++ b/include/uapi/linux/swab.h
79595 @@ -43,7 +43,7 @@
79596 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
79597 */
79598
79599 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
79600 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
79601 {
79602 #ifdef __HAVE_BUILTIN_BSWAP16__
79603 return __builtin_bswap16(val);
79604 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
79605 #endif
79606 }
79607
79608 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
79609 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
79610 {
79611 #ifdef __HAVE_BUILTIN_BSWAP32__
79612 return __builtin_bswap32(val);
79613 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
79614 #endif
79615 }
79616
79617 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
79618 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
79619 {
79620 #ifdef __HAVE_BUILTIN_BSWAP64__
79621 return __builtin_bswap64(val);
79622 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
79623 index 6d67213..8dab561 100644
79624 --- a/include/uapi/linux/sysctl.h
79625 +++ b/include/uapi/linux/sysctl.h
79626 @@ -155,7 +155,11 @@ enum
79627 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
79628 };
79629
79630 -
79631 +#ifdef CONFIG_PAX_SOFTMODE
79632 +enum {
79633 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
79634 +};
79635 +#endif
79636
79637 /* CTL_VM names: */
79638 enum
79639 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
79640 index e4629b9..6958086 100644
79641 --- a/include/uapi/linux/xattr.h
79642 +++ b/include/uapi/linux/xattr.h
79643 @@ -63,5 +63,9 @@
79644 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
79645 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
79646
79647 +/* User namespace */
79648 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
79649 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
79650 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
79651
79652 #endif /* _UAPI_LINUX_XATTR_H */
79653 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
79654 index f9466fa..f4e2b81 100644
79655 --- a/include/video/udlfb.h
79656 +++ b/include/video/udlfb.h
79657 @@ -53,10 +53,10 @@ struct dlfb_data {
79658 u32 pseudo_palette[256];
79659 int blank_mode; /*one of FB_BLANK_ */
79660 /* blit-only rendering path metrics, exposed through sysfs */
79661 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79662 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
79663 - atomic_t bytes_sent; /* to usb, after compression including overhead */
79664 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
79665 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79666 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
79667 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
79668 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
79669 };
79670
79671 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
79672 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
79673 index 30f5362..8ed8ac9 100644
79674 --- a/include/video/uvesafb.h
79675 +++ b/include/video/uvesafb.h
79676 @@ -122,6 +122,7 @@ struct uvesafb_par {
79677 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
79678 u8 pmi_setpal; /* PMI for palette changes */
79679 u16 *pmi_base; /* protected mode interface location */
79680 + u8 *pmi_code; /* protected mode code location */
79681 void *pmi_start;
79682 void *pmi_pal;
79683 u8 *vbe_state_orig; /*
79684 diff --git a/init/Kconfig b/init/Kconfig
79685 index 3ecd8a1..627843f 100644
79686 --- a/init/Kconfig
79687 +++ b/init/Kconfig
79688 @@ -1086,6 +1086,7 @@ endif # CGROUPS
79689
79690 config CHECKPOINT_RESTORE
79691 bool "Checkpoint/restore support" if EXPERT
79692 + depends on !GRKERNSEC
79693 default n
79694 help
79695 Enables additional kernel features in a sake of checkpoint/restore.
79696 @@ -1557,7 +1558,7 @@ config SLUB_DEBUG
79697
79698 config COMPAT_BRK
79699 bool "Disable heap randomization"
79700 - default y
79701 + default n
79702 help
79703 Randomizing heap placement makes heap exploits harder, but it
79704 also breaks ancient binaries (including anything libc5 based).
79705 @@ -1832,7 +1833,7 @@ config INIT_ALL_POSSIBLE
79706 config STOP_MACHINE
79707 bool
79708 default y
79709 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
79710 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
79711 help
79712 Need stop_machine() primitive.
79713
79714 diff --git a/init/Makefile b/init/Makefile
79715 index 7bc47ee..6da2dc7 100644
79716 --- a/init/Makefile
79717 +++ b/init/Makefile
79718 @@ -2,6 +2,9 @@
79719 # Makefile for the linux kernel.
79720 #
79721
79722 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
79723 +asflags-y := $(GCC_PLUGINS_AFLAGS)
79724 +
79725 obj-y := main.o version.o mounts.o
79726 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
79727 obj-y += noinitramfs.o
79728 diff --git a/init/do_mounts.c b/init/do_mounts.c
79729 index a51cddc..25c2768 100644
79730 --- a/init/do_mounts.c
79731 +++ b/init/do_mounts.c
79732 @@ -357,11 +357,11 @@ static void __init get_fs_names(char *page)
79733 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
79734 {
79735 struct super_block *s;
79736 - int err = sys_mount(name, "/root", fs, flags, data);
79737 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
79738 if (err)
79739 return err;
79740
79741 - sys_chdir("/root");
79742 + sys_chdir((const char __force_user *)"/root");
79743 s = current->fs->pwd.dentry->d_sb;
79744 ROOT_DEV = s->s_dev;
79745 printk(KERN_INFO
79746 @@ -482,18 +482,18 @@ void __init change_floppy(char *fmt, ...)
79747 va_start(args, fmt);
79748 vsprintf(buf, fmt, args);
79749 va_end(args);
79750 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
79751 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
79752 if (fd >= 0) {
79753 sys_ioctl(fd, FDEJECT, 0);
79754 sys_close(fd);
79755 }
79756 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
79757 - fd = sys_open("/dev/console", O_RDWR, 0);
79758 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
79759 if (fd >= 0) {
79760 sys_ioctl(fd, TCGETS, (long)&termios);
79761 termios.c_lflag &= ~ICANON;
79762 sys_ioctl(fd, TCSETSF, (long)&termios);
79763 - sys_read(fd, &c, 1);
79764 + sys_read(fd, (char __user *)&c, 1);
79765 termios.c_lflag |= ICANON;
79766 sys_ioctl(fd, TCSETSF, (long)&termios);
79767 sys_close(fd);
79768 @@ -587,8 +587,8 @@ void __init prepare_namespace(void)
79769 mount_root();
79770 out:
79771 devtmpfs_mount("dev");
79772 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79773 - sys_chroot(".");
79774 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79775 + sys_chroot((const char __force_user *)".");
79776 }
79777
79778 static bool is_tmpfs;
79779 diff --git a/init/do_mounts.h b/init/do_mounts.h
79780 index f5b978a..69dbfe8 100644
79781 --- a/init/do_mounts.h
79782 +++ b/init/do_mounts.h
79783 @@ -15,15 +15,15 @@ extern int root_mountflags;
79784
79785 static inline int create_dev(char *name, dev_t dev)
79786 {
79787 - sys_unlink(name);
79788 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
79789 + sys_unlink((char __force_user *)name);
79790 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
79791 }
79792
79793 #if BITS_PER_LONG == 32
79794 static inline u32 bstat(char *name)
79795 {
79796 struct stat64 stat;
79797 - if (sys_stat64(name, &stat) != 0)
79798 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
79799 return 0;
79800 if (!S_ISBLK(stat.st_mode))
79801 return 0;
79802 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
79803 static inline u32 bstat(char *name)
79804 {
79805 struct stat stat;
79806 - if (sys_newstat(name, &stat) != 0)
79807 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
79808 return 0;
79809 if (!S_ISBLK(stat.st_mode))
79810 return 0;
79811 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
79812 index 3e0878e..8a9d7a0 100644
79813 --- a/init/do_mounts_initrd.c
79814 +++ b/init/do_mounts_initrd.c
79815 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
79816 {
79817 sys_unshare(CLONE_FS | CLONE_FILES);
79818 /* stdin/stdout/stderr for /linuxrc */
79819 - sys_open("/dev/console", O_RDWR, 0);
79820 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
79821 sys_dup(0);
79822 sys_dup(0);
79823 /* move initrd over / and chdir/chroot in initrd root */
79824 - sys_chdir("/root");
79825 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79826 - sys_chroot(".");
79827 + sys_chdir((const char __force_user *)"/root");
79828 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79829 + sys_chroot((const char __force_user *)".");
79830 sys_setsid();
79831 return 0;
79832 }
79833 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
79834 create_dev("/dev/root.old", Root_RAM0);
79835 /* mount initrd on rootfs' /root */
79836 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
79837 - sys_mkdir("/old", 0700);
79838 - sys_chdir("/old");
79839 + sys_mkdir((const char __force_user *)"/old", 0700);
79840 + sys_chdir((const char __force_user *)"/old");
79841
79842 /* try loading default modules from initrd */
79843 load_default_modules();
79844 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
79845 current->flags &= ~PF_FREEZER_SKIP;
79846
79847 /* move initrd to rootfs' /old */
79848 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
79849 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
79850 /* switch root and cwd back to / of rootfs */
79851 - sys_chroot("..");
79852 + sys_chroot((const char __force_user *)"..");
79853
79854 if (new_decode_dev(real_root_dev) == Root_RAM0) {
79855 - sys_chdir("/old");
79856 + sys_chdir((const char __force_user *)"/old");
79857 return;
79858 }
79859
79860 - sys_chdir("/");
79861 + sys_chdir((const char __force_user *)"/");
79862 ROOT_DEV = new_decode_dev(real_root_dev);
79863 mount_root();
79864
79865 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
79866 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
79867 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
79868 if (!error)
79869 printk("okay\n");
79870 else {
79871 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
79872 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
79873 if (error == -ENOENT)
79874 printk("/initrd does not exist. Ignored.\n");
79875 else
79876 printk("failed\n");
79877 printk(KERN_NOTICE "Unmounting old root\n");
79878 - sys_umount("/old", MNT_DETACH);
79879 + sys_umount((char __force_user *)"/old", MNT_DETACH);
79880 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
79881 if (fd < 0) {
79882 error = fd;
79883 @@ -127,11 +127,11 @@ int __init initrd_load(void)
79884 * mounted in the normal path.
79885 */
79886 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
79887 - sys_unlink("/initrd.image");
79888 + sys_unlink((const char __force_user *)"/initrd.image");
79889 handle_initrd();
79890 return 1;
79891 }
79892 }
79893 - sys_unlink("/initrd.image");
79894 + sys_unlink((const char __force_user *)"/initrd.image");
79895 return 0;
79896 }
79897 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
79898 index 8cb6db5..d729f50 100644
79899 --- a/init/do_mounts_md.c
79900 +++ b/init/do_mounts_md.c
79901 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
79902 partitioned ? "_d" : "", minor,
79903 md_setup_args[ent].device_names);
79904
79905 - fd = sys_open(name, 0, 0);
79906 + fd = sys_open((char __force_user *)name, 0, 0);
79907 if (fd < 0) {
79908 printk(KERN_ERR "md: open failed - cannot start "
79909 "array %s\n", name);
79910 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
79911 * array without it
79912 */
79913 sys_close(fd);
79914 - fd = sys_open(name, 0, 0);
79915 + fd = sys_open((char __force_user *)name, 0, 0);
79916 sys_ioctl(fd, BLKRRPART, 0);
79917 }
79918 sys_close(fd);
79919 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
79920
79921 wait_for_device_probe();
79922
79923 - fd = sys_open("/dev/md0", 0, 0);
79924 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
79925 if (fd >= 0) {
79926 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
79927 sys_close(fd);
79928 diff --git a/init/init_task.c b/init/init_task.c
79929 index ba0a7f36..2bcf1d5 100644
79930 --- a/init/init_task.c
79931 +++ b/init/init_task.c
79932 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
79933 * Initial thread structure. Alignment of this is handled by a special
79934 * linker map entry.
79935 */
79936 +#ifdef CONFIG_X86
79937 +union thread_union init_thread_union __init_task_data;
79938 +#else
79939 union thread_union init_thread_union __init_task_data =
79940 { INIT_THREAD_INFO(init_task) };
79941 +#endif
79942 diff --git a/init/initramfs.c b/init/initramfs.c
79943 index a67ef9d..2d17ed9 100644
79944 --- a/init/initramfs.c
79945 +++ b/init/initramfs.c
79946 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79947 }
79948 }
79949
79950 -static long __init do_utime(char *filename, time_t mtime)
79951 +static long __init do_utime(char __force_user *filename, time_t mtime)
79952 {
79953 struct timespec t[2];
79954
79955 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79956 struct dir_entry *de, *tmp;
79957 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79958 list_del(&de->list);
79959 - do_utime(de->name, de->mtime);
79960 + do_utime((char __force_user *)de->name, de->mtime);
79961 kfree(de->name);
79962 kfree(de);
79963 }
79964 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79965 if (nlink >= 2) {
79966 char *old = find_link(major, minor, ino, mode, collected);
79967 if (old)
79968 - return (sys_link(old, collected) < 0) ? -1 : 1;
79969 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79970 }
79971 return 0;
79972 }
79973 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79974 {
79975 struct stat st;
79976
79977 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79978 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79979 if (S_ISDIR(st.st_mode))
79980 - sys_rmdir(path);
79981 + sys_rmdir((char __force_user *)path);
79982 else
79983 - sys_unlink(path);
79984 + sys_unlink((char __force_user *)path);
79985 }
79986 }
79987
79988 @@ -315,7 +315,7 @@ static int __init do_name(void)
79989 int openflags = O_WRONLY|O_CREAT;
79990 if (ml != 1)
79991 openflags |= O_TRUNC;
79992 - wfd = sys_open(collected, openflags, mode);
79993 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79994
79995 if (wfd >= 0) {
79996 sys_fchown(wfd, uid, gid);
79997 @@ -327,17 +327,17 @@ static int __init do_name(void)
79998 }
79999 }
80000 } else if (S_ISDIR(mode)) {
80001 - sys_mkdir(collected, mode);
80002 - sys_chown(collected, uid, gid);
80003 - sys_chmod(collected, mode);
80004 + sys_mkdir((char __force_user *)collected, mode);
80005 + sys_chown((char __force_user *)collected, uid, gid);
80006 + sys_chmod((char __force_user *)collected, mode);
80007 dir_add(collected, mtime);
80008 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
80009 S_ISFIFO(mode) || S_ISSOCK(mode)) {
80010 if (maybe_link() == 0) {
80011 - sys_mknod(collected, mode, rdev);
80012 - sys_chown(collected, uid, gid);
80013 - sys_chmod(collected, mode);
80014 - do_utime(collected, mtime);
80015 + sys_mknod((char __force_user *)collected, mode, rdev);
80016 + sys_chown((char __force_user *)collected, uid, gid);
80017 + sys_chmod((char __force_user *)collected, mode);
80018 + do_utime((char __force_user *)collected, mtime);
80019 }
80020 }
80021 return 0;
80022 @@ -346,15 +346,15 @@ static int __init do_name(void)
80023 static int __init do_copy(void)
80024 {
80025 if (count >= body_len) {
80026 - sys_write(wfd, victim, body_len);
80027 + sys_write(wfd, (char __force_user *)victim, body_len);
80028 sys_close(wfd);
80029 - do_utime(vcollected, mtime);
80030 + do_utime((char __force_user *)vcollected, mtime);
80031 kfree(vcollected);
80032 eat(body_len);
80033 state = SkipIt;
80034 return 0;
80035 } else {
80036 - sys_write(wfd, victim, count);
80037 + sys_write(wfd, (char __force_user *)victim, count);
80038 body_len -= count;
80039 eat(count);
80040 return 1;
80041 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
80042 {
80043 collected[N_ALIGN(name_len) + body_len] = '\0';
80044 clean_path(collected, 0);
80045 - sys_symlink(collected + N_ALIGN(name_len), collected);
80046 - sys_lchown(collected, uid, gid);
80047 - do_utime(collected, mtime);
80048 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
80049 + sys_lchown((char __force_user *)collected, uid, gid);
80050 + do_utime((char __force_user *)collected, mtime);
80051 state = SkipIt;
80052 next_state = Reset;
80053 return 0;
80054 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
80055 {
80056 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
80057 if (err)
80058 - panic(err); /* Failed to decompress INTERNAL initramfs */
80059 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
80060 if (initrd_start) {
80061 #ifdef CONFIG_BLK_DEV_RAM
80062 int fd;
80063 diff --git a/init/main.c b/init/main.c
80064 index 63d3e8f..291fa8a 100644
80065 --- a/init/main.c
80066 +++ b/init/main.c
80067 @@ -103,6 +103,8 @@ static inline void mark_rodata_ro(void) { }
80068 extern void tc_init(void);
80069 #endif
80070
80071 +extern void grsecurity_init(void);
80072 +
80073 /*
80074 * Debug helper: via this flag we know that we are in 'early bootup code'
80075 * where only the boot processor is running with IRQ disabled. This means
80076 @@ -156,6 +158,74 @@ static int __init set_reset_devices(char *str)
80077
80078 __setup("reset_devices", set_reset_devices);
80079
80080 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80081 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
80082 +static int __init setup_grsec_proc_gid(char *str)
80083 +{
80084 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
80085 + return 1;
80086 +}
80087 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
80088 +#endif
80089 +
80090 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
80091 +unsigned long pax_user_shadow_base __read_only;
80092 +EXPORT_SYMBOL(pax_user_shadow_base);
80093 +extern char pax_enter_kernel_user[];
80094 +extern char pax_exit_kernel_user[];
80095 +#endif
80096 +
80097 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
80098 +static int __init setup_pax_nouderef(char *str)
80099 +{
80100 +#ifdef CONFIG_X86_32
80101 + unsigned int cpu;
80102 + struct desc_struct *gdt;
80103 +
80104 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
80105 + gdt = get_cpu_gdt_table(cpu);
80106 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
80107 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
80108 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
80109 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
80110 + }
80111 + loadsegment(ds, __KERNEL_DS);
80112 + loadsegment(es, __KERNEL_DS);
80113 + loadsegment(ss, __KERNEL_DS);
80114 +#else
80115 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
80116 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
80117 + clone_pgd_mask = ~(pgdval_t)0UL;
80118 + pax_user_shadow_base = 0UL;
80119 + setup_clear_cpu_cap(X86_FEATURE_PCID);
80120 +#endif
80121 +
80122 + return 0;
80123 +}
80124 +early_param("pax_nouderef", setup_pax_nouderef);
80125 +
80126 +#ifdef CONFIG_X86_64
80127 +static int __init setup_pax_weakuderef(char *str)
80128 +{
80129 + if (clone_pgd_mask != ~(pgdval_t)0UL)
80130 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
80131 + return 1;
80132 +}
80133 +__setup("pax_weakuderef", setup_pax_weakuderef);
80134 +#endif
80135 +#endif
80136 +
80137 +#ifdef CONFIG_PAX_SOFTMODE
80138 +int pax_softmode;
80139 +
80140 +static int __init setup_pax_softmode(char *str)
80141 +{
80142 + get_option(&str, &pax_softmode);
80143 + return 1;
80144 +}
80145 +__setup("pax_softmode=", setup_pax_softmode);
80146 +#endif
80147 +
80148 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
80149 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
80150 static const char *panic_later, *panic_param;
80151 @@ -682,25 +752,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
80152 {
80153 int count = preempt_count();
80154 int ret;
80155 - char msgbuf[64];
80156 + const char *msg1 = "", *msg2 = "";
80157
80158 if (initcall_debug)
80159 ret = do_one_initcall_debug(fn);
80160 else
80161 ret = fn();
80162
80163 - msgbuf[0] = 0;
80164 -
80165 if (preempt_count() != count) {
80166 - sprintf(msgbuf, "preemption imbalance ");
80167 + msg1 = " preemption imbalance";
80168 preempt_count() = count;
80169 }
80170 if (irqs_disabled()) {
80171 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
80172 + msg2 = " disabled interrupts";
80173 local_irq_enable();
80174 }
80175 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
80176 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
80177
80178 + add_latent_entropy();
80179 return ret;
80180 }
80181
80182 @@ -807,10 +876,14 @@ static int run_init_process(const char *init_filename)
80183 {
80184 argv_init[0] = init_filename;
80185 return do_execve(init_filename,
80186 - (const char __user *const __user *)argv_init,
80187 - (const char __user *const __user *)envp_init);
80188 + (const char __user *const __force_user *)argv_init,
80189 + (const char __user *const __force_user *)envp_init);
80190 }
80191
80192 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80193 +extern int gr_init_ran;
80194 +#endif
80195 +
80196 static noinline void __init kernel_init_freeable(void);
80197
80198 static int __ref kernel_init(void *unused)
80199 @@ -831,6 +904,11 @@ static int __ref kernel_init(void *unused)
80200 pr_err("Failed to execute %s\n", ramdisk_execute_command);
80201 }
80202
80203 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80204 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
80205 + gr_init_ran = 1;
80206 +#endif
80207 +
80208 /*
80209 * We try each of these until one succeeds.
80210 *
80211 @@ -885,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
80212 do_basic_setup();
80213
80214 /* Open the /dev/console on the rootfs, this should never fail */
80215 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
80216 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
80217 pr_err("Warning: unable to open an initial console.\n");
80218
80219 (void) sys_dup(0);
80220 @@ -898,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
80221 if (!ramdisk_execute_command)
80222 ramdisk_execute_command = "/init";
80223
80224 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
80225 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
80226 ramdisk_execute_command = NULL;
80227 prepare_namespace();
80228 }
80229
80230 + grsecurity_init();
80231 +
80232 /*
80233 * Ok, we have completed the initial bootup, and
80234 * we're essentially up and running. Get rid of the
80235 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
80236 index b0e99de..09f385c 100644
80237 --- a/ipc/ipc_sysctl.c
80238 +++ b/ipc/ipc_sysctl.c
80239 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
80240 static int proc_ipc_dointvec(ctl_table *table, int write,
80241 void __user *buffer, size_t *lenp, loff_t *ppos)
80242 {
80243 - struct ctl_table ipc_table;
80244 + ctl_table_no_const ipc_table;
80245
80246 memcpy(&ipc_table, table, sizeof(ipc_table));
80247 ipc_table.data = get_ipc(table);
80248 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
80249 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
80250 void __user *buffer, size_t *lenp, loff_t *ppos)
80251 {
80252 - struct ctl_table ipc_table;
80253 + ctl_table_no_const ipc_table;
80254
80255 memcpy(&ipc_table, table, sizeof(ipc_table));
80256 ipc_table.data = get_ipc(table);
80257 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
80258 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80259 void __user *buffer, size_t *lenp, loff_t *ppos)
80260 {
80261 - struct ctl_table ipc_table;
80262 + ctl_table_no_const ipc_table;
80263 size_t lenp_bef = *lenp;
80264 int rc;
80265
80266 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80267 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
80268 void __user *buffer, size_t *lenp, loff_t *ppos)
80269 {
80270 - struct ctl_table ipc_table;
80271 + ctl_table_no_const ipc_table;
80272 memcpy(&ipc_table, table, sizeof(ipc_table));
80273 ipc_table.data = get_ipc(table);
80274
80275 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
80276 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
80277 void __user *buffer, size_t *lenp, loff_t *ppos)
80278 {
80279 - struct ctl_table ipc_table;
80280 + ctl_table_no_const ipc_table;
80281 size_t lenp_bef = *lenp;
80282 int oldval;
80283 int rc;
80284 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
80285 index 383d638..943fdbb 100644
80286 --- a/ipc/mq_sysctl.c
80287 +++ b/ipc/mq_sysctl.c
80288 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
80289 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
80290 void __user *buffer, size_t *lenp, loff_t *ppos)
80291 {
80292 - struct ctl_table mq_table;
80293 + ctl_table_no_const mq_table;
80294 memcpy(&mq_table, table, sizeof(mq_table));
80295 mq_table.data = get_mq(table);
80296
80297 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
80298 index ae1996d..a35f2cc 100644
80299 --- a/ipc/mqueue.c
80300 +++ b/ipc/mqueue.c
80301 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
80302 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
80303 info->attr.mq_msgsize);
80304
80305 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
80306 spin_lock(&mq_lock);
80307 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
80308 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
80309 diff --git a/ipc/msg.c b/ipc/msg.c
80310 index 558aa91..359e718 100644
80311 --- a/ipc/msg.c
80312 +++ b/ipc/msg.c
80313 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
80314 return security_msg_queue_associate(msq, msgflg);
80315 }
80316
80317 +static struct ipc_ops msg_ops = {
80318 + .getnew = newque,
80319 + .associate = msg_security,
80320 + .more_checks = NULL
80321 +};
80322 +
80323 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
80324 {
80325 struct ipc_namespace *ns;
80326 - struct ipc_ops msg_ops;
80327 struct ipc_params msg_params;
80328
80329 ns = current->nsproxy->ipc_ns;
80330
80331 - msg_ops.getnew = newque;
80332 - msg_ops.associate = msg_security;
80333 - msg_ops.more_checks = NULL;
80334 -
80335 msg_params.key = key;
80336 msg_params.flg = msgflg;
80337
80338 diff --git a/ipc/sem.c b/ipc/sem.c
80339 index db9d241..bc8427c 100644
80340 --- a/ipc/sem.c
80341 +++ b/ipc/sem.c
80342 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
80343 return 0;
80344 }
80345
80346 +static struct ipc_ops sem_ops = {
80347 + .getnew = newary,
80348 + .associate = sem_security,
80349 + .more_checks = sem_more_checks
80350 +};
80351 +
80352 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80353 {
80354 struct ipc_namespace *ns;
80355 - struct ipc_ops sem_ops;
80356 struct ipc_params sem_params;
80357
80358 ns = current->nsproxy->ipc_ns;
80359 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80360 if (nsems < 0 || nsems > ns->sc_semmsl)
80361 return -EINVAL;
80362
80363 - sem_ops.getnew = newary;
80364 - sem_ops.associate = sem_security;
80365 - sem_ops.more_checks = sem_more_checks;
80366 -
80367 sem_params.key = key;
80368 sem_params.flg = semflg;
80369 sem_params.u.nsems = nsems;
80370 diff --git a/ipc/shm.c b/ipc/shm.c
80371 index d697396..5aadb3f 100644
80372 --- a/ipc/shm.c
80373 +++ b/ipc/shm.c
80374 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
80375 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
80376 #endif
80377
80378 +#ifdef CONFIG_GRKERNSEC
80379 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80380 + const time_t shm_createtime, const kuid_t cuid,
80381 + const int shmid);
80382 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80383 + const time_t shm_createtime);
80384 +#endif
80385 +
80386 void shm_init_ns(struct ipc_namespace *ns)
80387 {
80388 ns->shm_ctlmax = SHMMAX;
80389 @@ -551,6 +559,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
80390 shp->shm_lprid = 0;
80391 shp->shm_atim = shp->shm_dtim = 0;
80392 shp->shm_ctim = get_seconds();
80393 +#ifdef CONFIG_GRKERNSEC
80394 + {
80395 + struct timespec timeval;
80396 + do_posix_clock_monotonic_gettime(&timeval);
80397 +
80398 + shp->shm_createtime = timeval.tv_sec;
80399 + }
80400 +#endif
80401 shp->shm_segsz = size;
80402 shp->shm_nattch = 0;
80403 shp->shm_file = file;
80404 @@ -604,18 +620,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
80405 return 0;
80406 }
80407
80408 +static struct ipc_ops shm_ops = {
80409 + .getnew = newseg,
80410 + .associate = shm_security,
80411 + .more_checks = shm_more_checks
80412 +};
80413 +
80414 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
80415 {
80416 struct ipc_namespace *ns;
80417 - struct ipc_ops shm_ops;
80418 struct ipc_params shm_params;
80419
80420 ns = current->nsproxy->ipc_ns;
80421
80422 - shm_ops.getnew = newseg;
80423 - shm_ops.associate = shm_security;
80424 - shm_ops.more_checks = shm_more_checks;
80425 -
80426 shm_params.key = key;
80427 shm_params.flg = shmflg;
80428 shm_params.u.size = size;
80429 @@ -1076,6 +1093,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80430 f_mode = FMODE_READ | FMODE_WRITE;
80431 }
80432 if (shmflg & SHM_EXEC) {
80433 +
80434 +#ifdef CONFIG_PAX_MPROTECT
80435 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
80436 + goto out;
80437 +#endif
80438 +
80439 prot |= PROT_EXEC;
80440 acc_mode |= S_IXUGO;
80441 }
80442 @@ -1100,10 +1123,23 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80443 if (err)
80444 goto out_unlock;
80445
80446 +#ifdef CONFIG_GRKERNSEC
80447 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
80448 + shp->shm_perm.cuid, shmid) ||
80449 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
80450 + err = -EACCES;
80451 + goto out_unlock;
80452 + }
80453 +#endif
80454 +
80455 ipc_lock_object(&shp->shm_perm);
80456 +
80457 path = shp->shm_file->f_path;
80458 path_get(&path);
80459 shp->shm_nattch++;
80460 +#ifdef CONFIG_GRKERNSEC
80461 + shp->shm_lapid = current->pid;
80462 +#endif
80463 size = i_size_read(path.dentry->d_inode);
80464 ipc_unlock_object(&shp->shm_perm);
80465 rcu_read_unlock();
80466 diff --git a/ipc/util.c b/ipc/util.c
80467 index 7684f41..f7da711 100644
80468 --- a/ipc/util.c
80469 +++ b/ipc/util.c
80470 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
80471 int (*show)(struct seq_file *, void *);
80472 };
80473
80474 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
80475 +
80476 static void ipc_memory_notifier(struct work_struct *work)
80477 {
80478 ipcns_notify(IPCNS_MEMCHANGED);
80479 @@ -560,6 +562,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
80480 granted_mode >>= 6;
80481 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
80482 granted_mode >>= 3;
80483 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
80484 + return -1;
80485 +
80486 /* is there some bit set in requested_mode but not in granted_mode? */
80487 if ((requested_mode & ~granted_mode & 0007) &&
80488 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
80489 diff --git a/kernel/acct.c b/kernel/acct.c
80490 index 8d6e145..33e0b1e 100644
80491 --- a/kernel/acct.c
80492 +++ b/kernel/acct.c
80493 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
80494 */
80495 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
80496 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
80497 - file->f_op->write(file, (char *)&ac,
80498 + file->f_op->write(file, (char __force_user *)&ac,
80499 sizeof(acct_t), &file->f_pos);
80500 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
80501 set_fs(fs);
80502 diff --git a/kernel/audit.c b/kernel/audit.c
80503 index 7b0e23a..f4d172f 100644
80504 --- a/kernel/audit.c
80505 +++ b/kernel/audit.c
80506 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
80507 3) suppressed due to audit_rate_limit
80508 4) suppressed due to audit_backlog_limit
80509 */
80510 -static atomic_t audit_lost = ATOMIC_INIT(0);
80511 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
80512
80513 /* The netlink socket. */
80514 static struct sock *audit_sock;
80515 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
80516 unsigned long now;
80517 int print;
80518
80519 - atomic_inc(&audit_lost);
80520 + atomic_inc_unchecked(&audit_lost);
80521
80522 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
80523
80524 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
80525 printk(KERN_WARNING
80526 "audit: audit_lost=%d audit_rate_limit=%d "
80527 "audit_backlog_limit=%d\n",
80528 - atomic_read(&audit_lost),
80529 + atomic_read_unchecked(&audit_lost),
80530 audit_rate_limit,
80531 audit_backlog_limit);
80532 audit_panic(message);
80533 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80534
80535 switch (msg_type) {
80536 case AUDIT_GET:
80537 + status_set.mask = 0;
80538 status_set.enabled = audit_enabled;
80539 status_set.failure = audit_failure;
80540 status_set.pid = audit_pid;
80541 status_set.rate_limit = audit_rate_limit;
80542 status_set.backlog_limit = audit_backlog_limit;
80543 - status_set.lost = atomic_read(&audit_lost);
80544 + status_set.lost = atomic_read_unchecked(&audit_lost);
80545 status_set.backlog = skb_queue_len(&audit_skb_queue);
80546 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
80547 &status_set, sizeof(status_set));
80548 break;
80549 case AUDIT_SET:
80550 - if (nlh->nlmsg_len < sizeof(struct audit_status))
80551 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
80552 return -EINVAL;
80553 status_get = (struct audit_status *)data;
80554 if (status_get->mask & AUDIT_STATUS_ENABLED) {
80555 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80556
80557 memset(&s, 0, sizeof(s));
80558 /* guard against past and future API changes */
80559 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
80560 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
80561 if ((s.enabled != 0 && s.enabled != 1) ||
80562 (s.log_passwd != 0 && s.log_passwd != 1))
80563 return -EINVAL;
80564 @@ -1251,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
80565 int i, avail, new_len;
80566 unsigned char *ptr;
80567 struct sk_buff *skb;
80568 - static const unsigned char *hex = "0123456789ABCDEF";
80569 + static const unsigned char hex[] = "0123456789ABCDEF";
80570
80571 if (!ab)
80572 return;
80573 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
80574 index 9845cb3..3ec9369 100644
80575 --- a/kernel/auditsc.c
80576 +++ b/kernel/auditsc.c
80577 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
80578 }
80579
80580 /* global counter which is incremented every time something logs in */
80581 -static atomic_t session_id = ATOMIC_INIT(0);
80582 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
80583
80584 /**
80585 * audit_set_loginuid - set current task's audit_context loginuid
80586 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
80587 return -EPERM;
80588 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
80589
80590 - sessionid = atomic_inc_return(&session_id);
80591 + sessionid = atomic_inc_return_unchecked(&session_id);
80592 if (context && context->in_syscall) {
80593 struct audit_buffer *ab;
80594
80595 diff --git a/kernel/capability.c b/kernel/capability.c
80596 index 4e66bf9..cdccecf 100644
80597 --- a/kernel/capability.c
80598 +++ b/kernel/capability.c
80599 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
80600 * before modification is attempted and the application
80601 * fails.
80602 */
80603 + if (tocopy > ARRAY_SIZE(kdata))
80604 + return -EFAULT;
80605 +
80606 if (copy_to_user(dataptr, kdata, tocopy
80607 * sizeof(struct __user_cap_data_struct))) {
80608 return -EFAULT;
80609 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
80610 int ret;
80611
80612 rcu_read_lock();
80613 - ret = security_capable(__task_cred(t), ns, cap);
80614 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
80615 + gr_task_is_capable(t, __task_cred(t), cap);
80616 rcu_read_unlock();
80617
80618 - return (ret == 0);
80619 + return ret;
80620 }
80621
80622 /**
80623 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
80624 int ret;
80625
80626 rcu_read_lock();
80627 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
80628 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
80629 rcu_read_unlock();
80630
80631 - return (ret == 0);
80632 + return ret;
80633 }
80634
80635 /**
80636 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
80637 BUG();
80638 }
80639
80640 - if (security_capable(current_cred(), ns, cap) == 0) {
80641 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
80642 current->flags |= PF_SUPERPRIV;
80643 return true;
80644 }
80645 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
80646 }
80647 EXPORT_SYMBOL(ns_capable);
80648
80649 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
80650 +{
80651 + if (unlikely(!cap_valid(cap))) {
80652 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
80653 + BUG();
80654 + }
80655 +
80656 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
80657 + current->flags |= PF_SUPERPRIV;
80658 + return true;
80659 + }
80660 + return false;
80661 +}
80662 +EXPORT_SYMBOL(ns_capable_nolog);
80663 +
80664 /**
80665 * file_ns_capable - Determine if the file's opener had a capability in effect
80666 * @file: The file we want to check
80667 @@ -432,6 +451,12 @@ bool capable(int cap)
80668 }
80669 EXPORT_SYMBOL(capable);
80670
80671 +bool capable_nolog(int cap)
80672 +{
80673 + return ns_capable_nolog(&init_user_ns, cap);
80674 +}
80675 +EXPORT_SYMBOL(capable_nolog);
80676 +
80677 /**
80678 * inode_capable - Check superior capability over inode
80679 * @inode: The inode in question
80680 @@ -453,3 +478,11 @@ bool inode_capable(const struct inode *inode, int cap)
80681 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80682 }
80683 EXPORT_SYMBOL(inode_capable);
80684 +
80685 +bool inode_capable_nolog(const struct inode *inode, int cap)
80686 +{
80687 + struct user_namespace *ns = current_user_ns();
80688 +
80689 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80690 +}
80691 +EXPORT_SYMBOL(inode_capable_nolog);
80692 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
80693 index 8bd9cfd..9faf120 100644
80694 --- a/kernel/cgroup.c
80695 +++ b/kernel/cgroup.c
80696 @@ -5817,7 +5817,7 @@ static int cgroup_css_links_read(struct cgroup_subsys_state *css,
80697 struct css_set *cset = link->cset;
80698 struct task_struct *task;
80699 int count = 0;
80700 - seq_printf(seq, "css_set %p\n", cset);
80701 + seq_printf(seq, "css_set %pK\n", cset);
80702 list_for_each_entry(task, &cset->tasks, cg_list) {
80703 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
80704 seq_puts(seq, " ...\n");
80705 diff --git a/kernel/compat.c b/kernel/compat.c
80706 index 0a09e48..f44f3f0 100644
80707 --- a/kernel/compat.c
80708 +++ b/kernel/compat.c
80709 @@ -13,6 +13,7 @@
80710
80711 #include <linux/linkage.h>
80712 #include <linux/compat.h>
80713 +#include <linux/module.h>
80714 #include <linux/errno.h>
80715 #include <linux/time.h>
80716 #include <linux/signal.h>
80717 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
80718 mm_segment_t oldfs;
80719 long ret;
80720
80721 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
80722 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
80723 oldfs = get_fs();
80724 set_fs(KERNEL_DS);
80725 ret = hrtimer_nanosleep_restart(restart);
80726 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
80727 oldfs = get_fs();
80728 set_fs(KERNEL_DS);
80729 ret = hrtimer_nanosleep(&tu,
80730 - rmtp ? (struct timespec __user *)&rmt : NULL,
80731 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
80732 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
80733 set_fs(oldfs);
80734
80735 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
80736 mm_segment_t old_fs = get_fs();
80737
80738 set_fs(KERNEL_DS);
80739 - ret = sys_sigpending((old_sigset_t __user *) &s);
80740 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
80741 set_fs(old_fs);
80742 if (ret == 0)
80743 ret = put_user(s, set);
80744 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
80745 mm_segment_t old_fs = get_fs();
80746
80747 set_fs(KERNEL_DS);
80748 - ret = sys_old_getrlimit(resource, &r);
80749 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
80750 set_fs(old_fs);
80751
80752 if (!ret) {
80753 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
80754 set_fs (KERNEL_DS);
80755 ret = sys_wait4(pid,
80756 (stat_addr ?
80757 - (unsigned int __user *) &status : NULL),
80758 - options, (struct rusage __user *) &r);
80759 + (unsigned int __force_user *) &status : NULL),
80760 + options, (struct rusage __force_user *) &r);
80761 set_fs (old_fs);
80762
80763 if (ret > 0) {
80764 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
80765 memset(&info, 0, sizeof(info));
80766
80767 set_fs(KERNEL_DS);
80768 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
80769 - uru ? (struct rusage __user *)&ru : NULL);
80770 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
80771 + uru ? (struct rusage __force_user *)&ru : NULL);
80772 set_fs(old_fs);
80773
80774 if ((ret < 0) || (info.si_signo == 0))
80775 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
80776 oldfs = get_fs();
80777 set_fs(KERNEL_DS);
80778 err = sys_timer_settime(timer_id, flags,
80779 - (struct itimerspec __user *) &newts,
80780 - (struct itimerspec __user *) &oldts);
80781 + (struct itimerspec __force_user *) &newts,
80782 + (struct itimerspec __force_user *) &oldts);
80783 set_fs(oldfs);
80784 if (!err && old && put_compat_itimerspec(old, &oldts))
80785 return -EFAULT;
80786 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
80787 oldfs = get_fs();
80788 set_fs(KERNEL_DS);
80789 err = sys_timer_gettime(timer_id,
80790 - (struct itimerspec __user *) &ts);
80791 + (struct itimerspec __force_user *) &ts);
80792 set_fs(oldfs);
80793 if (!err && put_compat_itimerspec(setting, &ts))
80794 return -EFAULT;
80795 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
80796 oldfs = get_fs();
80797 set_fs(KERNEL_DS);
80798 err = sys_clock_settime(which_clock,
80799 - (struct timespec __user *) &ts);
80800 + (struct timespec __force_user *) &ts);
80801 set_fs(oldfs);
80802 return err;
80803 }
80804 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
80805 oldfs = get_fs();
80806 set_fs(KERNEL_DS);
80807 err = sys_clock_gettime(which_clock,
80808 - (struct timespec __user *) &ts);
80809 + (struct timespec __force_user *) &ts);
80810 set_fs(oldfs);
80811 if (!err && put_compat_timespec(&ts, tp))
80812 return -EFAULT;
80813 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
80814
80815 oldfs = get_fs();
80816 set_fs(KERNEL_DS);
80817 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
80818 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
80819 set_fs(oldfs);
80820
80821 err = compat_put_timex(utp, &txc);
80822 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
80823 oldfs = get_fs();
80824 set_fs(KERNEL_DS);
80825 err = sys_clock_getres(which_clock,
80826 - (struct timespec __user *) &ts);
80827 + (struct timespec __force_user *) &ts);
80828 set_fs(oldfs);
80829 if (!err && tp && put_compat_timespec(&ts, tp))
80830 return -EFAULT;
80831 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
80832 long err;
80833 mm_segment_t oldfs;
80834 struct timespec tu;
80835 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
80836 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
80837
80838 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
80839 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
80840 oldfs = get_fs();
80841 set_fs(KERNEL_DS);
80842 err = clock_nanosleep_restart(restart);
80843 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
80844 oldfs = get_fs();
80845 set_fs(KERNEL_DS);
80846 err = sys_clock_nanosleep(which_clock, flags,
80847 - (struct timespec __user *) &in,
80848 - (struct timespec __user *) &out);
80849 + (struct timespec __force_user *) &in,
80850 + (struct timespec __force_user *) &out);
80851 set_fs(oldfs);
80852
80853 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
80854 diff --git a/kernel/configs.c b/kernel/configs.c
80855 index c18b1f1..b9a0132 100644
80856 --- a/kernel/configs.c
80857 +++ b/kernel/configs.c
80858 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
80859 struct proc_dir_entry *entry;
80860
80861 /* create the current config file */
80862 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
80863 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
80864 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
80865 + &ikconfig_file_ops);
80866 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80867 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
80868 + &ikconfig_file_ops);
80869 +#endif
80870 +#else
80871 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
80872 &ikconfig_file_ops);
80873 +#endif
80874 +
80875 if (!entry)
80876 return -ENOMEM;
80877
80878 diff --git a/kernel/cred.c b/kernel/cred.c
80879 index e0573a4..3874e41 100644
80880 --- a/kernel/cred.c
80881 +++ b/kernel/cred.c
80882 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
80883 validate_creds(cred);
80884 alter_cred_subscribers(cred, -1);
80885 put_cred(cred);
80886 +
80887 +#ifdef CONFIG_GRKERNSEC_SETXID
80888 + cred = (struct cred *) tsk->delayed_cred;
80889 + if (cred != NULL) {
80890 + tsk->delayed_cred = NULL;
80891 + validate_creds(cred);
80892 + alter_cred_subscribers(cred, -1);
80893 + put_cred(cred);
80894 + }
80895 +#endif
80896 }
80897
80898 /**
80899 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
80900 * Always returns 0 thus allowing this function to be tail-called at the end
80901 * of, say, sys_setgid().
80902 */
80903 -int commit_creds(struct cred *new)
80904 +static int __commit_creds(struct cred *new)
80905 {
80906 struct task_struct *task = current;
80907 const struct cred *old = task->real_cred;
80908 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
80909
80910 get_cred(new); /* we will require a ref for the subj creds too */
80911
80912 + gr_set_role_label(task, new->uid, new->gid);
80913 +
80914 /* dumpability changes */
80915 if (!uid_eq(old->euid, new->euid) ||
80916 !gid_eq(old->egid, new->egid) ||
80917 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
80918 put_cred(old);
80919 return 0;
80920 }
80921 +#ifdef CONFIG_GRKERNSEC_SETXID
80922 +extern int set_user(struct cred *new);
80923 +
80924 +void gr_delayed_cred_worker(void)
80925 +{
80926 + const struct cred *new = current->delayed_cred;
80927 + struct cred *ncred;
80928 +
80929 + current->delayed_cred = NULL;
80930 +
80931 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
80932 + // from doing get_cred on it when queueing this
80933 + put_cred(new);
80934 + return;
80935 + } else if (new == NULL)
80936 + return;
80937 +
80938 + ncred = prepare_creds();
80939 + if (!ncred)
80940 + goto die;
80941 + // uids
80942 + ncred->uid = new->uid;
80943 + ncred->euid = new->euid;
80944 + ncred->suid = new->suid;
80945 + ncred->fsuid = new->fsuid;
80946 + // gids
80947 + ncred->gid = new->gid;
80948 + ncred->egid = new->egid;
80949 + ncred->sgid = new->sgid;
80950 + ncred->fsgid = new->fsgid;
80951 + // groups
80952 + if (set_groups(ncred, new->group_info) < 0) {
80953 + abort_creds(ncred);
80954 + goto die;
80955 + }
80956 + // caps
80957 + ncred->securebits = new->securebits;
80958 + ncred->cap_inheritable = new->cap_inheritable;
80959 + ncred->cap_permitted = new->cap_permitted;
80960 + ncred->cap_effective = new->cap_effective;
80961 + ncred->cap_bset = new->cap_bset;
80962 +
80963 + if (set_user(ncred)) {
80964 + abort_creds(ncred);
80965 + goto die;
80966 + }
80967 +
80968 + // from doing get_cred on it when queueing this
80969 + put_cred(new);
80970 +
80971 + __commit_creds(ncred);
80972 + return;
80973 +die:
80974 + // from doing get_cred on it when queueing this
80975 + put_cred(new);
80976 + do_group_exit(SIGKILL);
80977 +}
80978 +#endif
80979 +
80980 +int commit_creds(struct cred *new)
80981 +{
80982 +#ifdef CONFIG_GRKERNSEC_SETXID
80983 + int ret;
80984 + int schedule_it = 0;
80985 + struct task_struct *t;
80986 +
80987 + /* we won't get called with tasklist_lock held for writing
80988 + and interrupts disabled as the cred struct in that case is
80989 + init_cred
80990 + */
80991 + if (grsec_enable_setxid && !current_is_single_threaded() &&
80992 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
80993 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
80994 + schedule_it = 1;
80995 + }
80996 + ret = __commit_creds(new);
80997 + if (schedule_it) {
80998 + rcu_read_lock();
80999 + read_lock(&tasklist_lock);
81000 + for (t = next_thread(current); t != current;
81001 + t = next_thread(t)) {
81002 + if (t->delayed_cred == NULL) {
81003 + t->delayed_cred = get_cred(new);
81004 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
81005 + set_tsk_need_resched(t);
81006 + }
81007 + }
81008 + read_unlock(&tasklist_lock);
81009 + rcu_read_unlock();
81010 + }
81011 + return ret;
81012 +#else
81013 + return __commit_creds(new);
81014 +#endif
81015 +}
81016 +
81017 EXPORT_SYMBOL(commit_creds);
81018
81019 /**
81020 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
81021 index 0506d44..2c20034 100644
81022 --- a/kernel/debug/debug_core.c
81023 +++ b/kernel/debug/debug_core.c
81024 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
81025 */
81026 static atomic_t masters_in_kgdb;
81027 static atomic_t slaves_in_kgdb;
81028 -static atomic_t kgdb_break_tasklet_var;
81029 +static atomic_unchecked_t kgdb_break_tasklet_var;
81030 atomic_t kgdb_setting_breakpoint;
81031
81032 struct task_struct *kgdb_usethread;
81033 @@ -133,7 +133,7 @@ int kgdb_single_step;
81034 static pid_t kgdb_sstep_pid;
81035
81036 /* to keep track of the CPU which is doing the single stepping*/
81037 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81038 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81039
81040 /*
81041 * If you are debugging a problem where roundup (the collection of
81042 @@ -541,7 +541,7 @@ return_normal:
81043 * kernel will only try for the value of sstep_tries before
81044 * giving up and continuing on.
81045 */
81046 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
81047 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
81048 (kgdb_info[cpu].task &&
81049 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
81050 atomic_set(&kgdb_active, -1);
81051 @@ -635,8 +635,8 @@ cpu_master_loop:
81052 }
81053
81054 kgdb_restore:
81055 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
81056 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
81057 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
81058 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
81059 if (kgdb_info[sstep_cpu].task)
81060 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
81061 else
81062 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
81063 static void kgdb_tasklet_bpt(unsigned long ing)
81064 {
81065 kgdb_breakpoint();
81066 - atomic_set(&kgdb_break_tasklet_var, 0);
81067 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
81068 }
81069
81070 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
81071
81072 void kgdb_schedule_breakpoint(void)
81073 {
81074 - if (atomic_read(&kgdb_break_tasklet_var) ||
81075 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
81076 atomic_read(&kgdb_active) != -1 ||
81077 atomic_read(&kgdb_setting_breakpoint))
81078 return;
81079 - atomic_inc(&kgdb_break_tasklet_var);
81080 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
81081 tasklet_schedule(&kgdb_tasklet_breakpoint);
81082 }
81083 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
81084 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
81085 index 00eb8f7..d7e3244 100644
81086 --- a/kernel/debug/kdb/kdb_main.c
81087 +++ b/kernel/debug/kdb/kdb_main.c
81088 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
81089 continue;
81090
81091 kdb_printf("%-20s%8u 0x%p ", mod->name,
81092 - mod->core_size, (void *)mod);
81093 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
81094 #ifdef CONFIG_MODULE_UNLOAD
81095 kdb_printf("%4ld ", module_refcount(mod));
81096 #endif
81097 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
81098 kdb_printf(" (Loading)");
81099 else
81100 kdb_printf(" (Live)");
81101 - kdb_printf(" 0x%p", mod->module_core);
81102 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
81103
81104 #ifdef CONFIG_MODULE_UNLOAD
81105 {
81106 diff --git a/kernel/events/core.c b/kernel/events/core.c
81107 index 953c143..5646bb1 100644
81108 --- a/kernel/events/core.c
81109 +++ b/kernel/events/core.c
81110 @@ -157,8 +157,15 @@ static struct srcu_struct pmus_srcu;
81111 * 0 - disallow raw tracepoint access for unpriv
81112 * 1 - disallow cpu events for unpriv
81113 * 2 - disallow kernel profiling for unpriv
81114 + * 3 - disallow all unpriv perf event use
81115 */
81116 -int sysctl_perf_event_paranoid __read_mostly = 1;
81117 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81118 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
81119 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
81120 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
81121 +#else
81122 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
81123 +#endif
81124
81125 /* Minimum for 512 kiB + 1 user control page */
81126 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
81127 @@ -271,7 +278,7 @@ void perf_sample_event_took(u64 sample_len_ns)
81128 update_perf_cpu_limits();
81129 }
81130
81131 -static atomic64_t perf_event_id;
81132 +static atomic64_unchecked_t perf_event_id;
81133
81134 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
81135 enum event_type_t event_type);
81136 @@ -2940,7 +2947,7 @@ static void __perf_event_read(void *info)
81137
81138 static inline u64 perf_event_count(struct perf_event *event)
81139 {
81140 - return local64_read(&event->count) + atomic64_read(&event->child_count);
81141 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
81142 }
81143
81144 static u64 perf_event_read(struct perf_event *event)
81145 @@ -3308,9 +3315,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
81146 mutex_lock(&event->child_mutex);
81147 total += perf_event_read(event);
81148 *enabled += event->total_time_enabled +
81149 - atomic64_read(&event->child_total_time_enabled);
81150 + atomic64_read_unchecked(&event->child_total_time_enabled);
81151 *running += event->total_time_running +
81152 - atomic64_read(&event->child_total_time_running);
81153 + atomic64_read_unchecked(&event->child_total_time_running);
81154
81155 list_for_each_entry(child, &event->child_list, child_list) {
81156 total += perf_event_read(child);
81157 @@ -3725,10 +3732,10 @@ void perf_event_update_userpage(struct perf_event *event)
81158 userpg->offset -= local64_read(&event->hw.prev_count);
81159
81160 userpg->time_enabled = enabled +
81161 - atomic64_read(&event->child_total_time_enabled);
81162 + atomic64_read_unchecked(&event->child_total_time_enabled);
81163
81164 userpg->time_running = running +
81165 - atomic64_read(&event->child_total_time_running);
81166 + atomic64_read_unchecked(&event->child_total_time_running);
81167
81168 arch_perf_update_userpage(userpg, now);
81169
81170 @@ -4279,7 +4286,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
81171
81172 /* Data. */
81173 sp = perf_user_stack_pointer(regs);
81174 - rem = __output_copy_user(handle, (void *) sp, dump_size);
81175 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
81176 dyn_size = dump_size - rem;
81177
81178 perf_output_skip(handle, rem);
81179 @@ -4370,11 +4377,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
81180 values[n++] = perf_event_count(event);
81181 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
81182 values[n++] = enabled +
81183 - atomic64_read(&event->child_total_time_enabled);
81184 + atomic64_read_unchecked(&event->child_total_time_enabled);
81185 }
81186 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
81187 values[n++] = running +
81188 - atomic64_read(&event->child_total_time_running);
81189 + atomic64_read_unchecked(&event->child_total_time_running);
81190 }
81191 if (read_format & PERF_FORMAT_ID)
81192 values[n++] = primary_event_id(event);
81193 @@ -5112,12 +5119,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
81194 * need to add enough zero bytes after the string to handle
81195 * the 64bit alignment we do later.
81196 */
81197 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
81198 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
81199 if (!buf) {
81200 name = strncpy(tmp, "//enomem", sizeof(tmp));
81201 goto got_name;
81202 }
81203 - name = d_path(&file->f_path, buf, PATH_MAX);
81204 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
81205 if (IS_ERR(name)) {
81206 name = strncpy(tmp, "//toolong", sizeof(tmp));
81207 goto got_name;
81208 @@ -6639,7 +6646,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
81209 event->parent = parent_event;
81210
81211 event->ns = get_pid_ns(task_active_pid_ns(current));
81212 - event->id = atomic64_inc_return(&perf_event_id);
81213 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
81214
81215 event->state = PERF_EVENT_STATE_INACTIVE;
81216
81217 @@ -6938,6 +6945,11 @@ SYSCALL_DEFINE5(perf_event_open,
81218 if (flags & ~PERF_FLAG_ALL)
81219 return -EINVAL;
81220
81221 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81222 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
81223 + return -EACCES;
81224 +#endif
81225 +
81226 err = perf_copy_attr(attr_uptr, &attr);
81227 if (err)
81228 return err;
81229 @@ -7271,10 +7283,10 @@ static void sync_child_event(struct perf_event *child_event,
81230 /*
81231 * Add back the child's count to the parent's count:
81232 */
81233 - atomic64_add(child_val, &parent_event->child_count);
81234 - atomic64_add(child_event->total_time_enabled,
81235 + atomic64_add_unchecked(child_val, &parent_event->child_count);
81236 + atomic64_add_unchecked(child_event->total_time_enabled,
81237 &parent_event->child_total_time_enabled);
81238 - atomic64_add(child_event->total_time_running,
81239 + atomic64_add_unchecked(child_event->total_time_running,
81240 &parent_event->child_total_time_running);
81241
81242 /*
81243 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
81244 index ca65997..60df03d 100644
81245 --- a/kernel/events/internal.h
81246 +++ b/kernel/events/internal.h
81247 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
81248 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
81249 }
81250
81251 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
81252 -static inline unsigned int \
81253 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
81254 +static inline unsigned long \
81255 func_name(struct perf_output_handle *handle, \
81256 - const void *buf, unsigned int len) \
81257 + const void user *buf, unsigned long len) \
81258 { \
81259 unsigned long size, written; \
81260 \
81261 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
81262 return n;
81263 }
81264
81265 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
81266 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
81267
81268 #define MEMCPY_SKIP(dst, src, n) (n)
81269
81270 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
81271 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
81272
81273 #ifndef arch_perf_out_copy_user
81274 #define arch_perf_out_copy_user __copy_from_user_inatomic
81275 #endif
81276
81277 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
81278 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
81279
81280 /* Callchain handling */
81281 extern struct perf_callchain_entry *
81282 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
81283 index ad8e1bd..fed7ba9 100644
81284 --- a/kernel/events/uprobes.c
81285 +++ b/kernel/events/uprobes.c
81286 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
81287 {
81288 struct page *page;
81289 uprobe_opcode_t opcode;
81290 - int result;
81291 + long result;
81292
81293 pagefault_disable();
81294 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
81295 diff --git a/kernel/exit.c b/kernel/exit.c
81296 index a949819..a5f127d 100644
81297 --- a/kernel/exit.c
81298 +++ b/kernel/exit.c
81299 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
81300 struct task_struct *leader;
81301 int zap_leader;
81302 repeat:
81303 +#ifdef CONFIG_NET
81304 + gr_del_task_from_ip_table(p);
81305 +#endif
81306 +
81307 /* don't need to get the RCU readlock here - the process is dead and
81308 * can't be modifying its own credentials. But shut RCU-lockdep up */
81309 rcu_read_lock();
81310 @@ -329,7 +333,7 @@ int allow_signal(int sig)
81311 * know it'll be handled, so that they don't get converted to
81312 * SIGKILL or just silently dropped.
81313 */
81314 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
81315 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
81316 recalc_sigpending();
81317 spin_unlock_irq(&current->sighand->siglock);
81318 return 0;
81319 @@ -698,6 +702,8 @@ void do_exit(long code)
81320 struct task_struct *tsk = current;
81321 int group_dead;
81322
81323 + set_fs(USER_DS);
81324 +
81325 profile_task_exit(tsk);
81326
81327 WARN_ON(blk_needs_flush_plug(tsk));
81328 @@ -714,7 +720,6 @@ void do_exit(long code)
81329 * mm_release()->clear_child_tid() from writing to a user-controlled
81330 * kernel address.
81331 */
81332 - set_fs(USER_DS);
81333
81334 ptrace_event(PTRACE_EVENT_EXIT, code);
81335
81336 @@ -773,6 +778,9 @@ void do_exit(long code)
81337 tsk->exit_code = code;
81338 taskstats_exit(tsk, group_dead);
81339
81340 + gr_acl_handle_psacct(tsk, code);
81341 + gr_acl_handle_exit();
81342 +
81343 exit_mm(tsk);
81344
81345 if (group_dead)
81346 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
81347 * Take down every thread in the group. This is called by fatal signals
81348 * as well as by sys_exit_group (below).
81349 */
81350 -void
81351 +__noreturn void
81352 do_group_exit(int exit_code)
81353 {
81354 struct signal_struct *sig = current->signal;
81355 diff --git a/kernel/fork.c b/kernel/fork.c
81356 index 086fe73..72c1122 100644
81357 --- a/kernel/fork.c
81358 +++ b/kernel/fork.c
81359 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
81360 *stackend = STACK_END_MAGIC; /* for overflow detection */
81361
81362 #ifdef CONFIG_CC_STACKPROTECTOR
81363 - tsk->stack_canary = get_random_int();
81364 + tsk->stack_canary = pax_get_random_long();
81365 #endif
81366
81367 /*
81368 @@ -345,12 +345,80 @@ free_tsk:
81369 }
81370
81371 #ifdef CONFIG_MMU
81372 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81373 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
81374 +{
81375 + struct vm_area_struct *tmp;
81376 + unsigned long charge;
81377 + struct file *file;
81378 + int retval;
81379 +
81380 + charge = 0;
81381 + if (mpnt->vm_flags & VM_ACCOUNT) {
81382 + unsigned long len = vma_pages(mpnt);
81383 +
81384 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81385 + goto fail_nomem;
81386 + charge = len;
81387 + }
81388 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81389 + if (!tmp)
81390 + goto fail_nomem;
81391 + *tmp = *mpnt;
81392 + tmp->vm_mm = mm;
81393 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
81394 + retval = vma_dup_policy(mpnt, tmp);
81395 + if (retval)
81396 + goto fail_nomem_policy;
81397 + if (anon_vma_fork(tmp, mpnt))
81398 + goto fail_nomem_anon_vma_fork;
81399 + tmp->vm_flags &= ~VM_LOCKED;
81400 + tmp->vm_next = tmp->vm_prev = NULL;
81401 + tmp->vm_mirror = NULL;
81402 + file = tmp->vm_file;
81403 + if (file) {
81404 + struct inode *inode = file_inode(file);
81405 + struct address_space *mapping = file->f_mapping;
81406 +
81407 + get_file(file);
81408 + if (tmp->vm_flags & VM_DENYWRITE)
81409 + atomic_dec(&inode->i_writecount);
81410 + mutex_lock(&mapping->i_mmap_mutex);
81411 + if (tmp->vm_flags & VM_SHARED)
81412 + mapping->i_mmap_writable++;
81413 + flush_dcache_mmap_lock(mapping);
81414 + /* insert tmp into the share list, just after mpnt */
81415 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81416 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
81417 + else
81418 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
81419 + flush_dcache_mmap_unlock(mapping);
81420 + mutex_unlock(&mapping->i_mmap_mutex);
81421 + }
81422 +
81423 + /*
81424 + * Clear hugetlb-related page reserves for children. This only
81425 + * affects MAP_PRIVATE mappings. Faults generated by the child
81426 + * are not guaranteed to succeed, even if read-only
81427 + */
81428 + if (is_vm_hugetlb_page(tmp))
81429 + reset_vma_resv_huge_pages(tmp);
81430 +
81431 + return tmp;
81432 +
81433 +fail_nomem_anon_vma_fork:
81434 + mpol_put(vma_policy(tmp));
81435 +fail_nomem_policy:
81436 + kmem_cache_free(vm_area_cachep, tmp);
81437 +fail_nomem:
81438 + vm_unacct_memory(charge);
81439 + return NULL;
81440 +}
81441 +
81442 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81443 {
81444 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
81445 struct rb_node **rb_link, *rb_parent;
81446 int retval;
81447 - unsigned long charge;
81448
81449 uprobe_start_dup_mmap();
81450 down_write(&oldmm->mmap_sem);
81451 @@ -379,55 +447,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81452
81453 prev = NULL;
81454 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
81455 - struct file *file;
81456 -
81457 if (mpnt->vm_flags & VM_DONTCOPY) {
81458 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
81459 -vma_pages(mpnt));
81460 continue;
81461 }
81462 - charge = 0;
81463 - if (mpnt->vm_flags & VM_ACCOUNT) {
81464 - unsigned long len = vma_pages(mpnt);
81465 -
81466 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81467 - goto fail_nomem;
81468 - charge = len;
81469 - }
81470 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81471 - if (!tmp)
81472 - goto fail_nomem;
81473 - *tmp = *mpnt;
81474 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
81475 - retval = vma_dup_policy(mpnt, tmp);
81476 - if (retval)
81477 - goto fail_nomem_policy;
81478 - tmp->vm_mm = mm;
81479 - if (anon_vma_fork(tmp, mpnt))
81480 - goto fail_nomem_anon_vma_fork;
81481 - tmp->vm_flags &= ~VM_LOCKED;
81482 - tmp->vm_next = tmp->vm_prev = NULL;
81483 - file = tmp->vm_file;
81484 - if (file) {
81485 - struct inode *inode = file_inode(file);
81486 - struct address_space *mapping = file->f_mapping;
81487 -
81488 - get_file(file);
81489 - if (tmp->vm_flags & VM_DENYWRITE)
81490 - atomic_dec(&inode->i_writecount);
81491 - mutex_lock(&mapping->i_mmap_mutex);
81492 - if (tmp->vm_flags & VM_SHARED)
81493 - mapping->i_mmap_writable++;
81494 - flush_dcache_mmap_lock(mapping);
81495 - /* insert tmp into the share list, just after mpnt */
81496 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81497 - vma_nonlinear_insert(tmp,
81498 - &mapping->i_mmap_nonlinear);
81499 - else
81500 - vma_interval_tree_insert_after(tmp, mpnt,
81501 - &mapping->i_mmap);
81502 - flush_dcache_mmap_unlock(mapping);
81503 - mutex_unlock(&mapping->i_mmap_mutex);
81504 + tmp = dup_vma(mm, oldmm, mpnt);
81505 + if (!tmp) {
81506 + retval = -ENOMEM;
81507 + goto out;
81508 }
81509
81510 /*
81511 @@ -459,6 +487,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81512 if (retval)
81513 goto out;
81514 }
81515 +
81516 +#ifdef CONFIG_PAX_SEGMEXEC
81517 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
81518 + struct vm_area_struct *mpnt_m;
81519 +
81520 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
81521 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
81522 +
81523 + if (!mpnt->vm_mirror)
81524 + continue;
81525 +
81526 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
81527 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
81528 + mpnt->vm_mirror = mpnt_m;
81529 + } else {
81530 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
81531 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
81532 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
81533 + mpnt->vm_mirror->vm_mirror = mpnt;
81534 + }
81535 + }
81536 + BUG_ON(mpnt_m);
81537 + }
81538 +#endif
81539 +
81540 /* a new mm has just been created */
81541 arch_dup_mmap(oldmm, mm);
81542 retval = 0;
81543 @@ -468,14 +521,6 @@ out:
81544 up_write(&oldmm->mmap_sem);
81545 uprobe_end_dup_mmap();
81546 return retval;
81547 -fail_nomem_anon_vma_fork:
81548 - mpol_put(vma_policy(tmp));
81549 -fail_nomem_policy:
81550 - kmem_cache_free(vm_area_cachep, tmp);
81551 -fail_nomem:
81552 - retval = -ENOMEM;
81553 - vm_unacct_memory(charge);
81554 - goto out;
81555 }
81556
81557 static inline int mm_alloc_pgd(struct mm_struct *mm)
81558 @@ -688,8 +733,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
81559 return ERR_PTR(err);
81560
81561 mm = get_task_mm(task);
81562 - if (mm && mm != current->mm &&
81563 - !ptrace_may_access(task, mode)) {
81564 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
81565 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
81566 mmput(mm);
81567 mm = ERR_PTR(-EACCES);
81568 }
81569 @@ -911,13 +956,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
81570 spin_unlock(&fs->lock);
81571 return -EAGAIN;
81572 }
81573 - fs->users++;
81574 + atomic_inc(&fs->users);
81575 spin_unlock(&fs->lock);
81576 return 0;
81577 }
81578 tsk->fs = copy_fs_struct(fs);
81579 if (!tsk->fs)
81580 return -ENOMEM;
81581 + /* Carry through gr_chroot_dentry and is_chrooted instead
81582 + of recomputing it here. Already copied when the task struct
81583 + is duplicated. This allows pivot_root to not be treated as
81584 + a chroot
81585 + */
81586 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
81587 +
81588 return 0;
81589 }
81590
81591 @@ -1128,7 +1180,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
81592 * parts of the process environment (as per the clone
81593 * flags). The actual kick-off is left to the caller.
81594 */
81595 -static struct task_struct *copy_process(unsigned long clone_flags,
81596 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
81597 unsigned long stack_start,
81598 unsigned long stack_size,
81599 int __user *child_tidptr,
81600 @@ -1200,6 +1252,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81601 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
81602 #endif
81603 retval = -EAGAIN;
81604 +
81605 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
81606 +
81607 if (atomic_read(&p->real_cred->user->processes) >=
81608 task_rlimit(p, RLIMIT_NPROC)) {
81609 if (p->real_cred->user != INIT_USER &&
81610 @@ -1449,6 +1504,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81611 goto bad_fork_free_pid;
81612 }
81613
81614 + /* synchronizes with gr_set_acls()
81615 + we need to call this past the point of no return for fork()
81616 + */
81617 + gr_copy_label(p);
81618 +
81619 if (likely(p->pid)) {
81620 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
81621
81622 @@ -1534,6 +1594,8 @@ bad_fork_cleanup_count:
81623 bad_fork_free:
81624 free_task(p);
81625 fork_out:
81626 + gr_log_forkfail(retval);
81627 +
81628 return ERR_PTR(retval);
81629 }
81630
81631 @@ -1595,6 +1657,7 @@ long do_fork(unsigned long clone_flags,
81632
81633 p = copy_process(clone_flags, stack_start, stack_size,
81634 child_tidptr, NULL, trace);
81635 + add_latent_entropy();
81636 /*
81637 * Do this prior waking up the new thread - the thread pointer
81638 * might get invalid after that point, if the thread exits quickly.
81639 @@ -1609,6 +1672,8 @@ long do_fork(unsigned long clone_flags,
81640 if (clone_flags & CLONE_PARENT_SETTID)
81641 put_user(nr, parent_tidptr);
81642
81643 + gr_handle_brute_check();
81644 +
81645 if (clone_flags & CLONE_VFORK) {
81646 p->vfork_done = &vfork;
81647 init_completion(&vfork);
81648 @@ -1725,7 +1790,7 @@ void __init proc_caches_init(void)
81649 mm_cachep = kmem_cache_create("mm_struct",
81650 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
81651 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
81652 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
81653 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
81654 mmap_init();
81655 nsproxy_cache_init();
81656 }
81657 @@ -1765,7 +1830,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
81658 return 0;
81659
81660 /* don't need lock here; in the worst case we'll do useless copy */
81661 - if (fs->users == 1)
81662 + if (atomic_read(&fs->users) == 1)
81663 return 0;
81664
81665 *new_fsp = copy_fs_struct(fs);
81666 @@ -1872,7 +1937,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
81667 fs = current->fs;
81668 spin_lock(&fs->lock);
81669 current->fs = new_fs;
81670 - if (--fs->users)
81671 + gr_set_chroot_entries(current, &current->fs->root);
81672 + if (atomic_dec_return(&fs->users))
81673 new_fs = NULL;
81674 else
81675 new_fs = fs;
81676 diff --git a/kernel/futex.c b/kernel/futex.c
81677 index c3a1a55..e32b4a98 100644
81678 --- a/kernel/futex.c
81679 +++ b/kernel/futex.c
81680 @@ -54,6 +54,7 @@
81681 #include <linux/mount.h>
81682 #include <linux/pagemap.h>
81683 #include <linux/syscalls.h>
81684 +#include <linux/ptrace.h>
81685 #include <linux/signal.h>
81686 #include <linux/export.h>
81687 #include <linux/magic.h>
81688 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
81689 struct page *page, *page_head;
81690 int err, ro = 0;
81691
81692 +#ifdef CONFIG_PAX_SEGMEXEC
81693 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
81694 + return -EFAULT;
81695 +#endif
81696 +
81697 /*
81698 * The futex address must be "naturally" aligned.
81699 */
81700 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
81701
81702 static int get_futex_value_locked(u32 *dest, u32 __user *from)
81703 {
81704 - int ret;
81705 + unsigned long ret;
81706
81707 pagefault_disable();
81708 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
81709 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
81710 {
81711 u32 curval;
81712 int i;
81713 + mm_segment_t oldfs;
81714
81715 /*
81716 * This will fail and we want it. Some arch implementations do
81717 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
81718 * implementation, the non-functional ones will return
81719 * -ENOSYS.
81720 */
81721 + oldfs = get_fs();
81722 + set_fs(USER_DS);
81723 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
81724 futex_cmpxchg_enabled = 1;
81725 + set_fs(oldfs);
81726
81727 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
81728 plist_head_init(&futex_queues[i].chain);
81729 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
81730 index f9f44fd..29885e4 100644
81731 --- a/kernel/futex_compat.c
81732 +++ b/kernel/futex_compat.c
81733 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
81734 return 0;
81735 }
81736
81737 -static void __user *futex_uaddr(struct robust_list __user *entry,
81738 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
81739 compat_long_t futex_offset)
81740 {
81741 compat_uptr_t base = ptr_to_compat(entry);
81742 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
81743 index 9b22d03..6295b62 100644
81744 --- a/kernel/gcov/base.c
81745 +++ b/kernel/gcov/base.c
81746 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
81747 }
81748
81749 #ifdef CONFIG_MODULES
81750 -static inline int within(void *addr, void *start, unsigned long size)
81751 -{
81752 - return ((addr >= start) && (addr < start + size));
81753 -}
81754 -
81755 /* Update list and generate events when modules are unloaded. */
81756 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81757 void *data)
81758 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81759 prev = NULL;
81760 /* Remove entries located in module from linked list. */
81761 for (info = gcov_info_head; info; info = info->next) {
81762 - if (within(info, mod->module_core, mod->core_size)) {
81763 + if (within_module_core_rw((unsigned long)info, mod)) {
81764 if (prev)
81765 prev->next = info->next;
81766 else
81767 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
81768 index 383319b..56ebb13 100644
81769 --- a/kernel/hrtimer.c
81770 +++ b/kernel/hrtimer.c
81771 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
81772 local_irq_restore(flags);
81773 }
81774
81775 -static void run_hrtimer_softirq(struct softirq_action *h)
81776 +static __latent_entropy void run_hrtimer_softirq(void)
81777 {
81778 hrtimer_peek_ahead_timers();
81779 }
81780 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
81781 index 55fcce6..0e4cf34 100644
81782 --- a/kernel/irq_work.c
81783 +++ b/kernel/irq_work.c
81784 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
81785 return NOTIFY_OK;
81786 }
81787
81788 -static struct notifier_block cpu_notify;
81789 +static struct notifier_block cpu_notify = {
81790 + .notifier_call = irq_work_cpu_notify,
81791 + .priority = 0,
81792 +};
81793
81794 static __init int irq_work_init_cpu_notifier(void)
81795 {
81796 - cpu_notify.notifier_call = irq_work_cpu_notify;
81797 - cpu_notify.priority = 0;
81798 register_cpu_notifier(&cpu_notify);
81799 return 0;
81800 }
81801 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
81802 index 297a924..7290070 100644
81803 --- a/kernel/jump_label.c
81804 +++ b/kernel/jump_label.c
81805 @@ -14,6 +14,7 @@
81806 #include <linux/err.h>
81807 #include <linux/static_key.h>
81808 #include <linux/jump_label_ratelimit.h>
81809 +#include <linux/mm.h>
81810
81811 #ifdef HAVE_JUMP_LABEL
81812
81813 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
81814
81815 size = (((unsigned long)stop - (unsigned long)start)
81816 / sizeof(struct jump_entry));
81817 + pax_open_kernel();
81818 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
81819 + pax_close_kernel();
81820 }
81821
81822 static void jump_label_update(struct static_key *key, int enable);
81823 @@ -358,10 +361,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
81824 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
81825 struct jump_entry *iter;
81826
81827 + pax_open_kernel();
81828 for (iter = iter_start; iter < iter_stop; iter++) {
81829 if (within_module_init(iter->code, mod))
81830 iter->code = 0;
81831 }
81832 + pax_close_kernel();
81833 }
81834
81835 static int
81836 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
81837 index 3127ad5..159d880 100644
81838 --- a/kernel/kallsyms.c
81839 +++ b/kernel/kallsyms.c
81840 @@ -11,6 +11,9 @@
81841 * Changed the compression method from stem compression to "table lookup"
81842 * compression (see scripts/kallsyms.c for a more complete description)
81843 */
81844 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81845 +#define __INCLUDED_BY_HIDESYM 1
81846 +#endif
81847 #include <linux/kallsyms.h>
81848 #include <linux/module.h>
81849 #include <linux/init.h>
81850 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
81851
81852 static inline int is_kernel_inittext(unsigned long addr)
81853 {
81854 + if (system_state != SYSTEM_BOOTING)
81855 + return 0;
81856 +
81857 if (addr >= (unsigned long)_sinittext
81858 && addr <= (unsigned long)_einittext)
81859 return 1;
81860 return 0;
81861 }
81862
81863 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81864 +#ifdef CONFIG_MODULES
81865 +static inline int is_module_text(unsigned long addr)
81866 +{
81867 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
81868 + return 1;
81869 +
81870 + addr = ktla_ktva(addr);
81871 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
81872 +}
81873 +#else
81874 +static inline int is_module_text(unsigned long addr)
81875 +{
81876 + return 0;
81877 +}
81878 +#endif
81879 +#endif
81880 +
81881 static inline int is_kernel_text(unsigned long addr)
81882 {
81883 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
81884 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
81885
81886 static inline int is_kernel(unsigned long addr)
81887 {
81888 +
81889 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81890 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
81891 + return 1;
81892 +
81893 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
81894 +#else
81895 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
81896 +#endif
81897 +
81898 return 1;
81899 return in_gate_area_no_mm(addr);
81900 }
81901
81902 static int is_ksym_addr(unsigned long addr)
81903 {
81904 +
81905 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81906 + if (is_module_text(addr))
81907 + return 0;
81908 +#endif
81909 +
81910 if (all_var)
81911 return is_kernel(addr);
81912
81913 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
81914
81915 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
81916 {
81917 - iter->name[0] = '\0';
81918 iter->nameoff = get_symbol_offset(new_pos);
81919 iter->pos = new_pos;
81920 }
81921 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
81922 {
81923 struct kallsym_iter *iter = m->private;
81924
81925 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81926 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
81927 + return 0;
81928 +#endif
81929 +
81930 /* Some debugging symbols have no name. Ignore them. */
81931 if (!iter->name[0])
81932 return 0;
81933 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
81934 */
81935 type = iter->exported ? toupper(iter->type) :
81936 tolower(iter->type);
81937 +
81938 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
81939 type, iter->name, iter->module_name);
81940 } else
81941 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
81942 struct kallsym_iter *iter;
81943 int ret;
81944
81945 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
81946 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
81947 if (!iter)
81948 return -ENOMEM;
81949 reset_iter(iter, 0);
81950 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
81951 index e30ac0f..3528cac 100644
81952 --- a/kernel/kcmp.c
81953 +++ b/kernel/kcmp.c
81954 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
81955 struct task_struct *task1, *task2;
81956 int ret;
81957
81958 +#ifdef CONFIG_GRKERNSEC
81959 + return -ENOSYS;
81960 +#endif
81961 +
81962 rcu_read_lock();
81963
81964 /*
81965 diff --git a/kernel/kexec.c b/kernel/kexec.c
81966 index 2a74f30..d139351 100644
81967 --- a/kernel/kexec.c
81968 +++ b/kernel/kexec.c
81969 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
81970 unsigned long flags)
81971 {
81972 struct compat_kexec_segment in;
81973 - struct kexec_segment out, __user *ksegments;
81974 + struct kexec_segment out;
81975 + struct kexec_segment __user *ksegments;
81976 unsigned long i, result;
81977
81978 /* Don't allow clients that don't understand the native
81979 diff --git a/kernel/kmod.c b/kernel/kmod.c
81980 index b086006..6d2e579 100644
81981 --- a/kernel/kmod.c
81982 +++ b/kernel/kmod.c
81983 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
81984 kfree(info->argv);
81985 }
81986
81987 -static int call_modprobe(char *module_name, int wait)
81988 +static int call_modprobe(char *module_name, char *module_param, int wait)
81989 {
81990 struct subprocess_info *info;
81991 static char *envp[] = {
81992 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81993 NULL
81994 };
81995
81996 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81997 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81998 if (!argv)
81999 goto out;
82000
82001 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
82002 argv[1] = "-q";
82003 argv[2] = "--";
82004 argv[3] = module_name; /* check free_modprobe_argv() */
82005 - argv[4] = NULL;
82006 + argv[4] = module_param;
82007 + argv[5] = NULL;
82008
82009 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
82010 NULL, free_modprobe_argv, NULL);
82011 @@ -129,9 +130,8 @@ out:
82012 * If module auto-loading support is disabled then this function
82013 * becomes a no-operation.
82014 */
82015 -int __request_module(bool wait, const char *fmt, ...)
82016 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
82017 {
82018 - va_list args;
82019 char module_name[MODULE_NAME_LEN];
82020 unsigned int max_modprobes;
82021 int ret;
82022 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
82023 if (!modprobe_path[0])
82024 return 0;
82025
82026 - va_start(args, fmt);
82027 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
82028 - va_end(args);
82029 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
82030 if (ret >= MODULE_NAME_LEN)
82031 return -ENAMETOOLONG;
82032
82033 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
82034 if (ret)
82035 return ret;
82036
82037 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82038 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82039 + /* hack to workaround consolekit/udisks stupidity */
82040 + read_lock(&tasklist_lock);
82041 + if (!strcmp(current->comm, "mount") &&
82042 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
82043 + read_unlock(&tasklist_lock);
82044 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
82045 + return -EPERM;
82046 + }
82047 + read_unlock(&tasklist_lock);
82048 + }
82049 +#endif
82050 +
82051 /* If modprobe needs a service that is in a module, we get a recursive
82052 * loop. Limit the number of running kmod threads to max_threads/2 or
82053 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
82054 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
82055
82056 trace_module_request(module_name, wait, _RET_IP_);
82057
82058 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82059 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82060
82061 atomic_dec(&kmod_concurrent);
82062 return ret;
82063 }
82064 +
82065 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
82066 +{
82067 + va_list args;
82068 + int ret;
82069 +
82070 + va_start(args, fmt);
82071 + ret = ____request_module(wait, module_param, fmt, args);
82072 + va_end(args);
82073 +
82074 + return ret;
82075 +}
82076 +
82077 +int __request_module(bool wait, const char *fmt, ...)
82078 +{
82079 + va_list args;
82080 + int ret;
82081 +
82082 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82083 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82084 + char module_param[MODULE_NAME_LEN];
82085 +
82086 + memset(module_param, 0, sizeof(module_param));
82087 +
82088 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
82089 +
82090 + va_start(args, fmt);
82091 + ret = ____request_module(wait, module_param, fmt, args);
82092 + va_end(args);
82093 +
82094 + return ret;
82095 + }
82096 +#endif
82097 +
82098 + va_start(args, fmt);
82099 + ret = ____request_module(wait, NULL, fmt, args);
82100 + va_end(args);
82101 +
82102 + return ret;
82103 +}
82104 +
82105 EXPORT_SYMBOL(__request_module);
82106 #endif /* CONFIG_MODULES */
82107
82108 @@ -218,6 +271,19 @@ static int ____call_usermodehelper(void *data)
82109 */
82110 set_user_nice(current, 0);
82111
82112 +#ifdef CONFIG_GRKERNSEC
82113 + /* this is race-free as far as userland is concerned as we copied
82114 + out the path to be used prior to this point and are now operating
82115 + on that copy
82116 + */
82117 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
82118 + strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7)) || strstr(sub_info->path, "..")) {
82119 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and system library paths\n", sub_info->path);
82120 + retval = -EPERM;
82121 + goto fail;
82122 + }
82123 +#endif
82124 +
82125 retval = -ENOMEM;
82126 new = prepare_kernel_cred(current);
82127 if (!new)
82128 @@ -260,6 +326,10 @@ static int call_helper(void *data)
82129
82130 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
82131 {
82132 +#ifdef CONFIG_GRKERNSEC
82133 + kfree(info->path);
82134 + info->path = info->origpath;
82135 +#endif
82136 if (info->cleanup)
82137 (*info->cleanup)(info);
82138 kfree(info);
82139 @@ -303,7 +373,7 @@ static int wait_for_helper(void *data)
82140 *
82141 * Thus the __user pointer cast is valid here.
82142 */
82143 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
82144 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
82145
82146 /*
82147 * If ret is 0, either ____call_usermodehelper failed and the
82148 @@ -542,7 +612,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
82149 goto out;
82150
82151 INIT_WORK(&sub_info->work, __call_usermodehelper);
82152 +#ifdef CONFIG_GRKERNSEC
82153 + sub_info->origpath = path;
82154 + sub_info->path = kstrdup(path, gfp_mask);
82155 +#else
82156 sub_info->path = path;
82157 +#endif
82158 sub_info->argv = argv;
82159 sub_info->envp = envp;
82160
82161 @@ -650,7 +725,7 @@ EXPORT_SYMBOL(call_usermodehelper);
82162 static int proc_cap_handler(struct ctl_table *table, int write,
82163 void __user *buffer, size_t *lenp, loff_t *ppos)
82164 {
82165 - struct ctl_table t;
82166 + ctl_table_no_const t;
82167 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
82168 kernel_cap_t new_cap;
82169 int err, i;
82170 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
82171 index a0d367a..11c18b6 100644
82172 --- a/kernel/kprobes.c
82173 +++ b/kernel/kprobes.c
82174 @@ -31,6 +31,9 @@
82175 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
82176 * <prasanna@in.ibm.com> added function-return probes.
82177 */
82178 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82179 +#define __INCLUDED_BY_HIDESYM 1
82180 +#endif
82181 #include <linux/kprobes.h>
82182 #include <linux/hash.h>
82183 #include <linux/init.h>
82184 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
82185
82186 static void *alloc_insn_page(void)
82187 {
82188 - return module_alloc(PAGE_SIZE);
82189 + return module_alloc_exec(PAGE_SIZE);
82190 }
82191
82192 static void free_insn_page(void *page)
82193 {
82194 - module_free(NULL, page);
82195 + module_free_exec(NULL, page);
82196 }
82197
82198 struct kprobe_insn_cache kprobe_insn_slots = {
82199 @@ -2066,7 +2069,7 @@ static int __init init_kprobes(void)
82200 {
82201 int i, err = 0;
82202 unsigned long offset = 0, size = 0;
82203 - char *modname, namebuf[128];
82204 + char *modname, namebuf[KSYM_NAME_LEN];
82205 const char *symbol_name;
82206 void *addr;
82207 struct kprobe_blackpoint *kb;
82208 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
82209 kprobe_type = "k";
82210
82211 if (sym)
82212 - seq_printf(pi, "%p %s %s+0x%x %s ",
82213 + seq_printf(pi, "%pK %s %s+0x%x %s ",
82214 p->addr, kprobe_type, sym, offset,
82215 (modname ? modname : " "));
82216 else
82217 - seq_printf(pi, "%p %s %p ",
82218 + seq_printf(pi, "%pK %s %pK ",
82219 p->addr, kprobe_type, p->addr);
82220
82221 if (!pp)
82222 @@ -2192,7 +2195,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
82223 const char *sym = NULL;
82224 unsigned int i = *(loff_t *) v;
82225 unsigned long offset = 0;
82226 - char *modname, namebuf[128];
82227 + char *modname, namebuf[KSYM_NAME_LEN];
82228
82229 head = &kprobe_table[i];
82230 preempt_disable();
82231 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
82232 index 9659d38..bffd520 100644
82233 --- a/kernel/ksysfs.c
82234 +++ b/kernel/ksysfs.c
82235 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
82236 {
82237 if (count+1 > UEVENT_HELPER_PATH_LEN)
82238 return -ENOENT;
82239 + if (!capable(CAP_SYS_ADMIN))
82240 + return -EPERM;
82241 memcpy(uevent_helper, buf, count);
82242 uevent_helper[count] = '\0';
82243 if (count && uevent_helper[count-1] == '\n')
82244 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
82245 return count;
82246 }
82247
82248 -static struct bin_attribute notes_attr = {
82249 +static bin_attribute_no_const notes_attr __read_only = {
82250 .attr = {
82251 .name = "notes",
82252 .mode = S_IRUGO,
82253 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
82254 index e16c45b..6f49c48 100644
82255 --- a/kernel/lockdep.c
82256 +++ b/kernel/lockdep.c
82257 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
82258 end = (unsigned long) &_end,
82259 addr = (unsigned long) obj;
82260
82261 +#ifdef CONFIG_PAX_KERNEXEC
82262 + start = ktla_ktva(start);
82263 +#endif
82264 +
82265 /*
82266 * static variable?
82267 */
82268 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
82269 if (!static_obj(lock->key)) {
82270 debug_locks_off();
82271 printk("INFO: trying to register non-static key.\n");
82272 + printk("lock:%pS key:%pS.\n", lock, lock->key);
82273 printk("the code is fine but needs lockdep annotation.\n");
82274 printk("turning off the locking correctness validator.\n");
82275 dump_stack();
82276 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
82277 if (!class)
82278 return 0;
82279 }
82280 - atomic_inc((atomic_t *)&class->ops);
82281 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
82282 if (very_verbose(class)) {
82283 printk("\nacquire class [%p] %s", class->key, class->name);
82284 if (class->name_version > 1)
82285 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
82286 index b2c71c5..7b88d63 100644
82287 --- a/kernel/lockdep_proc.c
82288 +++ b/kernel/lockdep_proc.c
82289 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
82290 return 0;
82291 }
82292
82293 - seq_printf(m, "%p", class->key);
82294 + seq_printf(m, "%pK", class->key);
82295 #ifdef CONFIG_DEBUG_LOCKDEP
82296 seq_printf(m, " OPS:%8ld", class->ops);
82297 #endif
82298 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
82299
82300 list_for_each_entry(entry, &class->locks_after, entry) {
82301 if (entry->distance == 1) {
82302 - seq_printf(m, " -> [%p] ", entry->class->key);
82303 + seq_printf(m, " -> [%pK] ", entry->class->key);
82304 print_name(m, entry->class);
82305 seq_puts(m, "\n");
82306 }
82307 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
82308 if (!class->key)
82309 continue;
82310
82311 - seq_printf(m, "[%p] ", class->key);
82312 + seq_printf(m, "[%pK] ", class->key);
82313 print_name(m, class);
82314 seq_puts(m, "\n");
82315 }
82316 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82317 if (!i)
82318 seq_line(m, '-', 40-namelen, namelen);
82319
82320 - snprintf(ip, sizeof(ip), "[<%p>]",
82321 + snprintf(ip, sizeof(ip), "[<%pK>]",
82322 (void *)class->contention_point[i]);
82323 seq_printf(m, "%40s %14lu %29s %pS\n",
82324 name, stats->contention_point[i],
82325 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82326 if (!i)
82327 seq_line(m, '-', 40-namelen, namelen);
82328
82329 - snprintf(ip, sizeof(ip), "[<%p>]",
82330 + snprintf(ip, sizeof(ip), "[<%pK>]",
82331 (void *)class->contending_point[i]);
82332 seq_printf(m, "%40s %14lu %29s %pS\n",
82333 name, stats->contending_point[i],
82334 diff --git a/kernel/module.c b/kernel/module.c
82335 index dc58274..3ddfa55 100644
82336 --- a/kernel/module.c
82337 +++ b/kernel/module.c
82338 @@ -61,6 +61,7 @@
82339 #include <linux/pfn.h>
82340 #include <linux/bsearch.h>
82341 #include <linux/fips.h>
82342 +#include <linux/grsecurity.h>
82343 #include <uapi/linux/module.h>
82344 #include "module-internal.h"
82345
82346 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
82347
82348 /* Bounds of module allocation, for speeding __module_address.
82349 * Protected by module_mutex. */
82350 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
82351 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
82352 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
82353
82354 int register_module_notifier(struct notifier_block * nb)
82355 {
82356 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82357 return true;
82358
82359 list_for_each_entry_rcu(mod, &modules, list) {
82360 - struct symsearch arr[] = {
82361 + struct symsearch modarr[] = {
82362 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
82363 NOT_GPL_ONLY, false },
82364 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
82365 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82366 if (mod->state == MODULE_STATE_UNFORMED)
82367 continue;
82368
82369 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
82370 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
82371 return true;
82372 }
82373 return false;
82374 @@ -491,7 +493,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
82375 if (!pcpusec->sh_size)
82376 return 0;
82377
82378 - if (align > PAGE_SIZE) {
82379 + if (align-1 >= PAGE_SIZE) {
82380 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
82381 mod->name, align, PAGE_SIZE);
82382 align = PAGE_SIZE;
82383 @@ -1097,7 +1099,7 @@ struct module_attribute module_uevent =
82384 static ssize_t show_coresize(struct module_attribute *mattr,
82385 struct module_kobject *mk, char *buffer)
82386 {
82387 - return sprintf(buffer, "%u\n", mk->mod->core_size);
82388 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
82389 }
82390
82391 static struct module_attribute modinfo_coresize =
82392 @@ -1106,7 +1108,7 @@ static struct module_attribute modinfo_coresize =
82393 static ssize_t show_initsize(struct module_attribute *mattr,
82394 struct module_kobject *mk, char *buffer)
82395 {
82396 - return sprintf(buffer, "%u\n", mk->mod->init_size);
82397 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
82398 }
82399
82400 static struct module_attribute modinfo_initsize =
82401 @@ -1321,7 +1323,7 @@ resolve_symbol_wait(struct module *mod,
82402 */
82403 #ifdef CONFIG_SYSFS
82404
82405 -#ifdef CONFIG_KALLSYMS
82406 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82407 static inline bool sect_empty(const Elf_Shdr *sect)
82408 {
82409 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
82410 @@ -1461,7 +1463,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
82411 {
82412 unsigned int notes, loaded, i;
82413 struct module_notes_attrs *notes_attrs;
82414 - struct bin_attribute *nattr;
82415 + bin_attribute_no_const *nattr;
82416
82417 /* failed to create section attributes, so can't create notes */
82418 if (!mod->sect_attrs)
82419 @@ -1573,7 +1575,7 @@ static void del_usage_links(struct module *mod)
82420 static int module_add_modinfo_attrs(struct module *mod)
82421 {
82422 struct module_attribute *attr;
82423 - struct module_attribute *temp_attr;
82424 + module_attribute_no_const *temp_attr;
82425 int error = 0;
82426 int i;
82427
82428 @@ -1795,21 +1797,21 @@ static void set_section_ro_nx(void *base,
82429
82430 static void unset_module_core_ro_nx(struct module *mod)
82431 {
82432 - set_page_attributes(mod->module_core + mod->core_text_size,
82433 - mod->module_core + mod->core_size,
82434 + set_page_attributes(mod->module_core_rw,
82435 + mod->module_core_rw + mod->core_size_rw,
82436 set_memory_x);
82437 - set_page_attributes(mod->module_core,
82438 - mod->module_core + mod->core_ro_size,
82439 + set_page_attributes(mod->module_core_rx,
82440 + mod->module_core_rx + mod->core_size_rx,
82441 set_memory_rw);
82442 }
82443
82444 static void unset_module_init_ro_nx(struct module *mod)
82445 {
82446 - set_page_attributes(mod->module_init + mod->init_text_size,
82447 - mod->module_init + mod->init_size,
82448 + set_page_attributes(mod->module_init_rw,
82449 + mod->module_init_rw + mod->init_size_rw,
82450 set_memory_x);
82451 - set_page_attributes(mod->module_init,
82452 - mod->module_init + mod->init_ro_size,
82453 + set_page_attributes(mod->module_init_rx,
82454 + mod->module_init_rx + mod->init_size_rx,
82455 set_memory_rw);
82456 }
82457
82458 @@ -1822,14 +1824,14 @@ void set_all_modules_text_rw(void)
82459 list_for_each_entry_rcu(mod, &modules, list) {
82460 if (mod->state == MODULE_STATE_UNFORMED)
82461 continue;
82462 - if ((mod->module_core) && (mod->core_text_size)) {
82463 - set_page_attributes(mod->module_core,
82464 - mod->module_core + mod->core_text_size,
82465 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82466 + set_page_attributes(mod->module_core_rx,
82467 + mod->module_core_rx + mod->core_size_rx,
82468 set_memory_rw);
82469 }
82470 - if ((mod->module_init) && (mod->init_text_size)) {
82471 - set_page_attributes(mod->module_init,
82472 - mod->module_init + mod->init_text_size,
82473 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82474 + set_page_attributes(mod->module_init_rx,
82475 + mod->module_init_rx + mod->init_size_rx,
82476 set_memory_rw);
82477 }
82478 }
82479 @@ -1845,14 +1847,14 @@ void set_all_modules_text_ro(void)
82480 list_for_each_entry_rcu(mod, &modules, list) {
82481 if (mod->state == MODULE_STATE_UNFORMED)
82482 continue;
82483 - if ((mod->module_core) && (mod->core_text_size)) {
82484 - set_page_attributes(mod->module_core,
82485 - mod->module_core + mod->core_text_size,
82486 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82487 + set_page_attributes(mod->module_core_rx,
82488 + mod->module_core_rx + mod->core_size_rx,
82489 set_memory_ro);
82490 }
82491 - if ((mod->module_init) && (mod->init_text_size)) {
82492 - set_page_attributes(mod->module_init,
82493 - mod->module_init + mod->init_text_size,
82494 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82495 + set_page_attributes(mod->module_init_rx,
82496 + mod->module_init_rx + mod->init_size_rx,
82497 set_memory_ro);
82498 }
82499 }
82500 @@ -1903,16 +1905,19 @@ static void free_module(struct module *mod)
82501
82502 /* This may be NULL, but that's OK */
82503 unset_module_init_ro_nx(mod);
82504 - module_free(mod, mod->module_init);
82505 + module_free(mod, mod->module_init_rw);
82506 + module_free_exec(mod, mod->module_init_rx);
82507 kfree(mod->args);
82508 percpu_modfree(mod);
82509
82510 /* Free lock-classes: */
82511 - lockdep_free_key_range(mod->module_core, mod->core_size);
82512 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
82513 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
82514
82515 /* Finally, free the core (containing the module structure) */
82516 unset_module_core_ro_nx(mod);
82517 - module_free(mod, mod->module_core);
82518 + module_free_exec(mod, mod->module_core_rx);
82519 + module_free(mod, mod->module_core_rw);
82520
82521 #ifdef CONFIG_MPU
82522 update_protections(current->mm);
82523 @@ -1982,9 +1987,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82524 int ret = 0;
82525 const struct kernel_symbol *ksym;
82526
82527 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82528 + int is_fs_load = 0;
82529 + int register_filesystem_found = 0;
82530 + char *p;
82531 +
82532 + p = strstr(mod->args, "grsec_modharden_fs");
82533 + if (p) {
82534 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
82535 + /* copy \0 as well */
82536 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
82537 + is_fs_load = 1;
82538 + }
82539 +#endif
82540 +
82541 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
82542 const char *name = info->strtab + sym[i].st_name;
82543
82544 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82545 + /* it's a real shame this will never get ripped and copied
82546 + upstream! ;(
82547 + */
82548 + if (is_fs_load && !strcmp(name, "register_filesystem"))
82549 + register_filesystem_found = 1;
82550 +#endif
82551 +
82552 switch (sym[i].st_shndx) {
82553 case SHN_COMMON:
82554 /* We compiled with -fno-common. These are not
82555 @@ -2005,7 +2032,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82556 ksym = resolve_symbol_wait(mod, info, name);
82557 /* Ok if resolved. */
82558 if (ksym && !IS_ERR(ksym)) {
82559 + pax_open_kernel();
82560 sym[i].st_value = ksym->value;
82561 + pax_close_kernel();
82562 break;
82563 }
82564
82565 @@ -2024,11 +2053,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82566 secbase = (unsigned long)mod_percpu(mod);
82567 else
82568 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
82569 + pax_open_kernel();
82570 sym[i].st_value += secbase;
82571 + pax_close_kernel();
82572 break;
82573 }
82574 }
82575
82576 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82577 + if (is_fs_load && !register_filesystem_found) {
82578 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
82579 + ret = -EPERM;
82580 + }
82581 +#endif
82582 +
82583 return ret;
82584 }
82585
82586 @@ -2112,22 +2150,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
82587 || s->sh_entsize != ~0UL
82588 || strstarts(sname, ".init"))
82589 continue;
82590 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
82591 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82592 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
82593 + else
82594 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
82595 pr_debug("\t%s\n", sname);
82596 }
82597 - switch (m) {
82598 - case 0: /* executable */
82599 - mod->core_size = debug_align(mod->core_size);
82600 - mod->core_text_size = mod->core_size;
82601 - break;
82602 - case 1: /* RO: text and ro-data */
82603 - mod->core_size = debug_align(mod->core_size);
82604 - mod->core_ro_size = mod->core_size;
82605 - break;
82606 - case 3: /* whole core */
82607 - mod->core_size = debug_align(mod->core_size);
82608 - break;
82609 - }
82610 }
82611
82612 pr_debug("Init section allocation order:\n");
82613 @@ -2141,23 +2169,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
82614 || s->sh_entsize != ~0UL
82615 || !strstarts(sname, ".init"))
82616 continue;
82617 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
82618 - | INIT_OFFSET_MASK);
82619 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82620 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
82621 + else
82622 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
82623 + s->sh_entsize |= INIT_OFFSET_MASK;
82624 pr_debug("\t%s\n", sname);
82625 }
82626 - switch (m) {
82627 - case 0: /* executable */
82628 - mod->init_size = debug_align(mod->init_size);
82629 - mod->init_text_size = mod->init_size;
82630 - break;
82631 - case 1: /* RO: text and ro-data */
82632 - mod->init_size = debug_align(mod->init_size);
82633 - mod->init_ro_size = mod->init_size;
82634 - break;
82635 - case 3: /* whole init */
82636 - mod->init_size = debug_align(mod->init_size);
82637 - break;
82638 - }
82639 }
82640 }
82641
82642 @@ -2330,7 +2348,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82643
82644 /* Put symbol section at end of init part of module. */
82645 symsect->sh_flags |= SHF_ALLOC;
82646 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
82647 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
82648 info->index.sym) | INIT_OFFSET_MASK;
82649 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
82650
82651 @@ -2347,13 +2365,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82652 }
82653
82654 /* Append room for core symbols at end of core part. */
82655 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
82656 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
82657 - mod->core_size += strtab_size;
82658 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
82659 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
82660 + mod->core_size_rx += strtab_size;
82661
82662 /* Put string table section at end of init part of module. */
82663 strsect->sh_flags |= SHF_ALLOC;
82664 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
82665 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
82666 info->index.str) | INIT_OFFSET_MASK;
82667 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
82668 }
82669 @@ -2371,12 +2389,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82670 /* Make sure we get permanent strtab: don't use info->strtab. */
82671 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
82672
82673 + pax_open_kernel();
82674 +
82675 /* Set types up while we still have access to sections. */
82676 for (i = 0; i < mod->num_symtab; i++)
82677 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
82678
82679 - mod->core_symtab = dst = mod->module_core + info->symoffs;
82680 - mod->core_strtab = s = mod->module_core + info->stroffs;
82681 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
82682 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
82683 src = mod->symtab;
82684 for (ndst = i = 0; i < mod->num_symtab; i++) {
82685 if (i == 0 ||
82686 @@ -2388,6 +2408,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82687 }
82688 }
82689 mod->core_num_syms = ndst;
82690 +
82691 + pax_close_kernel();
82692 }
82693 #else
82694 static inline void layout_symtab(struct module *mod, struct load_info *info)
82695 @@ -2421,17 +2443,33 @@ void * __weak module_alloc(unsigned long size)
82696 return vmalloc_exec(size);
82697 }
82698
82699 -static void *module_alloc_update_bounds(unsigned long size)
82700 +static void *module_alloc_update_bounds_rw(unsigned long size)
82701 {
82702 void *ret = module_alloc(size);
82703
82704 if (ret) {
82705 mutex_lock(&module_mutex);
82706 /* Update module bounds. */
82707 - if ((unsigned long)ret < module_addr_min)
82708 - module_addr_min = (unsigned long)ret;
82709 - if ((unsigned long)ret + size > module_addr_max)
82710 - module_addr_max = (unsigned long)ret + size;
82711 + if ((unsigned long)ret < module_addr_min_rw)
82712 + module_addr_min_rw = (unsigned long)ret;
82713 + if ((unsigned long)ret + size > module_addr_max_rw)
82714 + module_addr_max_rw = (unsigned long)ret + size;
82715 + mutex_unlock(&module_mutex);
82716 + }
82717 + return ret;
82718 +}
82719 +
82720 +static void *module_alloc_update_bounds_rx(unsigned long size)
82721 +{
82722 + void *ret = module_alloc_exec(size);
82723 +
82724 + if (ret) {
82725 + mutex_lock(&module_mutex);
82726 + /* Update module bounds. */
82727 + if ((unsigned long)ret < module_addr_min_rx)
82728 + module_addr_min_rx = (unsigned long)ret;
82729 + if ((unsigned long)ret + size > module_addr_max_rx)
82730 + module_addr_max_rx = (unsigned long)ret + size;
82731 mutex_unlock(&module_mutex);
82732 }
82733 return ret;
82734 @@ -2706,8 +2744,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
82735 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82736 {
82737 const char *modmagic = get_modinfo(info, "vermagic");
82738 + const char *license = get_modinfo(info, "license");
82739 int err;
82740
82741 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
82742 + if (!license || !license_is_gpl_compatible(license))
82743 + return -ENOEXEC;
82744 +#endif
82745 +
82746 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
82747 modmagic = NULL;
82748
82749 @@ -2733,7 +2777,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82750 }
82751
82752 /* Set up license info based on the info section */
82753 - set_license(mod, get_modinfo(info, "license"));
82754 + set_license(mod, license);
82755
82756 return 0;
82757 }
82758 @@ -2814,7 +2858,7 @@ static int move_module(struct module *mod, struct load_info *info)
82759 void *ptr;
82760
82761 /* Do the allocs. */
82762 - ptr = module_alloc_update_bounds(mod->core_size);
82763 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
82764 /*
82765 * The pointer to this block is stored in the module structure
82766 * which is inside the block. Just mark it as not being a
82767 @@ -2824,11 +2868,11 @@ static int move_module(struct module *mod, struct load_info *info)
82768 if (!ptr)
82769 return -ENOMEM;
82770
82771 - memset(ptr, 0, mod->core_size);
82772 - mod->module_core = ptr;
82773 + memset(ptr, 0, mod->core_size_rw);
82774 + mod->module_core_rw = ptr;
82775
82776 - if (mod->init_size) {
82777 - ptr = module_alloc_update_bounds(mod->init_size);
82778 + if (mod->init_size_rw) {
82779 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
82780 /*
82781 * The pointer to this block is stored in the module structure
82782 * which is inside the block. This block doesn't need to be
82783 @@ -2837,13 +2881,45 @@ static int move_module(struct module *mod, struct load_info *info)
82784 */
82785 kmemleak_ignore(ptr);
82786 if (!ptr) {
82787 - module_free(mod, mod->module_core);
82788 + module_free(mod, mod->module_core_rw);
82789 return -ENOMEM;
82790 }
82791 - memset(ptr, 0, mod->init_size);
82792 - mod->module_init = ptr;
82793 + memset(ptr, 0, mod->init_size_rw);
82794 + mod->module_init_rw = ptr;
82795 } else
82796 - mod->module_init = NULL;
82797 + mod->module_init_rw = NULL;
82798 +
82799 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
82800 + kmemleak_not_leak(ptr);
82801 + if (!ptr) {
82802 + if (mod->module_init_rw)
82803 + module_free(mod, mod->module_init_rw);
82804 + module_free(mod, mod->module_core_rw);
82805 + return -ENOMEM;
82806 + }
82807 +
82808 + pax_open_kernel();
82809 + memset(ptr, 0, mod->core_size_rx);
82810 + pax_close_kernel();
82811 + mod->module_core_rx = ptr;
82812 +
82813 + if (mod->init_size_rx) {
82814 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
82815 + kmemleak_ignore(ptr);
82816 + if (!ptr && mod->init_size_rx) {
82817 + module_free_exec(mod, mod->module_core_rx);
82818 + if (mod->module_init_rw)
82819 + module_free(mod, mod->module_init_rw);
82820 + module_free(mod, mod->module_core_rw);
82821 + return -ENOMEM;
82822 + }
82823 +
82824 + pax_open_kernel();
82825 + memset(ptr, 0, mod->init_size_rx);
82826 + pax_close_kernel();
82827 + mod->module_init_rx = ptr;
82828 + } else
82829 + mod->module_init_rx = NULL;
82830
82831 /* Transfer each section which specifies SHF_ALLOC */
82832 pr_debug("final section addresses:\n");
82833 @@ -2854,16 +2930,45 @@ static int move_module(struct module *mod, struct load_info *info)
82834 if (!(shdr->sh_flags & SHF_ALLOC))
82835 continue;
82836
82837 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
82838 - dest = mod->module_init
82839 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82840 - else
82841 - dest = mod->module_core + shdr->sh_entsize;
82842 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
82843 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82844 + dest = mod->module_init_rw
82845 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82846 + else
82847 + dest = mod->module_init_rx
82848 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82849 + } else {
82850 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82851 + dest = mod->module_core_rw + shdr->sh_entsize;
82852 + else
82853 + dest = mod->module_core_rx + shdr->sh_entsize;
82854 + }
82855 +
82856 + if (shdr->sh_type != SHT_NOBITS) {
82857 +
82858 +#ifdef CONFIG_PAX_KERNEXEC
82859 +#ifdef CONFIG_X86_64
82860 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
82861 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
82862 +#endif
82863 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
82864 + pax_open_kernel();
82865 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
82866 + pax_close_kernel();
82867 + } else
82868 +#endif
82869
82870 - if (shdr->sh_type != SHT_NOBITS)
82871 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
82872 + }
82873 /* Update sh_addr to point to copy in image. */
82874 - shdr->sh_addr = (unsigned long)dest;
82875 +
82876 +#ifdef CONFIG_PAX_KERNEXEC
82877 + if (shdr->sh_flags & SHF_EXECINSTR)
82878 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
82879 + else
82880 +#endif
82881 +
82882 + shdr->sh_addr = (unsigned long)dest;
82883 pr_debug("\t0x%lx %s\n",
82884 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
82885 }
82886 @@ -2920,12 +3025,12 @@ static void flush_module_icache(const struct module *mod)
82887 * Do it before processing of module parameters, so the module
82888 * can provide parameter accessor functions of its own.
82889 */
82890 - if (mod->module_init)
82891 - flush_icache_range((unsigned long)mod->module_init,
82892 - (unsigned long)mod->module_init
82893 - + mod->init_size);
82894 - flush_icache_range((unsigned long)mod->module_core,
82895 - (unsigned long)mod->module_core + mod->core_size);
82896 + if (mod->module_init_rx)
82897 + flush_icache_range((unsigned long)mod->module_init_rx,
82898 + (unsigned long)mod->module_init_rx
82899 + + mod->init_size_rx);
82900 + flush_icache_range((unsigned long)mod->module_core_rx,
82901 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
82902
82903 set_fs(old_fs);
82904 }
82905 @@ -2982,8 +3087,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
82906 static void module_deallocate(struct module *mod, struct load_info *info)
82907 {
82908 percpu_modfree(mod);
82909 - module_free(mod, mod->module_init);
82910 - module_free(mod, mod->module_core);
82911 + module_free_exec(mod, mod->module_init_rx);
82912 + module_free_exec(mod, mod->module_core_rx);
82913 + module_free(mod, mod->module_init_rw);
82914 + module_free(mod, mod->module_core_rw);
82915 }
82916
82917 int __weak module_finalize(const Elf_Ehdr *hdr,
82918 @@ -2996,7 +3103,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
82919 static int post_relocation(struct module *mod, const struct load_info *info)
82920 {
82921 /* Sort exception table now relocations are done. */
82922 + pax_open_kernel();
82923 sort_extable(mod->extable, mod->extable + mod->num_exentries);
82924 + pax_close_kernel();
82925
82926 /* Copy relocated percpu area over. */
82927 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
82928 @@ -3050,16 +3159,16 @@ static int do_init_module(struct module *mod)
82929 MODULE_STATE_COMING, mod);
82930
82931 /* Set RO and NX regions for core */
82932 - set_section_ro_nx(mod->module_core,
82933 - mod->core_text_size,
82934 - mod->core_ro_size,
82935 - mod->core_size);
82936 + set_section_ro_nx(mod->module_core_rx,
82937 + mod->core_size_rx,
82938 + mod->core_size_rx,
82939 + mod->core_size_rx);
82940
82941 /* Set RO and NX regions for init */
82942 - set_section_ro_nx(mod->module_init,
82943 - mod->init_text_size,
82944 - mod->init_ro_size,
82945 - mod->init_size);
82946 + set_section_ro_nx(mod->module_init_rx,
82947 + mod->init_size_rx,
82948 + mod->init_size_rx,
82949 + mod->init_size_rx);
82950
82951 do_mod_ctors(mod);
82952 /* Start the module */
82953 @@ -3121,11 +3230,12 @@ static int do_init_module(struct module *mod)
82954 mod->strtab = mod->core_strtab;
82955 #endif
82956 unset_module_init_ro_nx(mod);
82957 - module_free(mod, mod->module_init);
82958 - mod->module_init = NULL;
82959 - mod->init_size = 0;
82960 - mod->init_ro_size = 0;
82961 - mod->init_text_size = 0;
82962 + module_free(mod, mod->module_init_rw);
82963 + module_free_exec(mod, mod->module_init_rx);
82964 + mod->module_init_rw = NULL;
82965 + mod->module_init_rx = NULL;
82966 + mod->init_size_rw = 0;
82967 + mod->init_size_rx = 0;
82968 mutex_unlock(&module_mutex);
82969 wake_up_all(&module_wq);
82970
82971 @@ -3269,9 +3379,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
82972 if (err)
82973 goto free_unload;
82974
82975 + /* Now copy in args */
82976 + mod->args = strndup_user(uargs, ~0UL >> 1);
82977 + if (IS_ERR(mod->args)) {
82978 + err = PTR_ERR(mod->args);
82979 + goto free_unload;
82980 + }
82981 +
82982 /* Set up MODINFO_ATTR fields */
82983 setup_modinfo(mod, info);
82984
82985 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82986 + {
82987 + char *p, *p2;
82988 +
82989 + if (strstr(mod->args, "grsec_modharden_netdev")) {
82990 + 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);
82991 + err = -EPERM;
82992 + goto free_modinfo;
82993 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
82994 + p += sizeof("grsec_modharden_normal") - 1;
82995 + p2 = strstr(p, "_");
82996 + if (p2) {
82997 + *p2 = '\0';
82998 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
82999 + *p2 = '_';
83000 + }
83001 + err = -EPERM;
83002 + goto free_modinfo;
83003 + }
83004 + }
83005 +#endif
83006 +
83007 /* Fix up syms, so that st_value is a pointer to location. */
83008 err = simplify_symbols(mod, info);
83009 if (err < 0)
83010 @@ -3287,13 +3426,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
83011
83012 flush_module_icache(mod);
83013
83014 - /* Now copy in args */
83015 - mod->args = strndup_user(uargs, ~0UL >> 1);
83016 - if (IS_ERR(mod->args)) {
83017 - err = PTR_ERR(mod->args);
83018 - goto free_arch_cleanup;
83019 - }
83020 -
83021 dynamic_debug_setup(info->debug, info->num_debug);
83022
83023 /* Finally it's fully formed, ready to start executing. */
83024 @@ -3328,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
83025 ddebug_cleanup:
83026 dynamic_debug_remove(info->debug);
83027 synchronize_sched();
83028 - kfree(mod->args);
83029 - free_arch_cleanup:
83030 module_arch_cleanup(mod);
83031 free_modinfo:
83032 free_modinfo(mod);
83033 + kfree(mod->args);
83034 free_unload:
83035 module_unload_free(mod);
83036 unlink_mod:
83037 @@ -3415,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
83038 unsigned long nextval;
83039
83040 /* At worse, next value is at end of module */
83041 - if (within_module_init(addr, mod))
83042 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
83043 + if (within_module_init_rx(addr, mod))
83044 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
83045 + else if (within_module_init_rw(addr, mod))
83046 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
83047 + else if (within_module_core_rx(addr, mod))
83048 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
83049 + else if (within_module_core_rw(addr, mod))
83050 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
83051 else
83052 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
83053 + return NULL;
83054
83055 /* Scan for closest preceding symbol, and next symbol. (ELF
83056 starts real symbols at 1). */
83057 @@ -3669,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
83058 return 0;
83059
83060 seq_printf(m, "%s %u",
83061 - mod->name, mod->init_size + mod->core_size);
83062 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
83063 print_unload_info(m, mod);
83064
83065 /* Informative for users. */
83066 @@ -3678,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
83067 mod->state == MODULE_STATE_COMING ? "Loading":
83068 "Live");
83069 /* Used by oprofile and other similar tools. */
83070 - seq_printf(m, " 0x%pK", mod->module_core);
83071 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
83072
83073 /* Taints info */
83074 if (mod->taints)
83075 @@ -3714,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
83076
83077 static int __init proc_modules_init(void)
83078 {
83079 +#ifndef CONFIG_GRKERNSEC_HIDESYM
83080 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83081 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83082 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83083 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
83084 +#else
83085 proc_create("modules", 0, NULL, &proc_modules_operations);
83086 +#endif
83087 +#else
83088 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83089 +#endif
83090 return 0;
83091 }
83092 module_init(proc_modules_init);
83093 @@ -3775,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
83094 {
83095 struct module *mod;
83096
83097 - if (addr < module_addr_min || addr > module_addr_max)
83098 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
83099 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
83100 return NULL;
83101
83102 list_for_each_entry_rcu(mod, &modules, list) {
83103 if (mod->state == MODULE_STATE_UNFORMED)
83104 continue;
83105 - if (within_module_core(addr, mod)
83106 - || within_module_init(addr, mod))
83107 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
83108 return mod;
83109 }
83110 return NULL;
83111 @@ -3817,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
83112 */
83113 struct module *__module_text_address(unsigned long addr)
83114 {
83115 - struct module *mod = __module_address(addr);
83116 + struct module *mod;
83117 +
83118 +#ifdef CONFIG_X86_32
83119 + addr = ktla_ktva(addr);
83120 +#endif
83121 +
83122 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
83123 + return NULL;
83124 +
83125 + mod = __module_address(addr);
83126 +
83127 if (mod) {
83128 /* Make sure it's within the text section. */
83129 - if (!within(addr, mod->module_init, mod->init_text_size)
83130 - && !within(addr, mod->module_core, mod->core_text_size))
83131 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
83132 mod = NULL;
83133 }
83134 return mod;
83135 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
83136 index 7e3443f..b2a1e6b 100644
83137 --- a/kernel/mutex-debug.c
83138 +++ b/kernel/mutex-debug.c
83139 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
83140 }
83141
83142 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83143 - struct thread_info *ti)
83144 + struct task_struct *task)
83145 {
83146 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
83147
83148 /* Mark the current thread as blocked on the lock: */
83149 - ti->task->blocked_on = waiter;
83150 + task->blocked_on = waiter;
83151 }
83152
83153 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83154 - struct thread_info *ti)
83155 + struct task_struct *task)
83156 {
83157 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
83158 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
83159 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
83160 - ti->task->blocked_on = NULL;
83161 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
83162 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
83163 + task->blocked_on = NULL;
83164
83165 list_del_init(&waiter->list);
83166 waiter->task = NULL;
83167 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
83168 index 0799fd3..d06ae3b 100644
83169 --- a/kernel/mutex-debug.h
83170 +++ b/kernel/mutex-debug.h
83171 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
83172 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
83173 extern void debug_mutex_add_waiter(struct mutex *lock,
83174 struct mutex_waiter *waiter,
83175 - struct thread_info *ti);
83176 + struct task_struct *task);
83177 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83178 - struct thread_info *ti);
83179 + struct task_struct *task);
83180 extern void debug_mutex_unlock(struct mutex *lock);
83181 extern void debug_mutex_init(struct mutex *lock, const char *name,
83182 struct lock_class_key *key);
83183 diff --git a/kernel/mutex.c b/kernel/mutex.c
83184 index d24105b..15648eb 100644
83185 --- a/kernel/mutex.c
83186 +++ b/kernel/mutex.c
83187 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
83188 node->locked = 1;
83189 return;
83190 }
83191 - ACCESS_ONCE(prev->next) = node;
83192 + ACCESS_ONCE_RW(prev->next) = node;
83193 smp_wmb();
83194 /* Wait until the lock holder passes the lock down */
83195 while (!ACCESS_ONCE(node->locked))
83196 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
83197 while (!(next = ACCESS_ONCE(node->next)))
83198 arch_mutex_cpu_relax();
83199 }
83200 - ACCESS_ONCE(next->locked) = 1;
83201 + ACCESS_ONCE_RW(next->locked) = 1;
83202 smp_wmb();
83203 }
83204
83205 @@ -520,7 +520,7 @@ slowpath:
83206 goto skip_wait;
83207
83208 debug_mutex_lock_common(lock, &waiter);
83209 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
83210 + debug_mutex_add_waiter(lock, &waiter, task);
83211
83212 /* add waiting tasks to the end of the waitqueue (FIFO): */
83213 list_add_tail(&waiter.list, &lock->wait_list);
83214 @@ -564,7 +564,7 @@ slowpath:
83215 schedule_preempt_disabled();
83216 spin_lock_mutex(&lock->wait_lock, flags);
83217 }
83218 - mutex_remove_waiter(lock, &waiter, current_thread_info());
83219 + mutex_remove_waiter(lock, &waiter, task);
83220 /* set it to 0 if there are no waiters left: */
83221 if (likely(list_empty(&lock->wait_list)))
83222 atomic_set(&lock->count, 0);
83223 @@ -601,7 +601,7 @@ skip_wait:
83224 return 0;
83225
83226 err:
83227 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
83228 + mutex_remove_waiter(lock, &waiter, task);
83229 spin_unlock_mutex(&lock->wait_lock, flags);
83230 debug_mutex_free_waiter(&waiter);
83231 mutex_release(&lock->dep_map, 1, ip);
83232 diff --git a/kernel/notifier.c b/kernel/notifier.c
83233 index 2d5cc4c..d9ea600 100644
83234 --- a/kernel/notifier.c
83235 +++ b/kernel/notifier.c
83236 @@ -5,6 +5,7 @@
83237 #include <linux/rcupdate.h>
83238 #include <linux/vmalloc.h>
83239 #include <linux/reboot.h>
83240 +#include <linux/mm.h>
83241
83242 /*
83243 * Notifier list for kernel code which wants to be called
83244 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
83245 while ((*nl) != NULL) {
83246 if (n->priority > (*nl)->priority)
83247 break;
83248 - nl = &((*nl)->next);
83249 + nl = (struct notifier_block **)&((*nl)->next);
83250 }
83251 - n->next = *nl;
83252 + pax_open_kernel();
83253 + *(const void **)&n->next = *nl;
83254 rcu_assign_pointer(*nl, n);
83255 + pax_close_kernel();
83256 return 0;
83257 }
83258
83259 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
83260 return 0;
83261 if (n->priority > (*nl)->priority)
83262 break;
83263 - nl = &((*nl)->next);
83264 + nl = (struct notifier_block **)&((*nl)->next);
83265 }
83266 - n->next = *nl;
83267 + pax_open_kernel();
83268 + *(const void **)&n->next = *nl;
83269 rcu_assign_pointer(*nl, n);
83270 + pax_close_kernel();
83271 return 0;
83272 }
83273
83274 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
83275 {
83276 while ((*nl) != NULL) {
83277 if ((*nl) == n) {
83278 + pax_open_kernel();
83279 rcu_assign_pointer(*nl, n->next);
83280 + pax_close_kernel();
83281 return 0;
83282 }
83283 - nl = &((*nl)->next);
83284 + nl = (struct notifier_block **)&((*nl)->next);
83285 }
83286 return -ENOENT;
83287 }
83288 diff --git a/kernel/panic.c b/kernel/panic.c
83289 index b6c482c..5578061 100644
83290 --- a/kernel/panic.c
83291 +++ b/kernel/panic.c
83292 @@ -407,7 +407,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
83293 disable_trace_on_warning();
83294
83295 pr_warn("------------[ cut here ]------------\n");
83296 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
83297 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
83298 raw_smp_processor_id(), current->pid, file, line, caller);
83299
83300 if (args)
83301 @@ -461,7 +461,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
83302 */
83303 void __stack_chk_fail(void)
83304 {
83305 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
83306 + dump_stack();
83307 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
83308 __builtin_return_address(0));
83309 }
83310 EXPORT_SYMBOL(__stack_chk_fail);
83311 diff --git a/kernel/pid.c b/kernel/pid.c
83312 index 9b9a266..c20ef80 100644
83313 --- a/kernel/pid.c
83314 +++ b/kernel/pid.c
83315 @@ -33,6 +33,7 @@
83316 #include <linux/rculist.h>
83317 #include <linux/bootmem.h>
83318 #include <linux/hash.h>
83319 +#include <linux/security.h>
83320 #include <linux/pid_namespace.h>
83321 #include <linux/init_task.h>
83322 #include <linux/syscalls.h>
83323 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
83324
83325 int pid_max = PID_MAX_DEFAULT;
83326
83327 -#define RESERVED_PIDS 300
83328 +#define RESERVED_PIDS 500
83329
83330 int pid_max_min = RESERVED_PIDS + 1;
83331 int pid_max_max = PID_MAX_LIMIT;
83332 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
83333 */
83334 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
83335 {
83336 + struct task_struct *task;
83337 +
83338 rcu_lockdep_assert(rcu_read_lock_held(),
83339 "find_task_by_pid_ns() needs rcu_read_lock()"
83340 " protection");
83341 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83342 +
83343 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83344 +
83345 + if (gr_pid_is_chrooted(task))
83346 + return NULL;
83347 +
83348 + return task;
83349 }
83350
83351 struct task_struct *find_task_by_vpid(pid_t vnr)
83352 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
83353 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
83354 }
83355
83356 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
83357 +{
83358 + rcu_lockdep_assert(rcu_read_lock_held(),
83359 + "find_task_by_pid_ns() needs rcu_read_lock()"
83360 + " protection");
83361 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
83362 +}
83363 +
83364 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
83365 {
83366 struct pid *pid;
83367 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
83368 index 4208655..19f36a5 100644
83369 --- a/kernel/pid_namespace.c
83370 +++ b/kernel/pid_namespace.c
83371 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
83372 void __user *buffer, size_t *lenp, loff_t *ppos)
83373 {
83374 struct pid_namespace *pid_ns = task_active_pid_ns(current);
83375 - struct ctl_table tmp = *table;
83376 + ctl_table_no_const tmp = *table;
83377
83378 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
83379 return -EPERM;
83380 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
83381 index c7f31aa..2b44977 100644
83382 --- a/kernel/posix-cpu-timers.c
83383 +++ b/kernel/posix-cpu-timers.c
83384 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
83385
83386 static __init int init_posix_cpu_timers(void)
83387 {
83388 - struct k_clock process = {
83389 + static struct k_clock process = {
83390 .clock_getres = process_cpu_clock_getres,
83391 .clock_get = process_cpu_clock_get,
83392 .timer_create = process_cpu_timer_create,
83393 .nsleep = process_cpu_nsleep,
83394 .nsleep_restart = process_cpu_nsleep_restart,
83395 };
83396 - struct k_clock thread = {
83397 + static struct k_clock thread = {
83398 .clock_getres = thread_cpu_clock_getres,
83399 .clock_get = thread_cpu_clock_get,
83400 .timer_create = thread_cpu_timer_create,
83401 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
83402 index 424c2d4..679242f 100644
83403 --- a/kernel/posix-timers.c
83404 +++ b/kernel/posix-timers.c
83405 @@ -43,6 +43,7 @@
83406 #include <linux/hash.h>
83407 #include <linux/posix-clock.h>
83408 #include <linux/posix-timers.h>
83409 +#include <linux/grsecurity.h>
83410 #include <linux/syscalls.h>
83411 #include <linux/wait.h>
83412 #include <linux/workqueue.h>
83413 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
83414 * which we beg off on and pass to do_sys_settimeofday().
83415 */
83416
83417 -static struct k_clock posix_clocks[MAX_CLOCKS];
83418 +static struct k_clock *posix_clocks[MAX_CLOCKS];
83419
83420 /*
83421 * These ones are defined below.
83422 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
83423 */
83424 static __init int init_posix_timers(void)
83425 {
83426 - struct k_clock clock_realtime = {
83427 + static struct k_clock clock_realtime = {
83428 .clock_getres = hrtimer_get_res,
83429 .clock_get = posix_clock_realtime_get,
83430 .clock_set = posix_clock_realtime_set,
83431 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
83432 .timer_get = common_timer_get,
83433 .timer_del = common_timer_del,
83434 };
83435 - struct k_clock clock_monotonic = {
83436 + static struct k_clock clock_monotonic = {
83437 .clock_getres = hrtimer_get_res,
83438 .clock_get = posix_ktime_get_ts,
83439 .nsleep = common_nsleep,
83440 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
83441 .timer_get = common_timer_get,
83442 .timer_del = common_timer_del,
83443 };
83444 - struct k_clock clock_monotonic_raw = {
83445 + static struct k_clock clock_monotonic_raw = {
83446 .clock_getres = hrtimer_get_res,
83447 .clock_get = posix_get_monotonic_raw,
83448 };
83449 - struct k_clock clock_realtime_coarse = {
83450 + static struct k_clock clock_realtime_coarse = {
83451 .clock_getres = posix_get_coarse_res,
83452 .clock_get = posix_get_realtime_coarse,
83453 };
83454 - struct k_clock clock_monotonic_coarse = {
83455 + static struct k_clock clock_monotonic_coarse = {
83456 .clock_getres = posix_get_coarse_res,
83457 .clock_get = posix_get_monotonic_coarse,
83458 };
83459 - struct k_clock clock_tai = {
83460 + static struct k_clock clock_tai = {
83461 .clock_getres = hrtimer_get_res,
83462 .clock_get = posix_get_tai,
83463 .nsleep = common_nsleep,
83464 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
83465 .timer_get = common_timer_get,
83466 .timer_del = common_timer_del,
83467 };
83468 - struct k_clock clock_boottime = {
83469 + static struct k_clock clock_boottime = {
83470 .clock_getres = hrtimer_get_res,
83471 .clock_get = posix_get_boottime,
83472 .nsleep = common_nsleep,
83473 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
83474 return;
83475 }
83476
83477 - posix_clocks[clock_id] = *new_clock;
83478 + posix_clocks[clock_id] = new_clock;
83479 }
83480 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
83481
83482 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
83483 return (id & CLOCKFD_MASK) == CLOCKFD ?
83484 &clock_posix_dynamic : &clock_posix_cpu;
83485
83486 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
83487 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
83488 return NULL;
83489 - return &posix_clocks[id];
83490 + return posix_clocks[id];
83491 }
83492
83493 static int common_timer_create(struct k_itimer *new_timer)
83494 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
83495 struct k_clock *kc = clockid_to_kclock(which_clock);
83496 struct k_itimer *new_timer;
83497 int error, new_timer_id;
83498 - sigevent_t event;
83499 + sigevent_t event = { };
83500 int it_id_set = IT_ID_NOT_SET;
83501
83502 if (!kc)
83503 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
83504 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
83505 return -EFAULT;
83506
83507 + /* only the CLOCK_REALTIME clock can be set, all other clocks
83508 + have their clock_set fptr set to a nosettime dummy function
83509 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
83510 + call common_clock_set, which calls do_sys_settimeofday, which
83511 + we hook
83512 + */
83513 +
83514 return kc->clock_set(which_clock, &new_tp);
83515 }
83516
83517 diff --git a/kernel/power/process.c b/kernel/power/process.c
83518 index 06ec886..9dba35e 100644
83519 --- a/kernel/power/process.c
83520 +++ b/kernel/power/process.c
83521 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
83522 unsigned int elapsed_msecs;
83523 bool wakeup = false;
83524 int sleep_usecs = USEC_PER_MSEC;
83525 + bool timedout = false;
83526
83527 do_gettimeofday(&start);
83528
83529 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
83530
83531 while (true) {
83532 todo = 0;
83533 + if (time_after(jiffies, end_time))
83534 + timedout = true;
83535 read_lock(&tasklist_lock);
83536 do_each_thread(g, p) {
83537 if (p == current || !freeze_task(p))
83538 continue;
83539
83540 - if (!freezer_should_skip(p))
83541 + if (!freezer_should_skip(p)) {
83542 todo++;
83543 + if (timedout) {
83544 + printk(KERN_ERR "Task refusing to freeze:\n");
83545 + sched_show_task(p);
83546 + }
83547 + }
83548 } while_each_thread(g, p);
83549 read_unlock(&tasklist_lock);
83550
83551 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
83552 todo += wq_busy;
83553 }
83554
83555 - if (!todo || time_after(jiffies, end_time))
83556 + if (!todo || timedout)
83557 break;
83558
83559 if (pm_wakeup_pending()) {
83560 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
83561 index b4e8500..b457a6c 100644
83562 --- a/kernel/printk/printk.c
83563 +++ b/kernel/printk/printk.c
83564 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
83565 if (from_file && type != SYSLOG_ACTION_OPEN)
83566 return 0;
83567
83568 +#ifdef CONFIG_GRKERNSEC_DMESG
83569 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
83570 + return -EPERM;
83571 +#endif
83572 +
83573 if (syslog_action_restricted(type)) {
83574 if (capable(CAP_SYSLOG))
83575 return 0;
83576 diff --git a/kernel/profile.c b/kernel/profile.c
83577 index 6631e1e..310c266 100644
83578 --- a/kernel/profile.c
83579 +++ b/kernel/profile.c
83580 @@ -37,7 +37,7 @@ struct profile_hit {
83581 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
83582 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
83583
83584 -static atomic_t *prof_buffer;
83585 +static atomic_unchecked_t *prof_buffer;
83586 static unsigned long prof_len, prof_shift;
83587
83588 int prof_on __read_mostly;
83589 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
83590 hits[i].pc = 0;
83591 continue;
83592 }
83593 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83594 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83595 hits[i].hits = hits[i].pc = 0;
83596 }
83597 }
83598 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83599 * Add the current hit(s) and flush the write-queue out
83600 * to the global buffer:
83601 */
83602 - atomic_add(nr_hits, &prof_buffer[pc]);
83603 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
83604 for (i = 0; i < NR_PROFILE_HIT; ++i) {
83605 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83606 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83607 hits[i].pc = hits[i].hits = 0;
83608 }
83609 out:
83610 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83611 {
83612 unsigned long pc;
83613 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
83614 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83615 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83616 }
83617 #endif /* !CONFIG_SMP */
83618
83619 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
83620 return -EFAULT;
83621 buf++; p++; count--; read++;
83622 }
83623 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
83624 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
83625 if (copy_to_user(buf, (void *)pnt, count))
83626 return -EFAULT;
83627 read += count;
83628 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
83629 }
83630 #endif
83631 profile_discard_flip_buffers();
83632 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
83633 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
83634 return count;
83635 }
83636
83637 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
83638 index dd562e9..74fc16d 100644
83639 --- a/kernel/ptrace.c
83640 +++ b/kernel/ptrace.c
83641 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
83642 if (seize)
83643 flags |= PT_SEIZED;
83644 rcu_read_lock();
83645 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83646 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83647 flags |= PT_PTRACE_CAP;
83648 rcu_read_unlock();
83649 task->ptrace = flags;
83650 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
83651 break;
83652 return -EIO;
83653 }
83654 - if (copy_to_user(dst, buf, retval))
83655 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
83656 return -EFAULT;
83657 copied += retval;
83658 src += retval;
83659 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
83660 bool seized = child->ptrace & PT_SEIZED;
83661 int ret = -EIO;
83662 siginfo_t siginfo, *si;
83663 - void __user *datavp = (void __user *) data;
83664 + void __user *datavp = (__force void __user *) data;
83665 unsigned long __user *datalp = datavp;
83666 unsigned long flags;
83667
83668 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
83669 goto out;
83670 }
83671
83672 + if (gr_handle_ptrace(child, request)) {
83673 + ret = -EPERM;
83674 + goto out_put_task_struct;
83675 + }
83676 +
83677 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83678 ret = ptrace_attach(child, request, addr, data);
83679 /*
83680 * Some architectures need to do book-keeping after
83681 * a ptrace attach.
83682 */
83683 - if (!ret)
83684 + if (!ret) {
83685 arch_ptrace_attach(child);
83686 + gr_audit_ptrace(child);
83687 + }
83688 goto out_put_task_struct;
83689 }
83690
83691 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
83692 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
83693 if (copied != sizeof(tmp))
83694 return -EIO;
83695 - return put_user(tmp, (unsigned long __user *)data);
83696 + return put_user(tmp, (__force unsigned long __user *)data);
83697 }
83698
83699 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
83700 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
83701 }
83702
83703 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83704 - compat_long_t addr, compat_long_t data)
83705 + compat_ulong_t addr, compat_ulong_t data)
83706 {
83707 struct task_struct *child;
83708 long ret;
83709 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83710 goto out;
83711 }
83712
83713 + if (gr_handle_ptrace(child, request)) {
83714 + ret = -EPERM;
83715 + goto out_put_task_struct;
83716 + }
83717 +
83718 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83719 ret = ptrace_attach(child, request, addr, data);
83720 /*
83721 * Some architectures need to do book-keeping after
83722 * a ptrace attach.
83723 */
83724 - if (!ret)
83725 + if (!ret) {
83726 arch_ptrace_attach(child);
83727 + gr_audit_ptrace(child);
83728 + }
83729 goto out_put_task_struct;
83730 }
83731
83732 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
83733 index b02a339..ce2d20c 100644
83734 --- a/kernel/rcupdate.c
83735 +++ b/kernel/rcupdate.c
83736 @@ -312,10 +312,10 @@ int rcu_jiffies_till_stall_check(void)
83737 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
83738 */
83739 if (till_stall_check < 3) {
83740 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
83741 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
83742 till_stall_check = 3;
83743 } else if (till_stall_check > 300) {
83744 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
83745 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
83746 till_stall_check = 300;
83747 }
83748 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
83749 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
83750 index 9ed6075..c9e8a63 100644
83751 --- a/kernel/rcutiny.c
83752 +++ b/kernel/rcutiny.c
83753 @@ -45,7 +45,7 @@
83754 /* Forward declarations for rcutiny_plugin.h. */
83755 struct rcu_ctrlblk;
83756 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
83757 -static void rcu_process_callbacks(struct softirq_action *unused);
83758 +static void rcu_process_callbacks(void);
83759 static void __call_rcu(struct rcu_head *head,
83760 void (*func)(struct rcu_head *rcu),
83761 struct rcu_ctrlblk *rcp);
83762 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
83763 false));
83764 }
83765
83766 -static void rcu_process_callbacks(struct softirq_action *unused)
83767 +static __latent_entropy void rcu_process_callbacks(void)
83768 {
83769 __rcu_process_callbacks(&rcu_sched_ctrlblk);
83770 __rcu_process_callbacks(&rcu_bh_ctrlblk);
83771 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
83772 index be63101..05cf721 100644
83773 --- a/kernel/rcutorture.c
83774 +++ b/kernel/rcutorture.c
83775 @@ -170,12 +170,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
83776 { 0 };
83777 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
83778 { 0 };
83779 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83780 -static atomic_t n_rcu_torture_alloc;
83781 -static atomic_t n_rcu_torture_alloc_fail;
83782 -static atomic_t n_rcu_torture_free;
83783 -static atomic_t n_rcu_torture_mberror;
83784 -static atomic_t n_rcu_torture_error;
83785 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83786 +static atomic_unchecked_t n_rcu_torture_alloc;
83787 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
83788 +static atomic_unchecked_t n_rcu_torture_free;
83789 +static atomic_unchecked_t n_rcu_torture_mberror;
83790 +static atomic_unchecked_t n_rcu_torture_error;
83791 static long n_rcu_torture_barrier_error;
83792 static long n_rcu_torture_boost_ktrerror;
83793 static long n_rcu_torture_boost_rterror;
83794 @@ -293,11 +293,11 @@ rcu_torture_alloc(void)
83795
83796 spin_lock_bh(&rcu_torture_lock);
83797 if (list_empty(&rcu_torture_freelist)) {
83798 - atomic_inc(&n_rcu_torture_alloc_fail);
83799 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
83800 spin_unlock_bh(&rcu_torture_lock);
83801 return NULL;
83802 }
83803 - atomic_inc(&n_rcu_torture_alloc);
83804 + atomic_inc_unchecked(&n_rcu_torture_alloc);
83805 p = rcu_torture_freelist.next;
83806 list_del_init(p);
83807 spin_unlock_bh(&rcu_torture_lock);
83808 @@ -310,7 +310,7 @@ rcu_torture_alloc(void)
83809 static void
83810 rcu_torture_free(struct rcu_torture *p)
83811 {
83812 - atomic_inc(&n_rcu_torture_free);
83813 + atomic_inc_unchecked(&n_rcu_torture_free);
83814 spin_lock_bh(&rcu_torture_lock);
83815 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
83816 spin_unlock_bh(&rcu_torture_lock);
83817 @@ -431,7 +431,7 @@ rcu_torture_cb(struct rcu_head *p)
83818 i = rp->rtort_pipe_count;
83819 if (i > RCU_TORTURE_PIPE_LEN)
83820 i = RCU_TORTURE_PIPE_LEN;
83821 - atomic_inc(&rcu_torture_wcount[i]);
83822 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83823 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
83824 rp->rtort_mbtest = 0;
83825 rcu_torture_free(rp);
83826 @@ -821,7 +821,7 @@ rcu_torture_writer(void *arg)
83827 i = old_rp->rtort_pipe_count;
83828 if (i > RCU_TORTURE_PIPE_LEN)
83829 i = RCU_TORTURE_PIPE_LEN;
83830 - atomic_inc(&rcu_torture_wcount[i]);
83831 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83832 old_rp->rtort_pipe_count++;
83833 if (gp_normal == gp_exp)
83834 exp = !!(rcu_random(&rand) & 0x80);
83835 @@ -839,7 +839,7 @@ rcu_torture_writer(void *arg)
83836 i = rp->rtort_pipe_count;
83837 if (i > RCU_TORTURE_PIPE_LEN)
83838 i = RCU_TORTURE_PIPE_LEN;
83839 - atomic_inc(&rcu_torture_wcount[i]);
83840 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83841 if (++rp->rtort_pipe_count >=
83842 RCU_TORTURE_PIPE_LEN) {
83843 rp->rtort_mbtest = 0;
83844 @@ -938,7 +938,7 @@ static void rcu_torture_timer(unsigned long unused)
83845 return;
83846 }
83847 if (p->rtort_mbtest == 0)
83848 - atomic_inc(&n_rcu_torture_mberror);
83849 + atomic_inc_unchecked(&n_rcu_torture_mberror);
83850 spin_lock(&rand_lock);
83851 cur_ops->read_delay(&rand);
83852 n_rcu_torture_timers++;
83853 @@ -1008,7 +1008,7 @@ rcu_torture_reader(void *arg)
83854 continue;
83855 }
83856 if (p->rtort_mbtest == 0)
83857 - atomic_inc(&n_rcu_torture_mberror);
83858 + atomic_inc_unchecked(&n_rcu_torture_mberror);
83859 cur_ops->read_delay(&rand);
83860 preempt_disable();
83861 pipe_count = p->rtort_pipe_count;
83862 @@ -1071,11 +1071,11 @@ rcu_torture_printk(char *page)
83863 rcu_torture_current,
83864 rcu_torture_current_version,
83865 list_empty(&rcu_torture_freelist),
83866 - atomic_read(&n_rcu_torture_alloc),
83867 - atomic_read(&n_rcu_torture_alloc_fail),
83868 - atomic_read(&n_rcu_torture_free));
83869 + atomic_read_unchecked(&n_rcu_torture_alloc),
83870 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
83871 + atomic_read_unchecked(&n_rcu_torture_free));
83872 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
83873 - atomic_read(&n_rcu_torture_mberror),
83874 + atomic_read_unchecked(&n_rcu_torture_mberror),
83875 n_rcu_torture_boost_ktrerror,
83876 n_rcu_torture_boost_rterror);
83877 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
83878 @@ -1094,14 +1094,14 @@ rcu_torture_printk(char *page)
83879 n_barrier_attempts,
83880 n_rcu_torture_barrier_error);
83881 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
83882 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
83883 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
83884 n_rcu_torture_barrier_error != 0 ||
83885 n_rcu_torture_boost_ktrerror != 0 ||
83886 n_rcu_torture_boost_rterror != 0 ||
83887 n_rcu_torture_boost_failure != 0 ||
83888 i > 1) {
83889 cnt += sprintf(&page[cnt], "!!! ");
83890 - atomic_inc(&n_rcu_torture_error);
83891 + atomic_inc_unchecked(&n_rcu_torture_error);
83892 WARN_ON_ONCE(1);
83893 }
83894 cnt += sprintf(&page[cnt], "Reader Pipe: ");
83895 @@ -1115,7 +1115,7 @@ rcu_torture_printk(char *page)
83896 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
83897 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83898 cnt += sprintf(&page[cnt], " %d",
83899 - atomic_read(&rcu_torture_wcount[i]));
83900 + atomic_read_unchecked(&rcu_torture_wcount[i]));
83901 }
83902 cnt += sprintf(&page[cnt], "\n");
83903 if (cur_ops->stats)
83904 @@ -1830,7 +1830,7 @@ rcu_torture_cleanup(void)
83905
83906 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
83907
83908 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83909 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83910 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
83911 else if (n_online_successes != n_online_attempts ||
83912 n_offline_successes != n_offline_attempts)
83913 @@ -1952,18 +1952,18 @@ rcu_torture_init(void)
83914
83915 rcu_torture_current = NULL;
83916 rcu_torture_current_version = 0;
83917 - atomic_set(&n_rcu_torture_alloc, 0);
83918 - atomic_set(&n_rcu_torture_alloc_fail, 0);
83919 - atomic_set(&n_rcu_torture_free, 0);
83920 - atomic_set(&n_rcu_torture_mberror, 0);
83921 - atomic_set(&n_rcu_torture_error, 0);
83922 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
83923 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
83924 + atomic_set_unchecked(&n_rcu_torture_free, 0);
83925 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
83926 + atomic_set_unchecked(&n_rcu_torture_error, 0);
83927 n_rcu_torture_barrier_error = 0;
83928 n_rcu_torture_boost_ktrerror = 0;
83929 n_rcu_torture_boost_rterror = 0;
83930 n_rcu_torture_boost_failure = 0;
83931 n_rcu_torture_boosts = 0;
83932 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
83933 - atomic_set(&rcu_torture_wcount[i], 0);
83934 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
83935 for_each_possible_cpu(cpu) {
83936 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83937 per_cpu(rcu_torture_count, cpu)[i] = 0;
83938 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
83939 index 32618b3..c1fb822 100644
83940 --- a/kernel/rcutree.c
83941 +++ b/kernel/rcutree.c
83942 @@ -382,9 +382,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
83943 rcu_prepare_for_idle(smp_processor_id());
83944 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83945 smp_mb__before_atomic_inc(); /* See above. */
83946 - atomic_inc(&rdtp->dynticks);
83947 + atomic_inc_unchecked(&rdtp->dynticks);
83948 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
83949 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83950 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83951
83952 /*
83953 * It is illegal to enter an extended quiescent state while
83954 @@ -501,10 +501,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
83955 int user)
83956 {
83957 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
83958 - atomic_inc(&rdtp->dynticks);
83959 + atomic_inc_unchecked(&rdtp->dynticks);
83960 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83961 smp_mb__after_atomic_inc(); /* See above. */
83962 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83963 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83964 rcu_cleanup_after_idle(smp_processor_id());
83965 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
83966 if (!user && !is_idle_task(current)) {
83967 @@ -623,14 +623,14 @@ void rcu_nmi_enter(void)
83968 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
83969
83970 if (rdtp->dynticks_nmi_nesting == 0 &&
83971 - (atomic_read(&rdtp->dynticks) & 0x1))
83972 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
83973 return;
83974 rdtp->dynticks_nmi_nesting++;
83975 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
83976 - atomic_inc(&rdtp->dynticks);
83977 + atomic_inc_unchecked(&rdtp->dynticks);
83978 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83979 smp_mb__after_atomic_inc(); /* See above. */
83980 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83981 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83982 }
83983
83984 /**
83985 @@ -649,9 +649,9 @@ void rcu_nmi_exit(void)
83986 return;
83987 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83988 smp_mb__before_atomic_inc(); /* See above. */
83989 - atomic_inc(&rdtp->dynticks);
83990 + atomic_inc_unchecked(&rdtp->dynticks);
83991 smp_mb__after_atomic_inc(); /* Force delay to next write. */
83992 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83993 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83994 }
83995
83996 /**
83997 @@ -665,7 +665,7 @@ int rcu_is_cpu_idle(void)
83998 int ret;
83999
84000 preempt_disable();
84001 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84002 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84003 preempt_enable();
84004 return ret;
84005 }
84006 @@ -734,7 +734,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
84007 static int dyntick_save_progress_counter(struct rcu_data *rdp,
84008 bool *isidle, unsigned long *maxj)
84009 {
84010 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
84011 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84012 rcu_sysidle_check_cpu(rdp, isidle, maxj);
84013 return (rdp->dynticks_snap & 0x1) == 0;
84014 }
84015 @@ -751,7 +751,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
84016 unsigned int curr;
84017 unsigned int snap;
84018
84019 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
84020 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84021 snap = (unsigned int)rdp->dynticks_snap;
84022
84023 /*
84024 @@ -1341,9 +1341,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
84025 rdp = this_cpu_ptr(rsp->rda);
84026 rcu_preempt_check_blocked_tasks(rnp);
84027 rnp->qsmask = rnp->qsmaskinit;
84028 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
84029 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
84030 WARN_ON_ONCE(rnp->completed != rsp->completed);
84031 - ACCESS_ONCE(rnp->completed) = rsp->completed;
84032 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
84033 if (rnp == rdp->mynode)
84034 __note_gp_changes(rsp, rnp, rdp);
84035 rcu_preempt_boost_start_gp(rnp);
84036 @@ -1434,7 +1434,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
84037 */
84038 rcu_for_each_node_breadth_first(rsp, rnp) {
84039 raw_spin_lock_irq(&rnp->lock);
84040 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
84041 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
84042 rdp = this_cpu_ptr(rsp->rda);
84043 if (rnp == rdp->mynode)
84044 __note_gp_changes(rsp, rnp, rdp);
84045 @@ -1766,7 +1766,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
84046 rsp->qlen += rdp->qlen;
84047 rdp->n_cbs_orphaned += rdp->qlen;
84048 rdp->qlen_lazy = 0;
84049 - ACCESS_ONCE(rdp->qlen) = 0;
84050 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84051 }
84052
84053 /*
84054 @@ -2012,7 +2012,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
84055 }
84056 smp_mb(); /* List handling before counting for rcu_barrier(). */
84057 rdp->qlen_lazy -= count_lazy;
84058 - ACCESS_ONCE(rdp->qlen) -= count;
84059 + ACCESS_ONCE_RW(rdp->qlen) -= count;
84060 rdp->n_cbs_invoked += count;
84061
84062 /* Reinstate batch limit if we have worked down the excess. */
84063 @@ -2209,7 +2209,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
84064 /*
84065 * Do RCU core processing for the current CPU.
84066 */
84067 -static void rcu_process_callbacks(struct softirq_action *unused)
84068 +static __latent_entropy void rcu_process_callbacks(void)
84069 {
84070 struct rcu_state *rsp;
84071
84072 @@ -2316,7 +2316,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84073 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
84074 if (debug_rcu_head_queue(head)) {
84075 /* Probable double call_rcu(), so leak the callback. */
84076 - ACCESS_ONCE(head->func) = rcu_leak_callback;
84077 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
84078 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
84079 return;
84080 }
84081 @@ -2344,7 +2344,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84082 local_irq_restore(flags);
84083 return;
84084 }
84085 - ACCESS_ONCE(rdp->qlen)++;
84086 + ACCESS_ONCE_RW(rdp->qlen)++;
84087 if (lazy)
84088 rdp->qlen_lazy++;
84089 else
84090 @@ -2553,11 +2553,11 @@ void synchronize_sched_expedited(void)
84091 * counter wrap on a 32-bit system. Quite a few more CPUs would of
84092 * course be required on a 64-bit system.
84093 */
84094 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
84095 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
84096 (ulong)atomic_long_read(&rsp->expedited_done) +
84097 ULONG_MAX / 8)) {
84098 synchronize_sched();
84099 - atomic_long_inc(&rsp->expedited_wrap);
84100 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
84101 return;
84102 }
84103
84104 @@ -2565,7 +2565,7 @@ void synchronize_sched_expedited(void)
84105 * Take a ticket. Note that atomic_inc_return() implies a
84106 * full memory barrier.
84107 */
84108 - snap = atomic_long_inc_return(&rsp->expedited_start);
84109 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
84110 firstsnap = snap;
84111 get_online_cpus();
84112 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
84113 @@ -2578,14 +2578,14 @@ void synchronize_sched_expedited(void)
84114 synchronize_sched_expedited_cpu_stop,
84115 NULL) == -EAGAIN) {
84116 put_online_cpus();
84117 - atomic_long_inc(&rsp->expedited_tryfail);
84118 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
84119
84120 /* Check to see if someone else did our work for us. */
84121 s = atomic_long_read(&rsp->expedited_done);
84122 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84123 /* ensure test happens before caller kfree */
84124 smp_mb__before_atomic_inc(); /* ^^^ */
84125 - atomic_long_inc(&rsp->expedited_workdone1);
84126 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
84127 return;
84128 }
84129
84130 @@ -2594,7 +2594,7 @@ void synchronize_sched_expedited(void)
84131 udelay(trycount * num_online_cpus());
84132 } else {
84133 wait_rcu_gp(call_rcu_sched);
84134 - atomic_long_inc(&rsp->expedited_normal);
84135 + atomic_long_inc_unchecked(&rsp->expedited_normal);
84136 return;
84137 }
84138
84139 @@ -2603,7 +2603,7 @@ void synchronize_sched_expedited(void)
84140 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84141 /* ensure test happens before caller kfree */
84142 smp_mb__before_atomic_inc(); /* ^^^ */
84143 - atomic_long_inc(&rsp->expedited_workdone2);
84144 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
84145 return;
84146 }
84147
84148 @@ -2615,10 +2615,10 @@ void synchronize_sched_expedited(void)
84149 * period works for us.
84150 */
84151 get_online_cpus();
84152 - snap = atomic_long_read(&rsp->expedited_start);
84153 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
84154 smp_mb(); /* ensure read is before try_stop_cpus(). */
84155 }
84156 - atomic_long_inc(&rsp->expedited_stoppedcpus);
84157 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
84158
84159 /*
84160 * Everyone up to our most recent fetch is covered by our grace
84161 @@ -2627,16 +2627,16 @@ void synchronize_sched_expedited(void)
84162 * than we did already did their update.
84163 */
84164 do {
84165 - atomic_long_inc(&rsp->expedited_done_tries);
84166 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
84167 s = atomic_long_read(&rsp->expedited_done);
84168 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
84169 /* ensure test happens before caller kfree */
84170 smp_mb__before_atomic_inc(); /* ^^^ */
84171 - atomic_long_inc(&rsp->expedited_done_lost);
84172 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
84173 break;
84174 }
84175 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
84176 - atomic_long_inc(&rsp->expedited_done_exit);
84177 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
84178
84179 put_online_cpus();
84180 }
84181 @@ -2829,7 +2829,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84182 * ACCESS_ONCE() to prevent the compiler from speculating
84183 * the increment to precede the early-exit check.
84184 */
84185 - ACCESS_ONCE(rsp->n_barrier_done)++;
84186 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84187 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
84188 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
84189 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
84190 @@ -2879,7 +2879,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84191
84192 /* Increment ->n_barrier_done to prevent duplicate work. */
84193 smp_mb(); /* Keep increment after above mechanism. */
84194 - ACCESS_ONCE(rsp->n_barrier_done)++;
84195 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84196 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
84197 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
84198 smp_mb(); /* Keep increment before caller's subsequent code. */
84199 @@ -2924,10 +2924,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
84200 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
84201 init_callback_list(rdp);
84202 rdp->qlen_lazy = 0;
84203 - ACCESS_ONCE(rdp->qlen) = 0;
84204 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84205 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
84206 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
84207 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
84208 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
84209 rdp->cpu = cpu;
84210 rdp->rsp = rsp;
84211 rcu_boot_init_nocb_percpu_data(rdp);
84212 @@ -2961,8 +2961,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
84213 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
84214 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
84215 rcu_sysidle_init_percpu_data(rdp->dynticks);
84216 - atomic_set(&rdp->dynticks->dynticks,
84217 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
84218 + atomic_set_unchecked(&rdp->dynticks->dynticks,
84219 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
84220 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
84221
84222 /* Add CPU to rcu_node bitmasks. */
84223 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
84224 index 5f97eab..db8f687 100644
84225 --- a/kernel/rcutree.h
84226 +++ b/kernel/rcutree.h
84227 @@ -87,11 +87,11 @@ struct rcu_dynticks {
84228 long long dynticks_nesting; /* Track irq/process nesting level. */
84229 /* Process level is worth LLONG_MAX/2. */
84230 int dynticks_nmi_nesting; /* Track NMI nesting level. */
84231 - atomic_t dynticks; /* Even value for idle, else odd. */
84232 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
84233 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
84234 long long dynticks_idle_nesting;
84235 /* irq/process nesting level from idle. */
84236 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
84237 + atomic_unchecked_t dynticks_idle; /* Even value for idle, else odd. */
84238 /* "Idle" excludes userspace execution. */
84239 unsigned long dynticks_idle_jiffies;
84240 /* End of last non-NMI non-idle period. */
84241 @@ -427,17 +427,17 @@ struct rcu_state {
84242 /* _rcu_barrier(). */
84243 /* End of fields guarded by barrier_mutex. */
84244
84245 - atomic_long_t expedited_start; /* Starting ticket. */
84246 - atomic_long_t expedited_done; /* Done ticket. */
84247 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
84248 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
84249 - atomic_long_t expedited_workdone1; /* # done by others #1. */
84250 - atomic_long_t expedited_workdone2; /* # done by others #2. */
84251 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
84252 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
84253 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
84254 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
84255 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
84256 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
84257 + atomic_long_t expedited_done; /* Done ticket. */
84258 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
84259 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
84260 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
84261 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
84262 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
84263 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
84264 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
84265 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
84266 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
84267
84268 unsigned long jiffies_force_qs; /* Time at which to invoke */
84269 /* force_quiescent_state(). */
84270 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
84271 index 130c97b..da2e5fc 100644
84272 --- a/kernel/rcutree_plugin.h
84273 +++ b/kernel/rcutree_plugin.h
84274 @@ -900,7 +900,7 @@ void synchronize_rcu_expedited(void)
84275
84276 /* Clean up and exit. */
84277 smp_mb(); /* ensure expedited GP seen before counter increment. */
84278 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
84279 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
84280 unlock_mb_ret:
84281 mutex_unlock(&sync_rcu_preempt_exp_mutex);
84282 mb_ret:
84283 @@ -1474,7 +1474,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
84284 free_cpumask_var(cm);
84285 }
84286
84287 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
84288 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
84289 .store = &rcu_cpu_kthread_task,
84290 .thread_should_run = rcu_cpu_kthread_should_run,
84291 .thread_fn = rcu_cpu_kthread,
84292 @@ -1939,7 +1939,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
84293 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
84294 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
84295 cpu, ticks_value, ticks_title,
84296 - atomic_read(&rdtp->dynticks) & 0xfff,
84297 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
84298 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
84299 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
84300 fast_no_hz);
84301 @@ -2102,7 +2102,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
84302
84303 /* Enqueue the callback on the nocb list and update counts. */
84304 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
84305 - ACCESS_ONCE(*old_rhpp) = rhp;
84306 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
84307 atomic_long_add(rhcount, &rdp->nocb_q_count);
84308 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
84309
84310 @@ -2242,12 +2242,12 @@ static int rcu_nocb_kthread(void *arg)
84311 * Extract queued callbacks, update counts, and wait
84312 * for a grace period to elapse.
84313 */
84314 - ACCESS_ONCE(rdp->nocb_head) = NULL;
84315 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
84316 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
84317 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
84318 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
84319 - ACCESS_ONCE(rdp->nocb_p_count) += c;
84320 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
84321 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
84322 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
84323 rcu_nocb_wait_gp(rdp);
84324
84325 /* Each pass through the following loop invokes a callback. */
84326 @@ -2269,8 +2269,8 @@ static int rcu_nocb_kthread(void *arg)
84327 list = next;
84328 }
84329 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
84330 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
84331 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
84332 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
84333 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
84334 rdp->n_nocbs_invoked += c;
84335 }
84336 return 0;
84337 @@ -2297,7 +2297,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
84338 t = kthread_run(rcu_nocb_kthread, rdp,
84339 "rcuo%c/%d", rsp->abbr, cpu);
84340 BUG_ON(IS_ERR(t));
84341 - ACCESS_ONCE(rdp->nocb_kthread) = t;
84342 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
84343 }
84344 }
84345
84346 @@ -2425,9 +2425,9 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
84347 j = jiffies;
84348 ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
84349 smp_mb__before_atomic_inc();
84350 - atomic_inc(&rdtp->dynticks_idle);
84351 + atomic_inc_unchecked(&rdtp->dynticks_idle);
84352 smp_mb__after_atomic_inc();
84353 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
84354 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
84355 }
84356
84357 /*
84358 @@ -2492,9 +2492,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
84359
84360 /* Record end of idle period. */
84361 smp_mb__before_atomic_inc();
84362 - atomic_inc(&rdtp->dynticks_idle);
84363 + atomic_inc_unchecked(&rdtp->dynticks_idle);
84364 smp_mb__after_atomic_inc();
84365 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
84366 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
84367
84368 /*
84369 * If we are the timekeeping CPU, we are permitted to be non-idle
84370 @@ -2535,7 +2535,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
84371 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
84372
84373 /* Pick up current idle and NMI-nesting counter and check. */
84374 - cur = atomic_read(&rdtp->dynticks_idle);
84375 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
84376 if (cur & 0x1) {
84377 *isidle = false; /* We are not idle! */
84378 return;
84379 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
84380 index cf6c174..a8f4b50 100644
84381 --- a/kernel/rcutree_trace.c
84382 +++ b/kernel/rcutree_trace.c
84383 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
84384 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
84385 rdp->passed_quiesce, rdp->qs_pending);
84386 seq_printf(m, " dt=%d/%llx/%d df=%lu",
84387 - atomic_read(&rdp->dynticks->dynticks),
84388 + atomic_read_unchecked(&rdp->dynticks->dynticks),
84389 rdp->dynticks->dynticks_nesting,
84390 rdp->dynticks->dynticks_nmi_nesting,
84391 rdp->dynticks_fqs);
84392 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
84393 struct rcu_state *rsp = (struct rcu_state *)m->private;
84394
84395 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",
84396 - atomic_long_read(&rsp->expedited_start),
84397 + atomic_long_read_unchecked(&rsp->expedited_start),
84398 atomic_long_read(&rsp->expedited_done),
84399 - atomic_long_read(&rsp->expedited_wrap),
84400 - atomic_long_read(&rsp->expedited_tryfail),
84401 - atomic_long_read(&rsp->expedited_workdone1),
84402 - atomic_long_read(&rsp->expedited_workdone2),
84403 - atomic_long_read(&rsp->expedited_normal),
84404 - atomic_long_read(&rsp->expedited_stoppedcpus),
84405 - atomic_long_read(&rsp->expedited_done_tries),
84406 - atomic_long_read(&rsp->expedited_done_lost),
84407 - atomic_long_read(&rsp->expedited_done_exit));
84408 + atomic_long_read_unchecked(&rsp->expedited_wrap),
84409 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
84410 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
84411 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
84412 + atomic_long_read_unchecked(&rsp->expedited_normal),
84413 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
84414 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
84415 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
84416 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
84417 return 0;
84418 }
84419
84420 diff --git a/kernel/resource.c b/kernel/resource.c
84421 index 3f285dc..5755f62 100644
84422 --- a/kernel/resource.c
84423 +++ b/kernel/resource.c
84424 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
84425
84426 static int __init ioresources_init(void)
84427 {
84428 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84429 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84430 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
84431 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
84432 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84433 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
84434 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
84435 +#endif
84436 +#else
84437 proc_create("ioports", 0, NULL, &proc_ioports_operations);
84438 proc_create("iomem", 0, NULL, &proc_iomem_operations);
84439 +#endif
84440 return 0;
84441 }
84442 __initcall(ioresources_init);
84443 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
84444 index 1d96dd0..994ff19 100644
84445 --- a/kernel/rtmutex-tester.c
84446 +++ b/kernel/rtmutex-tester.c
84447 @@ -22,7 +22,7 @@
84448 #define MAX_RT_TEST_MUTEXES 8
84449
84450 static spinlock_t rttest_lock;
84451 -static atomic_t rttest_event;
84452 +static atomic_unchecked_t rttest_event;
84453
84454 struct test_thread_data {
84455 int opcode;
84456 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84457
84458 case RTTEST_LOCKCONT:
84459 td->mutexes[td->opdata] = 1;
84460 - td->event = atomic_add_return(1, &rttest_event);
84461 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84462 return 0;
84463
84464 case RTTEST_RESET:
84465 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84466 return 0;
84467
84468 case RTTEST_RESETEVENT:
84469 - atomic_set(&rttest_event, 0);
84470 + atomic_set_unchecked(&rttest_event, 0);
84471 return 0;
84472
84473 default:
84474 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84475 return ret;
84476
84477 td->mutexes[id] = 1;
84478 - td->event = atomic_add_return(1, &rttest_event);
84479 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84480 rt_mutex_lock(&mutexes[id]);
84481 - td->event = atomic_add_return(1, &rttest_event);
84482 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84483 td->mutexes[id] = 4;
84484 return 0;
84485
84486 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84487 return ret;
84488
84489 td->mutexes[id] = 1;
84490 - td->event = atomic_add_return(1, &rttest_event);
84491 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84492 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
84493 - td->event = atomic_add_return(1, &rttest_event);
84494 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84495 td->mutexes[id] = ret ? 0 : 4;
84496 return ret ? -EINTR : 0;
84497
84498 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84499 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
84500 return ret;
84501
84502 - td->event = atomic_add_return(1, &rttest_event);
84503 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84504 rt_mutex_unlock(&mutexes[id]);
84505 - td->event = atomic_add_return(1, &rttest_event);
84506 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84507 td->mutexes[id] = 0;
84508 return 0;
84509
84510 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84511 break;
84512
84513 td->mutexes[dat] = 2;
84514 - td->event = atomic_add_return(1, &rttest_event);
84515 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84516 break;
84517
84518 default:
84519 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84520 return;
84521
84522 td->mutexes[dat] = 3;
84523 - td->event = atomic_add_return(1, &rttest_event);
84524 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84525 break;
84526
84527 case RTTEST_LOCKNOWAIT:
84528 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84529 return;
84530
84531 td->mutexes[dat] = 1;
84532 - td->event = atomic_add_return(1, &rttest_event);
84533 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84534 return;
84535
84536 default:
84537 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
84538 index 4a07353..66b5291 100644
84539 --- a/kernel/sched/auto_group.c
84540 +++ b/kernel/sched/auto_group.c
84541 @@ -11,7 +11,7 @@
84542
84543 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
84544 static struct autogroup autogroup_default;
84545 -static atomic_t autogroup_seq_nr;
84546 +static atomic_unchecked_t autogroup_seq_nr;
84547
84548 void __init autogroup_init(struct task_struct *init_task)
84549 {
84550 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
84551
84552 kref_init(&ag->kref);
84553 init_rwsem(&ag->lock);
84554 - ag->id = atomic_inc_return(&autogroup_seq_nr);
84555 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
84556 ag->tg = tg;
84557 #ifdef CONFIG_RT_GROUP_SCHED
84558 /*
84559 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
84560 index 5ac63c9..d912786 100644
84561 --- a/kernel/sched/core.c
84562 +++ b/kernel/sched/core.c
84563 @@ -2868,7 +2868,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
84564 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
84565 * or number of jiffies left till timeout) if completed.
84566 */
84567 -long __sched
84568 +long __sched __intentional_overflow(-1)
84569 wait_for_completion_interruptible_timeout(struct completion *x,
84570 unsigned long timeout)
84571 {
84572 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
84573 *
84574 * Return: -ERESTARTSYS if interrupted, 0 if completed.
84575 */
84576 -int __sched wait_for_completion_killable(struct completion *x)
84577 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
84578 {
84579 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
84580 if (t == -ERESTARTSYS)
84581 @@ -2906,7 +2906,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
84582 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
84583 * or number of jiffies left till timeout) if completed.
84584 */
84585 -long __sched
84586 +long __sched __intentional_overflow(-1)
84587 wait_for_completion_killable_timeout(struct completion *x,
84588 unsigned long timeout)
84589 {
84590 @@ -3132,6 +3132,8 @@ int can_nice(const struct task_struct *p, const int nice)
84591 /* convert nice value [19,-20] to rlimit style value [1,40] */
84592 int nice_rlim = 20 - nice;
84593
84594 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
84595 +
84596 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
84597 capable(CAP_SYS_NICE));
84598 }
84599 @@ -3165,7 +3167,8 @@ SYSCALL_DEFINE1(nice, int, increment)
84600 if (nice > 19)
84601 nice = 19;
84602
84603 - if (increment < 0 && !can_nice(current, nice))
84604 + if (increment < 0 && (!can_nice(current, nice) ||
84605 + gr_handle_chroot_nice()))
84606 return -EPERM;
84607
84608 retval = security_task_setnice(current, nice);
84609 @@ -3327,6 +3330,7 @@ recheck:
84610 unsigned long rlim_rtprio =
84611 task_rlimit(p, RLIMIT_RTPRIO);
84612
84613 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
84614 /* can't set/change the rt policy */
84615 if (policy != p->policy && !rlim_rtprio)
84616 return -EPERM;
84617 @@ -4456,7 +4460,7 @@ static void migrate_tasks(unsigned int dead_cpu)
84618
84619 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
84620
84621 -static struct ctl_table sd_ctl_dir[] = {
84622 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
84623 {
84624 .procname = "sched_domain",
84625 .mode = 0555,
84626 @@ -4473,17 +4477,17 @@ static struct ctl_table sd_ctl_root[] = {
84627 {}
84628 };
84629
84630 -static struct ctl_table *sd_alloc_ctl_entry(int n)
84631 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
84632 {
84633 - struct ctl_table *entry =
84634 + ctl_table_no_const *entry =
84635 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
84636
84637 return entry;
84638 }
84639
84640 -static void sd_free_ctl_entry(struct ctl_table **tablep)
84641 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
84642 {
84643 - struct ctl_table *entry;
84644 + ctl_table_no_const *entry;
84645
84646 /*
84647 * In the intermediate directories, both the child directory and
84648 @@ -4491,22 +4495,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
84649 * will always be set. In the lowest directory the names are
84650 * static strings and all have proc handlers.
84651 */
84652 - for (entry = *tablep; entry->mode; entry++) {
84653 - if (entry->child)
84654 - sd_free_ctl_entry(&entry->child);
84655 + for (entry = tablep; entry->mode; entry++) {
84656 + if (entry->child) {
84657 + sd_free_ctl_entry(entry->child);
84658 + pax_open_kernel();
84659 + entry->child = NULL;
84660 + pax_close_kernel();
84661 + }
84662 if (entry->proc_handler == NULL)
84663 kfree(entry->procname);
84664 }
84665
84666 - kfree(*tablep);
84667 - *tablep = NULL;
84668 + kfree(tablep);
84669 }
84670
84671 static int min_load_idx = 0;
84672 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
84673
84674 static void
84675 -set_table_entry(struct ctl_table *entry,
84676 +set_table_entry(ctl_table_no_const *entry,
84677 const char *procname, void *data, int maxlen,
84678 umode_t mode, proc_handler *proc_handler,
84679 bool load_idx)
84680 @@ -4526,7 +4533,7 @@ set_table_entry(struct ctl_table *entry,
84681 static struct ctl_table *
84682 sd_alloc_ctl_domain_table(struct sched_domain *sd)
84683 {
84684 - struct ctl_table *table = sd_alloc_ctl_entry(13);
84685 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
84686
84687 if (table == NULL)
84688 return NULL;
84689 @@ -4561,9 +4568,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
84690 return table;
84691 }
84692
84693 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
84694 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
84695 {
84696 - struct ctl_table *entry, *table;
84697 + ctl_table_no_const *entry, *table;
84698 struct sched_domain *sd;
84699 int domain_num = 0, i;
84700 char buf[32];
84701 @@ -4590,11 +4597,13 @@ static struct ctl_table_header *sd_sysctl_header;
84702 static void register_sched_domain_sysctl(void)
84703 {
84704 int i, cpu_num = num_possible_cpus();
84705 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
84706 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
84707 char buf[32];
84708
84709 WARN_ON(sd_ctl_dir[0].child);
84710 + pax_open_kernel();
84711 sd_ctl_dir[0].child = entry;
84712 + pax_close_kernel();
84713
84714 if (entry == NULL)
84715 return;
84716 @@ -4617,8 +4626,12 @@ static void unregister_sched_domain_sysctl(void)
84717 if (sd_sysctl_header)
84718 unregister_sysctl_table(sd_sysctl_header);
84719 sd_sysctl_header = NULL;
84720 - if (sd_ctl_dir[0].child)
84721 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
84722 + if (sd_ctl_dir[0].child) {
84723 + sd_free_ctl_entry(sd_ctl_dir[0].child);
84724 + pax_open_kernel();
84725 + sd_ctl_dir[0].child = NULL;
84726 + pax_close_kernel();
84727 + }
84728 }
84729 #else
84730 static void register_sched_domain_sysctl(void)
84731 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
84732 index 7c70201..23f52b6 100644
84733 --- a/kernel/sched/fair.c
84734 +++ b/kernel/sched/fair.c
84735 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
84736
84737 static void reset_ptenuma_scan(struct task_struct *p)
84738 {
84739 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
84740 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
84741 p->mm->numa_scan_offset = 0;
84742 }
84743
84744 @@ -5838,7 +5838,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
84745 * run_rebalance_domains is triggered when needed from the scheduler tick.
84746 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
84747 */
84748 -static void run_rebalance_domains(struct softirq_action *h)
84749 +static __latent_entropy void run_rebalance_domains(void)
84750 {
84751 int this_cpu = smp_processor_id();
84752 struct rq *this_rq = cpu_rq(this_cpu);
84753 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
84754 index b3c5653..a4d192a 100644
84755 --- a/kernel/sched/sched.h
84756 +++ b/kernel/sched/sched.h
84757 @@ -1004,7 +1004,7 @@ struct sched_class {
84758 #ifdef CONFIG_FAIR_GROUP_SCHED
84759 void (*task_move_group) (struct task_struct *p, int on_rq);
84760 #endif
84761 -};
84762 +} __do_const;
84763
84764 #define sched_class_highest (&stop_sched_class)
84765 #define for_each_class(class) \
84766 diff --git a/kernel/signal.c b/kernel/signal.c
84767 index ded28b9..6886c08 100644
84768 --- a/kernel/signal.c
84769 +++ b/kernel/signal.c
84770 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
84771
84772 int print_fatal_signals __read_mostly;
84773
84774 -static void __user *sig_handler(struct task_struct *t, int sig)
84775 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
84776 {
84777 return t->sighand->action[sig - 1].sa.sa_handler;
84778 }
84779
84780 -static int sig_handler_ignored(void __user *handler, int sig)
84781 +static int sig_handler_ignored(__sighandler_t handler, int sig)
84782 {
84783 /* Is it explicitly or implicitly ignored? */
84784 return handler == SIG_IGN ||
84785 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
84786
84787 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
84788 {
84789 - void __user *handler;
84790 + __sighandler_t handler;
84791
84792 handler = sig_handler(t, sig);
84793
84794 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
84795 atomic_inc(&user->sigpending);
84796 rcu_read_unlock();
84797
84798 + if (!override_rlimit)
84799 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
84800 +
84801 if (override_rlimit ||
84802 atomic_read(&user->sigpending) <=
84803 task_rlimit(t, RLIMIT_SIGPENDING)) {
84804 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
84805
84806 int unhandled_signal(struct task_struct *tsk, int sig)
84807 {
84808 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
84809 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
84810 if (is_global_init(tsk))
84811 return 1;
84812 if (handler != SIG_IGN && handler != SIG_DFL)
84813 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
84814 }
84815 }
84816
84817 + /* allow glibc communication via tgkill to other threads in our
84818 + thread group */
84819 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
84820 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
84821 + && gr_handle_signal(t, sig))
84822 + return -EPERM;
84823 +
84824 return security_task_kill(t, info, sig, 0);
84825 }
84826
84827 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84828 return send_signal(sig, info, p, 1);
84829 }
84830
84831 -static int
84832 +int
84833 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84834 {
84835 return send_signal(sig, info, t, 0);
84836 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84837 unsigned long int flags;
84838 int ret, blocked, ignored;
84839 struct k_sigaction *action;
84840 + int is_unhandled = 0;
84841
84842 spin_lock_irqsave(&t->sighand->siglock, flags);
84843 action = &t->sighand->action[sig-1];
84844 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
84845 }
84846 if (action->sa.sa_handler == SIG_DFL)
84847 t->signal->flags &= ~SIGNAL_UNKILLABLE;
84848 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
84849 + is_unhandled = 1;
84850 ret = specific_send_sig_info(sig, info, t);
84851 spin_unlock_irqrestore(&t->sighand->siglock, flags);
84852
84853 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
84854 + normal operation */
84855 + if (is_unhandled) {
84856 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
84857 + gr_handle_crash(t, sig);
84858 + }
84859 +
84860 return ret;
84861 }
84862
84863 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
84864 ret = check_kill_permission(sig, info, p);
84865 rcu_read_unlock();
84866
84867 - if (!ret && sig)
84868 + if (!ret && sig) {
84869 ret = do_send_sig_info(sig, info, p, true);
84870 + if (!ret)
84871 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
84872 + }
84873
84874 return ret;
84875 }
84876 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
84877 int error = -ESRCH;
84878
84879 rcu_read_lock();
84880 - p = find_task_by_vpid(pid);
84881 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
84882 + /* allow glibc communication via tgkill to other threads in our
84883 + thread group */
84884 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
84885 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
84886 + p = find_task_by_vpid_unrestricted(pid);
84887 + else
84888 +#endif
84889 + p = find_task_by_vpid(pid);
84890 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
84891 error = check_kill_permission(sig, info, p);
84892 /*
84893 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
84894 }
84895 seg = get_fs();
84896 set_fs(KERNEL_DS);
84897 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
84898 - (stack_t __force __user *) &uoss,
84899 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
84900 + (stack_t __force_user *) &uoss,
84901 compat_user_stack_pointer());
84902 set_fs(seg);
84903 if (ret >= 0 && uoss_ptr) {
84904 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
84905 index eb89e18..a4e6792 100644
84906 --- a/kernel/smpboot.c
84907 +++ b/kernel/smpboot.c
84908 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
84909 }
84910 smpboot_unpark_thread(plug_thread, cpu);
84911 }
84912 - list_add(&plug_thread->list, &hotplug_threads);
84913 + pax_list_add(&plug_thread->list, &hotplug_threads);
84914 out:
84915 mutex_unlock(&smpboot_threads_lock);
84916 return ret;
84917 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
84918 {
84919 get_online_cpus();
84920 mutex_lock(&smpboot_threads_lock);
84921 - list_del(&plug_thread->list);
84922 + pax_list_del(&plug_thread->list);
84923 smpboot_destroy_threads(plug_thread);
84924 mutex_unlock(&smpboot_threads_lock);
84925 put_online_cpus();
84926 diff --git a/kernel/softirq.c b/kernel/softirq.c
84927 index d7d498d..94fe0f7 100644
84928 --- a/kernel/softirq.c
84929 +++ b/kernel/softirq.c
84930 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
84931 EXPORT_SYMBOL(irq_stat);
84932 #endif
84933
84934 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
84935 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
84936
84937 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
84938
84939 -char *softirq_to_name[NR_SOFTIRQS] = {
84940 +const char * const softirq_to_name[NR_SOFTIRQS] = {
84941 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
84942 "TASKLET", "SCHED", "HRTIMER", "RCU"
84943 };
84944 @@ -248,7 +248,7 @@ restart:
84945 kstat_incr_softirqs_this_cpu(vec_nr);
84946
84947 trace_softirq_entry(vec_nr);
84948 - h->action(h);
84949 + h->action();
84950 trace_softirq_exit(vec_nr);
84951 if (unlikely(prev_count != preempt_count())) {
84952 printk(KERN_ERR "huh, entered softirq %u %s %p"
84953 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
84954 or_softirq_pending(1UL << nr);
84955 }
84956
84957 -void open_softirq(int nr, void (*action)(struct softirq_action *))
84958 +void __init open_softirq(int nr, void (*action)(void))
84959 {
84960 softirq_vec[nr].action = action;
84961 }
84962 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
84963
84964 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
84965
84966 -static void tasklet_action(struct softirq_action *a)
84967 +static __latent_entropy void tasklet_action(void)
84968 {
84969 struct tasklet_struct *list;
84970
84971 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
84972 }
84973 }
84974
84975 -static void tasklet_hi_action(struct softirq_action *a)
84976 +static __latent_entropy void tasklet_hi_action(void)
84977 {
84978 struct tasklet_struct *list;
84979
84980 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
84981 .notifier_call = cpu_callback
84982 };
84983
84984 -static struct smp_hotplug_thread softirq_threads = {
84985 +static struct smp_hotplug_thread softirq_threads __read_only = {
84986 .store = &ksoftirqd,
84987 .thread_should_run = ksoftirqd_should_run,
84988 .thread_fn = run_ksoftirqd,
84989 diff --git a/kernel/srcu.c b/kernel/srcu.c
84990 index 01d5ccb..cdcbee6 100644
84991 --- a/kernel/srcu.c
84992 +++ b/kernel/srcu.c
84993 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
84994
84995 idx = ACCESS_ONCE(sp->completed) & 0x1;
84996 preempt_disable();
84997 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84998 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84999 smp_mb(); /* B */ /* Avoid leaking the critical section. */
85000 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85001 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85002 preempt_enable();
85003 return idx;
85004 }
85005 diff --git a/kernel/sys.c b/kernel/sys.c
85006 index c18ecca..b3c2dd2 100644
85007 --- a/kernel/sys.c
85008 +++ b/kernel/sys.c
85009 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
85010 error = -EACCES;
85011 goto out;
85012 }
85013 +
85014 + if (gr_handle_chroot_setpriority(p, niceval)) {
85015 + error = -EACCES;
85016 + goto out;
85017 + }
85018 +
85019 no_nice = security_task_setnice(p, niceval);
85020 if (no_nice) {
85021 error = no_nice;
85022 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
85023 goto error;
85024 }
85025
85026 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
85027 + goto error;
85028 +
85029 if (rgid != (gid_t) -1 ||
85030 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
85031 new->sgid = new->egid;
85032 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
85033 old = current_cred();
85034
85035 retval = -EPERM;
85036 +
85037 + if (gr_check_group_change(kgid, kgid, kgid))
85038 + goto error;
85039 +
85040 if (ns_capable(old->user_ns, CAP_SETGID))
85041 new->gid = new->egid = new->sgid = new->fsgid = kgid;
85042 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
85043 @@ -404,7 +417,7 @@ error:
85044 /*
85045 * change the user struct in a credentials set to match the new UID
85046 */
85047 -static int set_user(struct cred *new)
85048 +int set_user(struct cred *new)
85049 {
85050 struct user_struct *new_user;
85051
85052 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
85053 goto error;
85054 }
85055
85056 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
85057 + goto error;
85058 +
85059 if (!uid_eq(new->uid, old->uid)) {
85060 retval = set_user(new);
85061 if (retval < 0)
85062 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
85063 old = current_cred();
85064
85065 retval = -EPERM;
85066 +
85067 + if (gr_check_crash_uid(kuid))
85068 + goto error;
85069 + if (gr_check_user_change(kuid, kuid, kuid))
85070 + goto error;
85071 +
85072 if (ns_capable(old->user_ns, CAP_SETUID)) {
85073 new->suid = new->uid = kuid;
85074 if (!uid_eq(kuid, old->uid)) {
85075 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
85076 goto error;
85077 }
85078
85079 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
85080 + goto error;
85081 +
85082 if (ruid != (uid_t) -1) {
85083 new->uid = kruid;
85084 if (!uid_eq(kruid, old->uid)) {
85085 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
85086 goto error;
85087 }
85088
85089 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
85090 + goto error;
85091 +
85092 if (rgid != (gid_t) -1)
85093 new->gid = krgid;
85094 if (egid != (gid_t) -1)
85095 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
85096 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
85097 ns_capable(old->user_ns, CAP_SETUID)) {
85098 if (!uid_eq(kuid, old->fsuid)) {
85099 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
85100 + goto error;
85101 +
85102 new->fsuid = kuid;
85103 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
85104 goto change_okay;
85105 }
85106 }
85107
85108 +error:
85109 abort_creds(new);
85110 return old_fsuid;
85111
85112 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
85113 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
85114 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
85115 ns_capable(old->user_ns, CAP_SETGID)) {
85116 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
85117 + goto error;
85118 +
85119 if (!gid_eq(kgid, old->fsgid)) {
85120 new->fsgid = kgid;
85121 goto change_okay;
85122 }
85123 }
85124
85125 +error:
85126 abort_creds(new);
85127 return old_fsgid;
85128
85129 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
85130 return -EFAULT;
85131
85132 down_read(&uts_sem);
85133 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
85134 + error = __copy_to_user(name->sysname, &utsname()->sysname,
85135 __OLD_UTS_LEN);
85136 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
85137 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
85138 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
85139 __OLD_UTS_LEN);
85140 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
85141 - error |= __copy_to_user(&name->release, &utsname()->release,
85142 + error |= __copy_to_user(name->release, &utsname()->release,
85143 __OLD_UTS_LEN);
85144 error |= __put_user(0, name->release + __OLD_UTS_LEN);
85145 - error |= __copy_to_user(&name->version, &utsname()->version,
85146 + error |= __copy_to_user(name->version, &utsname()->version,
85147 __OLD_UTS_LEN);
85148 error |= __put_user(0, name->version + __OLD_UTS_LEN);
85149 - error |= __copy_to_user(&name->machine, &utsname()->machine,
85150 + error |= __copy_to_user(name->machine, &utsname()->machine,
85151 __OLD_UTS_LEN);
85152 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
85153 up_read(&uts_sem);
85154 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
85155 */
85156 new_rlim->rlim_cur = 1;
85157 }
85158 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
85159 + is changed to a lower value. Since tasks can be created by the same
85160 + user in between this limit change and an execve by this task, force
85161 + a recheck only for this task by setting PF_NPROC_EXCEEDED
85162 + */
85163 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
85164 + tsk->flags |= PF_NPROC_EXCEEDED;
85165 }
85166 if (!retval) {
85167 if (old_rlim)
85168 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
85169 index b2f06f3..e6354ab 100644
85170 --- a/kernel/sysctl.c
85171 +++ b/kernel/sysctl.c
85172 @@ -93,7 +93,6 @@
85173
85174
85175 #if defined(CONFIG_SYSCTL)
85176 -
85177 /* External variables not in a header file. */
85178 extern int sysctl_overcommit_memory;
85179 extern int sysctl_overcommit_ratio;
85180 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
85181
85182 /* Constants used for minimum and maximum */
85183 #ifdef CONFIG_LOCKUP_DETECTOR
85184 -static int sixty = 60;
85185 +static int sixty __read_only = 60;
85186 #endif
85187
85188 -static int zero;
85189 -static int __maybe_unused one = 1;
85190 -static int __maybe_unused two = 2;
85191 -static int __maybe_unused three = 3;
85192 -static unsigned long one_ul = 1;
85193 -static int one_hundred = 100;
85194 +static int neg_one __read_only = -1;
85195 +static int zero __read_only = 0;
85196 +static int __maybe_unused one __read_only = 1;
85197 +static int __maybe_unused two __read_only = 2;
85198 +static int __maybe_unused three __read_only = 3;
85199 +static unsigned long one_ul __read_only = 1;
85200 +static int one_hundred __read_only = 100;
85201 #ifdef CONFIG_PRINTK
85202 -static int ten_thousand = 10000;
85203 +static int ten_thousand __read_only = 10000;
85204 #endif
85205
85206 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
85207 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
85208 void __user *buffer, size_t *lenp, loff_t *ppos);
85209 #endif
85210
85211 -#ifdef CONFIG_PRINTK
85212 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85213 void __user *buffer, size_t *lenp, loff_t *ppos);
85214 -#endif
85215
85216 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
85217 void __user *buffer, size_t *lenp, loff_t *ppos);
85218 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
85219
85220 #endif
85221
85222 +extern struct ctl_table grsecurity_table[];
85223 +
85224 static struct ctl_table kern_table[];
85225 static struct ctl_table vm_table[];
85226 static struct ctl_table fs_table[];
85227 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
85228 int sysctl_legacy_va_layout;
85229 #endif
85230
85231 +#ifdef CONFIG_PAX_SOFTMODE
85232 +static ctl_table pax_table[] = {
85233 + {
85234 + .procname = "softmode",
85235 + .data = &pax_softmode,
85236 + .maxlen = sizeof(unsigned int),
85237 + .mode = 0600,
85238 + .proc_handler = &proc_dointvec,
85239 + },
85240 +
85241 + { }
85242 +};
85243 +#endif
85244 +
85245 /* The default sysctl tables: */
85246
85247 static struct ctl_table sysctl_base_table[] = {
85248 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
85249 #endif
85250
85251 static struct ctl_table kern_table[] = {
85252 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
85253 + {
85254 + .procname = "grsecurity",
85255 + .mode = 0500,
85256 + .child = grsecurity_table,
85257 + },
85258 +#endif
85259 +
85260 +#ifdef CONFIG_PAX_SOFTMODE
85261 + {
85262 + .procname = "pax",
85263 + .mode = 0500,
85264 + .child = pax_table,
85265 + },
85266 +#endif
85267 +
85268 {
85269 .procname = "sched_child_runs_first",
85270 .data = &sysctl_sched_child_runs_first,
85271 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
85272 .data = &modprobe_path,
85273 .maxlen = KMOD_PATH_LEN,
85274 .mode = 0644,
85275 - .proc_handler = proc_dostring,
85276 + .proc_handler = proc_dostring_modpriv,
85277 },
85278 {
85279 .procname = "modules_disabled",
85280 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
85281 .extra1 = &zero,
85282 .extra2 = &one,
85283 },
85284 +#endif
85285 {
85286 .procname = "kptr_restrict",
85287 .data = &kptr_restrict,
85288 .maxlen = sizeof(int),
85289 .mode = 0644,
85290 .proc_handler = proc_dointvec_minmax_sysadmin,
85291 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85292 + .extra1 = &two,
85293 +#else
85294 .extra1 = &zero,
85295 +#endif
85296 .extra2 = &two,
85297 },
85298 -#endif
85299 {
85300 .procname = "ngroups_max",
85301 .data = &ngroups_max,
85302 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
85303 */
85304 {
85305 .procname = "perf_event_paranoid",
85306 - .data = &sysctl_perf_event_paranoid,
85307 - .maxlen = sizeof(sysctl_perf_event_paranoid),
85308 + .data = &sysctl_perf_event_legitimately_concerned,
85309 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
85310 .mode = 0644,
85311 - .proc_handler = proc_dointvec,
85312 + /* go ahead, be a hero */
85313 + .proc_handler = proc_dointvec_minmax_sysadmin,
85314 + .extra1 = &neg_one,
85315 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
85316 + .extra2 = &three,
85317 +#else
85318 + .extra2 = &two,
85319 +#endif
85320 },
85321 {
85322 .procname = "perf_event_mlock_kb",
85323 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
85324 .proc_handler = proc_dointvec_minmax,
85325 .extra1 = &zero,
85326 },
85327 + {
85328 + .procname = "heap_stack_gap",
85329 + .data = &sysctl_heap_stack_gap,
85330 + .maxlen = sizeof(sysctl_heap_stack_gap),
85331 + .mode = 0644,
85332 + .proc_handler = proc_doulongvec_minmax,
85333 + },
85334 #else
85335 {
85336 .procname = "nr_trim_pages",
85337 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
85338 buffer, lenp, ppos);
85339 }
85340
85341 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85342 + void __user *buffer, size_t *lenp, loff_t *ppos)
85343 +{
85344 + if (write && !capable(CAP_SYS_MODULE))
85345 + return -EPERM;
85346 +
85347 + return _proc_do_string(table->data, table->maxlen, write,
85348 + buffer, lenp, ppos);
85349 +}
85350 +
85351 static size_t proc_skip_spaces(char **buf)
85352 {
85353 size_t ret;
85354 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
85355 len = strlen(tmp);
85356 if (len > *size)
85357 len = *size;
85358 + if (len > sizeof(tmp))
85359 + len = sizeof(tmp);
85360 if (copy_to_user(*buf, tmp, len))
85361 return -EFAULT;
85362 *size -= len;
85363 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
85364 static int proc_taint(struct ctl_table *table, int write,
85365 void __user *buffer, size_t *lenp, loff_t *ppos)
85366 {
85367 - struct ctl_table t;
85368 + ctl_table_no_const t;
85369 unsigned long tmptaint = get_taint();
85370 int err;
85371
85372 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
85373 return err;
85374 }
85375
85376 -#ifdef CONFIG_PRINTK
85377 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85378 void __user *buffer, size_t *lenp, loff_t *ppos)
85379 {
85380 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85381
85382 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
85383 }
85384 -#endif
85385
85386 struct do_proc_dointvec_minmax_conv_param {
85387 int *min;
85388 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
85389 *i = val;
85390 } else {
85391 val = convdiv * (*i) / convmul;
85392 - if (!first)
85393 + if (!first) {
85394 err = proc_put_char(&buffer, &left, '\t');
85395 + if (err)
85396 + break;
85397 + }
85398 err = proc_put_long(&buffer, &left, val, false);
85399 if (err)
85400 break;
85401 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
85402 return -ENOSYS;
85403 }
85404
85405 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85406 + void __user *buffer, size_t *lenp, loff_t *ppos)
85407 +{
85408 + return -ENOSYS;
85409 +}
85410 +
85411 int proc_dointvec(struct ctl_table *table, int write,
85412 void __user *buffer, size_t *lenp, loff_t *ppos)
85413 {
85414 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
85415 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
85416 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
85417 EXPORT_SYMBOL(proc_dostring);
85418 +EXPORT_SYMBOL(proc_dostring_modpriv);
85419 EXPORT_SYMBOL(proc_doulongvec_minmax);
85420 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
85421 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
85422 index 145bb4d..b2aa969 100644
85423 --- a/kernel/taskstats.c
85424 +++ b/kernel/taskstats.c
85425 @@ -28,9 +28,12 @@
85426 #include <linux/fs.h>
85427 #include <linux/file.h>
85428 #include <linux/pid_namespace.h>
85429 +#include <linux/grsecurity.h>
85430 #include <net/genetlink.h>
85431 #include <linux/atomic.h>
85432
85433 +extern int gr_is_taskstats_denied(int pid);
85434 +
85435 /*
85436 * Maximum length of a cpumask that can be specified in
85437 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
85438 @@ -570,6 +573,9 @@ err:
85439
85440 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
85441 {
85442 + if (gr_is_taskstats_denied(current->pid))
85443 + return -EACCES;
85444 +
85445 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
85446 return cmd_attr_register_cpumask(info);
85447 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
85448 diff --git a/kernel/time.c b/kernel/time.c
85449 index 7c7964c..2a0d412 100644
85450 --- a/kernel/time.c
85451 +++ b/kernel/time.c
85452 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
85453 return error;
85454
85455 if (tz) {
85456 + /* we log in do_settimeofday called below, so don't log twice
85457 + */
85458 + if (!tv)
85459 + gr_log_timechange();
85460 +
85461 sys_tz = *tz;
85462 update_vsyscall_tz();
85463 if (firsttime) {
85464 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
85465 index eec50fc..65e5df6 100644
85466 --- a/kernel/time/alarmtimer.c
85467 +++ b/kernel/time/alarmtimer.c
85468 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
85469 struct platform_device *pdev;
85470 int error = 0;
85471 int i;
85472 - struct k_clock alarm_clock = {
85473 + static struct k_clock alarm_clock = {
85474 .clock_getres = alarm_clock_getres,
85475 .clock_get = alarm_clock_get,
85476 .timer_create = alarm_timer_create,
85477 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
85478 index 947ba25..20cbade 100644
85479 --- a/kernel/time/timekeeping.c
85480 +++ b/kernel/time/timekeeping.c
85481 @@ -15,6 +15,7 @@
85482 #include <linux/init.h>
85483 #include <linux/mm.h>
85484 #include <linux/sched.h>
85485 +#include <linux/grsecurity.h>
85486 #include <linux/syscore_ops.h>
85487 #include <linux/clocksource.h>
85488 #include <linux/jiffies.h>
85489 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
85490 if (!timespec_valid_strict(tv))
85491 return -EINVAL;
85492
85493 + gr_log_timechange();
85494 +
85495 raw_spin_lock_irqsave(&timekeeper_lock, flags);
85496 write_seqcount_begin(&timekeeper_seq);
85497
85498 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
85499 index 61ed862..3b52c65 100644
85500 --- a/kernel/time/timer_list.c
85501 +++ b/kernel/time/timer_list.c
85502 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
85503
85504 static void print_name_offset(struct seq_file *m, void *sym)
85505 {
85506 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85507 + SEQ_printf(m, "<%p>", NULL);
85508 +#else
85509 char symname[KSYM_NAME_LEN];
85510
85511 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
85512 SEQ_printf(m, "<%pK>", sym);
85513 else
85514 SEQ_printf(m, "%s", symname);
85515 +#endif
85516 }
85517
85518 static void
85519 @@ -119,7 +123,11 @@ next_one:
85520 static void
85521 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
85522 {
85523 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85524 + SEQ_printf(m, " .base: %p\n", NULL);
85525 +#else
85526 SEQ_printf(m, " .base: %pK\n", base);
85527 +#endif
85528 SEQ_printf(m, " .index: %d\n",
85529 base->index);
85530 SEQ_printf(m, " .resolution: %Lu nsecs\n",
85531 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
85532 {
85533 struct proc_dir_entry *pe;
85534
85535 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85536 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
85537 +#else
85538 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
85539 +#endif
85540 if (!pe)
85541 return -ENOMEM;
85542 return 0;
85543 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
85544 index 0b537f2..40d6c20 100644
85545 --- a/kernel/time/timer_stats.c
85546 +++ b/kernel/time/timer_stats.c
85547 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
85548 static unsigned long nr_entries;
85549 static struct entry entries[MAX_ENTRIES];
85550
85551 -static atomic_t overflow_count;
85552 +static atomic_unchecked_t overflow_count;
85553
85554 /*
85555 * The entries are in a hash-table, for fast lookup:
85556 @@ -140,7 +140,7 @@ static void reset_entries(void)
85557 nr_entries = 0;
85558 memset(entries, 0, sizeof(entries));
85559 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
85560 - atomic_set(&overflow_count, 0);
85561 + atomic_set_unchecked(&overflow_count, 0);
85562 }
85563
85564 static struct entry *alloc_entry(void)
85565 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85566 if (likely(entry))
85567 entry->count++;
85568 else
85569 - atomic_inc(&overflow_count);
85570 + atomic_inc_unchecked(&overflow_count);
85571
85572 out_unlock:
85573 raw_spin_unlock_irqrestore(lock, flags);
85574 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85575
85576 static void print_name_offset(struct seq_file *m, unsigned long addr)
85577 {
85578 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85579 + seq_printf(m, "<%p>", NULL);
85580 +#else
85581 char symname[KSYM_NAME_LEN];
85582
85583 if (lookup_symbol_name(addr, symname) < 0)
85584 - seq_printf(m, "<%p>", (void *)addr);
85585 + seq_printf(m, "<%pK>", (void *)addr);
85586 else
85587 seq_printf(m, "%s", symname);
85588 +#endif
85589 }
85590
85591 static int tstats_show(struct seq_file *m, void *v)
85592 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
85593
85594 seq_puts(m, "Timer Stats Version: v0.2\n");
85595 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
85596 - if (atomic_read(&overflow_count))
85597 + if (atomic_read_unchecked(&overflow_count))
85598 seq_printf(m, "Overflow: %d entries\n",
85599 - atomic_read(&overflow_count));
85600 + atomic_read_unchecked(&overflow_count));
85601
85602 for (i = 0; i < nr_entries; i++) {
85603 entry = entries + i;
85604 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
85605 {
85606 struct proc_dir_entry *pe;
85607
85608 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85609 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
85610 +#else
85611 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
85612 +#endif
85613 if (!pe)
85614 return -ENOMEM;
85615 return 0;
85616 diff --git a/kernel/timer.c b/kernel/timer.c
85617 index 4296d13..0164b04 100644
85618 --- a/kernel/timer.c
85619 +++ b/kernel/timer.c
85620 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
85621 /*
85622 * This function runs timers and the timer-tq in bottom half context.
85623 */
85624 -static void run_timer_softirq(struct softirq_action *h)
85625 +static __latent_entropy void run_timer_softirq(void)
85626 {
85627 struct tvec_base *base = __this_cpu_read(tvec_bases);
85628
85629 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
85630 *
85631 * In all cases the return value is guaranteed to be non-negative.
85632 */
85633 -signed long __sched schedule_timeout(signed long timeout)
85634 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
85635 {
85636 struct timer_list timer;
85637 unsigned long expire;
85638 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
85639 index b8b8560..75b1a09 100644
85640 --- a/kernel/trace/blktrace.c
85641 +++ b/kernel/trace/blktrace.c
85642 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
85643 struct blk_trace *bt = filp->private_data;
85644 char buf[16];
85645
85646 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
85647 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
85648
85649 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
85650 }
85651 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
85652 return 1;
85653
85654 bt = buf->chan->private_data;
85655 - atomic_inc(&bt->dropped);
85656 + atomic_inc_unchecked(&bt->dropped);
85657 return 0;
85658 }
85659
85660 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
85661
85662 bt->dir = dir;
85663 bt->dev = dev;
85664 - atomic_set(&bt->dropped, 0);
85665 + atomic_set_unchecked(&bt->dropped, 0);
85666
85667 ret = -EIO;
85668 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
85669 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
85670 index 03cf44a..3051c64 100644
85671 --- a/kernel/trace/ftrace.c
85672 +++ b/kernel/trace/ftrace.c
85673 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
85674 if (unlikely(ftrace_disabled))
85675 return 0;
85676
85677 + ret = ftrace_arch_code_modify_prepare();
85678 + FTRACE_WARN_ON(ret);
85679 + if (ret)
85680 + return 0;
85681 +
85682 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
85683 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
85684 if (ret) {
85685 ftrace_bug(ret, ip);
85686 - return 0;
85687 }
85688 - return 1;
85689 + return ret ? 0 : 1;
85690 }
85691
85692 /*
85693 @@ -4043,8 +4048,10 @@ static int ftrace_process_locs(struct module *mod,
85694 if (!count)
85695 return 0;
85696
85697 + pax_open_kernel();
85698 sort(start, count, sizeof(*start),
85699 ftrace_cmp_ips, ftrace_swap_ips);
85700 + pax_close_kernel();
85701
85702 start_pg = ftrace_allocate_pages(count);
85703 if (!start_pg)
85704 @@ -4767,8 +4774,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
85705 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
85706
85707 static int ftrace_graph_active;
85708 -static struct notifier_block ftrace_suspend_notifier;
85709 -
85710 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
85711 {
85712 return 0;
85713 @@ -4912,6 +4917,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
85714 return NOTIFY_DONE;
85715 }
85716
85717 +static struct notifier_block ftrace_suspend_notifier = {
85718 + .notifier_call = ftrace_suspend_notifier_call
85719 +};
85720 +
85721 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85722 trace_func_graph_ent_t entryfunc)
85723 {
85724 @@ -4925,7 +4934,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85725 goto out;
85726 }
85727
85728 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
85729 register_pm_notifier(&ftrace_suspend_notifier);
85730
85731 ftrace_graph_active++;
85732 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
85733 index cc2f66f..05edd54 100644
85734 --- a/kernel/trace/ring_buffer.c
85735 +++ b/kernel/trace/ring_buffer.c
85736 @@ -352,9 +352,9 @@ struct buffer_data_page {
85737 */
85738 struct buffer_page {
85739 struct list_head list; /* list of buffer pages */
85740 - local_t write; /* index for next write */
85741 + local_unchecked_t write; /* index for next write */
85742 unsigned read; /* index for next read */
85743 - local_t entries; /* entries on this page */
85744 + local_unchecked_t entries; /* entries on this page */
85745 unsigned long real_end; /* real end of data */
85746 struct buffer_data_page *page; /* Actual data page */
85747 };
85748 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
85749 unsigned long last_overrun;
85750 local_t entries_bytes;
85751 local_t entries;
85752 - local_t overrun;
85753 - local_t commit_overrun;
85754 + local_unchecked_t overrun;
85755 + local_unchecked_t commit_overrun;
85756 local_t dropped_events;
85757 local_t committing;
85758 local_t commits;
85759 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85760 *
85761 * We add a counter to the write field to denote this.
85762 */
85763 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
85764 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
85765 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
85766 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
85767
85768 /*
85769 * Just make sure we have seen our old_write and synchronize
85770 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85771 * cmpxchg to only update if an interrupt did not already
85772 * do it for us. If the cmpxchg fails, we don't care.
85773 */
85774 - (void)local_cmpxchg(&next_page->write, old_write, val);
85775 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
85776 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
85777 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
85778
85779 /*
85780 * No need to worry about races with clearing out the commit.
85781 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
85782
85783 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
85784 {
85785 - return local_read(&bpage->entries) & RB_WRITE_MASK;
85786 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
85787 }
85788
85789 static inline unsigned long rb_page_write(struct buffer_page *bpage)
85790 {
85791 - return local_read(&bpage->write) & RB_WRITE_MASK;
85792 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
85793 }
85794
85795 static int
85796 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
85797 * bytes consumed in ring buffer from here.
85798 * Increment overrun to account for the lost events.
85799 */
85800 - local_add(page_entries, &cpu_buffer->overrun);
85801 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
85802 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85803 }
85804
85805 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
85806 * it is our responsibility to update
85807 * the counters.
85808 */
85809 - local_add(entries, &cpu_buffer->overrun);
85810 + local_add_unchecked(entries, &cpu_buffer->overrun);
85811 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85812
85813 /*
85814 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85815 if (tail == BUF_PAGE_SIZE)
85816 tail_page->real_end = 0;
85817
85818 - local_sub(length, &tail_page->write);
85819 + local_sub_unchecked(length, &tail_page->write);
85820 return;
85821 }
85822
85823 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85824 rb_event_set_padding(event);
85825
85826 /* Set the write back to the previous setting */
85827 - local_sub(length, &tail_page->write);
85828 + local_sub_unchecked(length, &tail_page->write);
85829 return;
85830 }
85831
85832 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
85833
85834 /* Set write to end of buffer */
85835 length = (tail + length) - BUF_PAGE_SIZE;
85836 - local_sub(length, &tail_page->write);
85837 + local_sub_unchecked(length, &tail_page->write);
85838 }
85839
85840 /*
85841 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
85842 * about it.
85843 */
85844 if (unlikely(next_page == commit_page)) {
85845 - local_inc(&cpu_buffer->commit_overrun);
85846 + local_inc_unchecked(&cpu_buffer->commit_overrun);
85847 goto out_reset;
85848 }
85849
85850 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
85851 cpu_buffer->tail_page) &&
85852 (cpu_buffer->commit_page ==
85853 cpu_buffer->reader_page))) {
85854 - local_inc(&cpu_buffer->commit_overrun);
85855 + local_inc_unchecked(&cpu_buffer->commit_overrun);
85856 goto out_reset;
85857 }
85858 }
85859 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
85860 length += RB_LEN_TIME_EXTEND;
85861
85862 tail_page = cpu_buffer->tail_page;
85863 - write = local_add_return(length, &tail_page->write);
85864 + write = local_add_return_unchecked(length, &tail_page->write);
85865
85866 /* set write to only the index of the write */
85867 write &= RB_WRITE_MASK;
85868 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
85869 kmemcheck_annotate_bitfield(event, bitfield);
85870 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
85871
85872 - local_inc(&tail_page->entries);
85873 + local_inc_unchecked(&tail_page->entries);
85874
85875 /*
85876 * If this is the first commit on the page, then update
85877 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
85878
85879 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
85880 unsigned long write_mask =
85881 - local_read(&bpage->write) & ~RB_WRITE_MASK;
85882 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
85883 unsigned long event_length = rb_event_length(event);
85884 /*
85885 * This is on the tail page. It is possible that
85886 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
85887 */
85888 old_index += write_mask;
85889 new_index += write_mask;
85890 - index = local_cmpxchg(&bpage->write, old_index, new_index);
85891 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
85892 if (index == old_index) {
85893 /* update counters */
85894 local_sub(event_length, &cpu_buffer->entries_bytes);
85895 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
85896
85897 /* Do the likely case first */
85898 if (likely(bpage->page == (void *)addr)) {
85899 - local_dec(&bpage->entries);
85900 + local_dec_unchecked(&bpage->entries);
85901 return;
85902 }
85903
85904 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
85905 start = bpage;
85906 do {
85907 if (bpage->page == (void *)addr) {
85908 - local_dec(&bpage->entries);
85909 + local_dec_unchecked(&bpage->entries);
85910 return;
85911 }
85912 rb_inc_page(cpu_buffer, &bpage);
85913 @@ -3139,7 +3139,7 @@ static inline unsigned long
85914 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
85915 {
85916 return local_read(&cpu_buffer->entries) -
85917 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
85918 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
85919 }
85920
85921 /**
85922 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
85923 return 0;
85924
85925 cpu_buffer = buffer->buffers[cpu];
85926 - ret = local_read(&cpu_buffer->overrun);
85927 + ret = local_read_unchecked(&cpu_buffer->overrun);
85928
85929 return ret;
85930 }
85931 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
85932 return 0;
85933
85934 cpu_buffer = buffer->buffers[cpu];
85935 - ret = local_read(&cpu_buffer->commit_overrun);
85936 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
85937
85938 return ret;
85939 }
85940 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
85941 /* if you care about this being correct, lock the buffer */
85942 for_each_buffer_cpu(buffer, cpu) {
85943 cpu_buffer = buffer->buffers[cpu];
85944 - overruns += local_read(&cpu_buffer->overrun);
85945 + overruns += local_read_unchecked(&cpu_buffer->overrun);
85946 }
85947
85948 return overruns;
85949 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85950 /*
85951 * Reset the reader page to size zero.
85952 */
85953 - local_set(&cpu_buffer->reader_page->write, 0);
85954 - local_set(&cpu_buffer->reader_page->entries, 0);
85955 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85956 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85957 local_set(&cpu_buffer->reader_page->page->commit, 0);
85958 cpu_buffer->reader_page->real_end = 0;
85959
85960 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85961 * want to compare with the last_overrun.
85962 */
85963 smp_mb();
85964 - overwrite = local_read(&(cpu_buffer->overrun));
85965 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
85966
85967 /*
85968 * Here's the tricky part.
85969 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85970
85971 cpu_buffer->head_page
85972 = list_entry(cpu_buffer->pages, struct buffer_page, list);
85973 - local_set(&cpu_buffer->head_page->write, 0);
85974 - local_set(&cpu_buffer->head_page->entries, 0);
85975 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
85976 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
85977 local_set(&cpu_buffer->head_page->page->commit, 0);
85978
85979 cpu_buffer->head_page->read = 0;
85980 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85981
85982 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
85983 INIT_LIST_HEAD(&cpu_buffer->new_pages);
85984 - local_set(&cpu_buffer->reader_page->write, 0);
85985 - local_set(&cpu_buffer->reader_page->entries, 0);
85986 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85987 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85988 local_set(&cpu_buffer->reader_page->page->commit, 0);
85989 cpu_buffer->reader_page->read = 0;
85990
85991 local_set(&cpu_buffer->entries_bytes, 0);
85992 - local_set(&cpu_buffer->overrun, 0);
85993 - local_set(&cpu_buffer->commit_overrun, 0);
85994 + local_set_unchecked(&cpu_buffer->overrun, 0);
85995 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
85996 local_set(&cpu_buffer->dropped_events, 0);
85997 local_set(&cpu_buffer->entries, 0);
85998 local_set(&cpu_buffer->committing, 0);
85999 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
86000 rb_init_page(bpage);
86001 bpage = reader->page;
86002 reader->page = *data_page;
86003 - local_set(&reader->write, 0);
86004 - local_set(&reader->entries, 0);
86005 + local_set_unchecked(&reader->write, 0);
86006 + local_set_unchecked(&reader->entries, 0);
86007 reader->read = 0;
86008 *data_page = bpage;
86009
86010 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
86011 index b778e96..4e84621 100644
86012 --- a/kernel/trace/trace.c
86013 +++ b/kernel/trace/trace.c
86014 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
86015 return 0;
86016 }
86017
86018 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
86019 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
86020 {
86021 /* do nothing if flag is already set */
86022 if (!!(trace_flags & mask) == !!enabled)
86023 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
86024 index 10c86fb..645ab0a 100644
86025 --- a/kernel/trace/trace.h
86026 +++ b/kernel/trace/trace.h
86027 @@ -1029,7 +1029,7 @@ extern const char *__stop___tracepoint_str[];
86028 void trace_printk_init_buffers(void);
86029 void trace_printk_start_comm(void);
86030 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
86031 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
86032 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
86033
86034 /*
86035 * Normal trace_printk() and friends allocates special buffers
86036 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
86037 index 26dc348..8708ca7 100644
86038 --- a/kernel/trace/trace_clock.c
86039 +++ b/kernel/trace/trace_clock.c
86040 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
86041 return now;
86042 }
86043
86044 -static atomic64_t trace_counter;
86045 +static atomic64_unchecked_t trace_counter;
86046
86047 /*
86048 * trace_clock_counter(): simply an atomic counter.
86049 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
86050 */
86051 u64 notrace trace_clock_counter(void)
86052 {
86053 - return atomic64_add_return(1, &trace_counter);
86054 + return atomic64_inc_return_unchecked(&trace_counter);
86055 }
86056 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
86057 index 368a4d5..7b6d1d5 100644
86058 --- a/kernel/trace/trace_events.c
86059 +++ b/kernel/trace/trace_events.c
86060 @@ -1673,7 +1673,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
86061 return 0;
86062 }
86063
86064 -struct ftrace_module_file_ops;
86065 static void __add_event_to_tracers(struct ftrace_event_call *call);
86066
86067 /* Add an additional event_call dynamically */
86068 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
86069 index b3dcfb2..ebee344 100644
86070 --- a/kernel/trace/trace_mmiotrace.c
86071 +++ b/kernel/trace/trace_mmiotrace.c
86072 @@ -24,7 +24,7 @@ struct header_iter {
86073 static struct trace_array *mmio_trace_array;
86074 static bool overrun_detected;
86075 static unsigned long prev_overruns;
86076 -static atomic_t dropped_count;
86077 +static atomic_unchecked_t dropped_count;
86078
86079 static void mmio_reset_data(struct trace_array *tr)
86080 {
86081 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
86082
86083 static unsigned long count_overruns(struct trace_iterator *iter)
86084 {
86085 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
86086 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
86087 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
86088
86089 if (over > prev_overruns)
86090 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
86091 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
86092 sizeof(*entry), 0, pc);
86093 if (!event) {
86094 - atomic_inc(&dropped_count);
86095 + atomic_inc_unchecked(&dropped_count);
86096 return;
86097 }
86098 entry = ring_buffer_event_data(event);
86099 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
86100 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
86101 sizeof(*entry), 0, pc);
86102 if (!event) {
86103 - atomic_inc(&dropped_count);
86104 + atomic_inc_unchecked(&dropped_count);
86105 return;
86106 }
86107 entry = ring_buffer_event_data(event);
86108 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
86109 index 34e7cba..6f9a729 100644
86110 --- a/kernel/trace/trace_output.c
86111 +++ b/kernel/trace/trace_output.c
86112 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
86113
86114 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
86115 if (!IS_ERR(p)) {
86116 - p = mangle_path(s->buffer + s->len, p, "\n");
86117 + p = mangle_path(s->buffer + s->len, p, "\n\\");
86118 if (p) {
86119 s->len = p - s->buffer;
86120 return 1;
86121 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
86122 goto out;
86123 }
86124
86125 + pax_open_kernel();
86126 if (event->funcs->trace == NULL)
86127 - event->funcs->trace = trace_nop_print;
86128 + *(void **)&event->funcs->trace = trace_nop_print;
86129 if (event->funcs->raw == NULL)
86130 - event->funcs->raw = trace_nop_print;
86131 + *(void **)&event->funcs->raw = trace_nop_print;
86132 if (event->funcs->hex == NULL)
86133 - event->funcs->hex = trace_nop_print;
86134 + *(void **)&event->funcs->hex = trace_nop_print;
86135 if (event->funcs->binary == NULL)
86136 - event->funcs->binary = trace_nop_print;
86137 + *(void **)&event->funcs->binary = trace_nop_print;
86138 + pax_close_kernel();
86139
86140 key = event->type & (EVENT_HASHSIZE - 1);
86141
86142 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
86143 index b20428c..4845a10 100644
86144 --- a/kernel/trace/trace_stack.c
86145 +++ b/kernel/trace/trace_stack.c
86146 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
86147 return;
86148
86149 /* we do not handle interrupt stacks yet */
86150 - if (!object_is_on_stack(stack))
86151 + if (!object_starts_on_stack(stack))
86152 return;
86153
86154 local_irq_save(flags);
86155 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
86156 index 13fb113..a6ced3f 100644
86157 --- a/kernel/user_namespace.c
86158 +++ b/kernel/user_namespace.c
86159 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
86160 !kgid_has_mapping(parent_ns, group))
86161 return -EPERM;
86162
86163 +#ifdef CONFIG_GRKERNSEC
86164 + /*
86165 + * This doesn't really inspire confidence:
86166 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
86167 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
86168 + * Increases kernel attack surface in areas developers
86169 + * previously cared little about ("low importance due
86170 + * to requiring "root" capability")
86171 + * To be removed when this code receives *proper* review
86172 + */
86173 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
86174 + !capable(CAP_SETGID))
86175 + return -EPERM;
86176 +#endif
86177 +
86178 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
86179 if (!ns)
86180 return -ENOMEM;
86181 @@ -860,7 +875,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
86182 if (atomic_read(&current->mm->mm_users) > 1)
86183 return -EINVAL;
86184
86185 - if (current->fs->users != 1)
86186 + if (atomic_read(&current->fs->users) != 1)
86187 return -EINVAL;
86188
86189 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
86190 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
86191 index 4f69f9a..7c6f8f8 100644
86192 --- a/kernel/utsname_sysctl.c
86193 +++ b/kernel/utsname_sysctl.c
86194 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
86195 static int proc_do_uts_string(ctl_table *table, int write,
86196 void __user *buffer, size_t *lenp, loff_t *ppos)
86197 {
86198 - struct ctl_table uts_table;
86199 + ctl_table_no_const uts_table;
86200 int r;
86201 memcpy(&uts_table, table, sizeof(uts_table));
86202 uts_table.data = get_uts(table, write);
86203 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
86204 index 4431610..4265616 100644
86205 --- a/kernel/watchdog.c
86206 +++ b/kernel/watchdog.c
86207 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
86208 static void watchdog_nmi_disable(unsigned int cpu) { return; }
86209 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
86210
86211 -static struct smp_hotplug_thread watchdog_threads = {
86212 +static struct smp_hotplug_thread watchdog_threads __read_only = {
86213 .store = &softlockup_watchdog,
86214 .thread_should_run = watchdog_should_run,
86215 .thread_fn = watchdog,
86216 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
86217 index 987293d..60b3043 100644
86218 --- a/kernel/workqueue.c
86219 +++ b/kernel/workqueue.c
86220 @@ -4658,7 +4658,7 @@ static void rebind_workers(struct worker_pool *pool)
86221 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
86222 worker_flags |= WORKER_REBOUND;
86223 worker_flags &= ~WORKER_UNBOUND;
86224 - ACCESS_ONCE(worker->flags) = worker_flags;
86225 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
86226 }
86227
86228 spin_unlock_irq(&pool->lock);
86229 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
86230 index 094f315..244a824 100644
86231 --- a/lib/Kconfig.debug
86232 +++ b/lib/Kconfig.debug
86233 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
86234
86235 config DEBUG_WW_MUTEX_SLOWPATH
86236 bool "Wait/wound mutex debugging: Slowpath testing"
86237 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86238 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86239 select DEBUG_LOCK_ALLOC
86240 select DEBUG_SPINLOCK
86241 select DEBUG_MUTEXES
86242 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
86243
86244 config DEBUG_LOCK_ALLOC
86245 bool "Lock debugging: detect incorrect freeing of live locks"
86246 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86247 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86248 select DEBUG_SPINLOCK
86249 select DEBUG_MUTEXES
86250 select LOCKDEP
86251 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
86252
86253 config PROVE_LOCKING
86254 bool "Lock debugging: prove locking correctness"
86255 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86256 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86257 select LOCKDEP
86258 select DEBUG_SPINLOCK
86259 select DEBUG_MUTEXES
86260 @@ -914,7 +914,7 @@ config LOCKDEP
86261
86262 config LOCK_STAT
86263 bool "Lock usage statistics"
86264 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86265 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86266 select LOCKDEP
86267 select DEBUG_SPINLOCK
86268 select DEBUG_MUTEXES
86269 @@ -1376,6 +1376,7 @@ config LATENCYTOP
86270 depends on DEBUG_KERNEL
86271 depends on STACKTRACE_SUPPORT
86272 depends on PROC_FS
86273 + depends on !GRKERNSEC_HIDESYM
86274 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
86275 select KALLSYMS
86276 select KALLSYMS_ALL
86277 @@ -1392,7 +1393,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86278 config DEBUG_STRICT_USER_COPY_CHECKS
86279 bool "Strict user copy size checks"
86280 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86281 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
86282 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
86283 help
86284 Enabling this option turns a certain set of sanity checks for user
86285 copy operations into compile time failures.
86286 @@ -1502,7 +1503,7 @@ endmenu # runtime tests
86287
86288 config PROVIDE_OHCI1394_DMA_INIT
86289 bool "Remote debugging over FireWire early on boot"
86290 - depends on PCI && X86
86291 + depends on PCI && X86 && !GRKERNSEC
86292 help
86293 If you want to debug problems which hang or crash the kernel early
86294 on boot and the crashing machine has a FireWire port, you can use
86295 @@ -1531,7 +1532,7 @@ config PROVIDE_OHCI1394_DMA_INIT
86296
86297 config FIREWIRE_OHCI_REMOTE_DMA
86298 bool "Remote debugging over FireWire with firewire-ohci"
86299 - depends on FIREWIRE_OHCI
86300 + depends on FIREWIRE_OHCI && !GRKERNSEC
86301 help
86302 This option lets you use the FireWire bus for remote debugging
86303 with help of the firewire-ohci driver. It enables unfiltered
86304 diff --git a/lib/Makefile b/lib/Makefile
86305 index f3bb2cb..b358ace 100644
86306 --- a/lib/Makefile
86307 +++ b/lib/Makefile
86308 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
86309
86310 obj-$(CONFIG_BTREE) += btree.o
86311 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
86312 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
86313 +obj-y += list_debug.o
86314 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
86315
86316 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
86317 diff --git a/lib/bitmap.c b/lib/bitmap.c
86318 index 06f7e4f..f3cf2b0 100644
86319 --- a/lib/bitmap.c
86320 +++ b/lib/bitmap.c
86321 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
86322 {
86323 int c, old_c, totaldigits, ndigits, nchunks, nbits;
86324 u32 chunk;
86325 - const char __user __force *ubuf = (const char __user __force *)buf;
86326 + const char __user *ubuf = (const char __force_user *)buf;
86327
86328 bitmap_zero(maskp, nmaskbits);
86329
86330 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
86331 {
86332 if (!access_ok(VERIFY_READ, ubuf, ulen))
86333 return -EFAULT;
86334 - return __bitmap_parse((const char __force *)ubuf,
86335 + return __bitmap_parse((const char __force_kernel *)ubuf,
86336 ulen, 1, maskp, nmaskbits);
86337
86338 }
86339 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
86340 {
86341 unsigned a, b;
86342 int c, old_c, totaldigits;
86343 - const char __user __force *ubuf = (const char __user __force *)buf;
86344 + const char __user *ubuf = (const char __force_user *)buf;
86345 int exp_digit, in_range;
86346
86347 totaldigits = c = 0;
86348 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
86349 {
86350 if (!access_ok(VERIFY_READ, ubuf, ulen))
86351 return -EFAULT;
86352 - return __bitmap_parselist((const char __force *)ubuf,
86353 + return __bitmap_parselist((const char __force_kernel *)ubuf,
86354 ulen, 1, maskp, nmaskbits);
86355 }
86356 EXPORT_SYMBOL(bitmap_parselist_user);
86357 diff --git a/lib/bug.c b/lib/bug.c
86358 index 1686034..a9c00c8 100644
86359 --- a/lib/bug.c
86360 +++ b/lib/bug.c
86361 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
86362 return BUG_TRAP_TYPE_NONE;
86363
86364 bug = find_bug(bugaddr);
86365 + if (!bug)
86366 + return BUG_TRAP_TYPE_NONE;
86367
86368 file = NULL;
86369 line = 0;
86370 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
86371 index bf2c8b1..1d00ccf 100644
86372 --- a/lib/debugobjects.c
86373 +++ b/lib/debugobjects.c
86374 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
86375 if (limit > 4)
86376 return;
86377
86378 - is_on_stack = object_is_on_stack(addr);
86379 + is_on_stack = object_starts_on_stack(addr);
86380 if (is_on_stack == onstack)
86381 return;
86382
86383 diff --git a/lib/devres.c b/lib/devres.c
86384 index 8235331..5881053 100644
86385 --- a/lib/devres.c
86386 +++ b/lib/devres.c
86387 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
86388 void devm_iounmap(struct device *dev, void __iomem *addr)
86389 {
86390 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
86391 - (void *)addr));
86392 + (void __force *)addr));
86393 iounmap(addr);
86394 }
86395 EXPORT_SYMBOL(devm_iounmap);
86396 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
86397 {
86398 ioport_unmap(addr);
86399 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
86400 - devm_ioport_map_match, (void *)addr));
86401 + devm_ioport_map_match, (void __force *)addr));
86402 }
86403 EXPORT_SYMBOL(devm_ioport_unmap);
86404 #endif /* CONFIG_HAS_IOPORT */
86405 diff --git a/lib/div64.c b/lib/div64.c
86406 index 4382ad7..08aa558 100644
86407 --- a/lib/div64.c
86408 +++ b/lib/div64.c
86409 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
86410 EXPORT_SYMBOL(__div64_32);
86411
86412 #ifndef div_s64_rem
86413 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86414 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86415 {
86416 u64 quotient;
86417
86418 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
86419 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
86420 */
86421 #ifndef div64_u64
86422 -u64 div64_u64(u64 dividend, u64 divisor)
86423 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
86424 {
86425 u32 high = divisor >> 32;
86426 u64 quot;
86427 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
86428 index d87a17a..ac0d79a 100644
86429 --- a/lib/dma-debug.c
86430 +++ b/lib/dma-debug.c
86431 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
86432
86433 void dma_debug_add_bus(struct bus_type *bus)
86434 {
86435 - struct notifier_block *nb;
86436 + notifier_block_no_const *nb;
86437
86438 if (global_disable)
86439 return;
86440 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
86441
86442 static void check_for_stack(struct device *dev, void *addr)
86443 {
86444 - if (object_is_on_stack(addr))
86445 + if (object_starts_on_stack(addr))
86446 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
86447 "stack [addr=%p]\n", addr);
86448 }
86449 diff --git a/lib/inflate.c b/lib/inflate.c
86450 index 013a761..c28f3fc 100644
86451 --- a/lib/inflate.c
86452 +++ b/lib/inflate.c
86453 @@ -269,7 +269,7 @@ static void free(void *where)
86454 malloc_ptr = free_mem_ptr;
86455 }
86456 #else
86457 -#define malloc(a) kmalloc(a, GFP_KERNEL)
86458 +#define malloc(a) kmalloc((a), GFP_KERNEL)
86459 #define free(a) kfree(a)
86460 #endif
86461
86462 diff --git a/lib/ioremap.c b/lib/ioremap.c
86463 index 0c9216c..863bd89 100644
86464 --- a/lib/ioremap.c
86465 +++ b/lib/ioremap.c
86466 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
86467 unsigned long next;
86468
86469 phys_addr -= addr;
86470 - pmd = pmd_alloc(&init_mm, pud, addr);
86471 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
86472 if (!pmd)
86473 return -ENOMEM;
86474 do {
86475 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
86476 unsigned long next;
86477
86478 phys_addr -= addr;
86479 - pud = pud_alloc(&init_mm, pgd, addr);
86480 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
86481 if (!pud)
86482 return -ENOMEM;
86483 do {
86484 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
86485 index bd2bea9..6b3c95e 100644
86486 --- a/lib/is_single_threaded.c
86487 +++ b/lib/is_single_threaded.c
86488 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
86489 struct task_struct *p, *t;
86490 bool ret;
86491
86492 + if (!mm)
86493 + return true;
86494 +
86495 if (atomic_read(&task->signal->live) != 1)
86496 return false;
86497
86498 diff --git a/lib/kobject.c b/lib/kobject.c
86499 index 084f7b1..d265b8a 100644
86500 --- a/lib/kobject.c
86501 +++ b/lib/kobject.c
86502 @@ -875,9 +875,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
86503
86504
86505 static DEFINE_SPINLOCK(kobj_ns_type_lock);
86506 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
86507 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
86508
86509 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86510 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86511 {
86512 enum kobj_ns_type type = ops->type;
86513 int error;
86514 diff --git a/lib/list_debug.c b/lib/list_debug.c
86515 index c24c2f7..f0296f4 100644
86516 --- a/lib/list_debug.c
86517 +++ b/lib/list_debug.c
86518 @@ -11,7 +11,9 @@
86519 #include <linux/bug.h>
86520 #include <linux/kernel.h>
86521 #include <linux/rculist.h>
86522 +#include <linux/mm.h>
86523
86524 +#ifdef CONFIG_DEBUG_LIST
86525 /*
86526 * Insert a new entry between two known consecutive entries.
86527 *
86528 @@ -19,21 +21,40 @@
86529 * the prev/next entries already!
86530 */
86531
86532 +static bool __list_add_debug(struct list_head *new,
86533 + struct list_head *prev,
86534 + struct list_head *next)
86535 +{
86536 + if (unlikely(next->prev != prev)) {
86537 + printk(KERN_ERR "list_add corruption. next->prev should be "
86538 + "prev (%p), but was %p. (next=%p).\n",
86539 + prev, next->prev, next);
86540 + BUG();
86541 + return false;
86542 + }
86543 + if (unlikely(prev->next != next)) {
86544 + printk(KERN_ERR "list_add corruption. prev->next should be "
86545 + "next (%p), but was %p. (prev=%p).\n",
86546 + next, prev->next, prev);
86547 + BUG();
86548 + return false;
86549 + }
86550 + if (unlikely(new == prev || new == next)) {
86551 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
86552 + new, prev, next);
86553 + BUG();
86554 + return false;
86555 + }
86556 + return true;
86557 +}
86558 +
86559 void __list_add(struct list_head *new,
86560 - struct list_head *prev,
86561 - struct list_head *next)
86562 + struct list_head *prev,
86563 + struct list_head *next)
86564 {
86565 - WARN(next->prev != prev,
86566 - "list_add corruption. next->prev should be "
86567 - "prev (%p), but was %p. (next=%p).\n",
86568 - prev, next->prev, next);
86569 - WARN(prev->next != next,
86570 - "list_add corruption. prev->next should be "
86571 - "next (%p), but was %p. (prev=%p).\n",
86572 - next, prev->next, prev);
86573 - WARN(new == prev || new == next,
86574 - "list_add double add: new=%p, prev=%p, next=%p.\n",
86575 - new, prev, next);
86576 + if (!__list_add_debug(new, prev, next))
86577 + return;
86578 +
86579 next->prev = new;
86580 new->next = next;
86581 new->prev = prev;
86582 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
86583 }
86584 EXPORT_SYMBOL(__list_add);
86585
86586 -void __list_del_entry(struct list_head *entry)
86587 +static bool __list_del_entry_debug(struct list_head *entry)
86588 {
86589 struct list_head *prev, *next;
86590
86591 prev = entry->prev;
86592 next = entry->next;
86593
86594 - if (WARN(next == LIST_POISON1,
86595 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
86596 - entry, LIST_POISON1) ||
86597 - WARN(prev == LIST_POISON2,
86598 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
86599 - entry, LIST_POISON2) ||
86600 - WARN(prev->next != entry,
86601 - "list_del corruption. prev->next should be %p, "
86602 - "but was %p\n", entry, prev->next) ||
86603 - WARN(next->prev != entry,
86604 - "list_del corruption. next->prev should be %p, "
86605 - "but was %p\n", entry, next->prev))
86606 + if (unlikely(next == LIST_POISON1)) {
86607 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
86608 + entry, LIST_POISON1);
86609 + BUG();
86610 + return false;
86611 + }
86612 + if (unlikely(prev == LIST_POISON2)) {
86613 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
86614 + entry, LIST_POISON2);
86615 + BUG();
86616 + return false;
86617 + }
86618 + if (unlikely(entry->prev->next != entry)) {
86619 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
86620 + "but was %p\n", entry, prev->next);
86621 + BUG();
86622 + return false;
86623 + }
86624 + if (unlikely(entry->next->prev != entry)) {
86625 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
86626 + "but was %p\n", entry, next->prev);
86627 + BUG();
86628 + return false;
86629 + }
86630 + return true;
86631 +}
86632 +
86633 +void __list_del_entry(struct list_head *entry)
86634 +{
86635 + if (!__list_del_entry_debug(entry))
86636 return;
86637
86638 - __list_del(prev, next);
86639 + __list_del(entry->prev, entry->next);
86640 }
86641 EXPORT_SYMBOL(__list_del_entry);
86642
86643 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
86644 void __list_add_rcu(struct list_head *new,
86645 struct list_head *prev, struct list_head *next)
86646 {
86647 - WARN(next->prev != prev,
86648 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
86649 - prev, next->prev, next);
86650 - WARN(prev->next != next,
86651 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
86652 - next, prev->next, prev);
86653 + if (!__list_add_debug(new, prev, next))
86654 + return;
86655 +
86656 new->next = next;
86657 new->prev = prev;
86658 rcu_assign_pointer(list_next_rcu(prev), new);
86659 next->prev = new;
86660 }
86661 EXPORT_SYMBOL(__list_add_rcu);
86662 +#endif
86663 +
86664 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
86665 +{
86666 +#ifdef CONFIG_DEBUG_LIST
86667 + if (!__list_add_debug(new, prev, next))
86668 + return;
86669 +#endif
86670 +
86671 + pax_open_kernel();
86672 + next->prev = new;
86673 + new->next = next;
86674 + new->prev = prev;
86675 + prev->next = new;
86676 + pax_close_kernel();
86677 +}
86678 +EXPORT_SYMBOL(__pax_list_add);
86679 +
86680 +void pax_list_del(struct list_head *entry)
86681 +{
86682 +#ifdef CONFIG_DEBUG_LIST
86683 + if (!__list_del_entry_debug(entry))
86684 + return;
86685 +#endif
86686 +
86687 + pax_open_kernel();
86688 + __list_del(entry->prev, entry->next);
86689 + entry->next = LIST_POISON1;
86690 + entry->prev = LIST_POISON2;
86691 + pax_close_kernel();
86692 +}
86693 +EXPORT_SYMBOL(pax_list_del);
86694 +
86695 +void pax_list_del_init(struct list_head *entry)
86696 +{
86697 + pax_open_kernel();
86698 + __list_del(entry->prev, entry->next);
86699 + INIT_LIST_HEAD(entry);
86700 + pax_close_kernel();
86701 +}
86702 +EXPORT_SYMBOL(pax_list_del_init);
86703 +
86704 +void __pax_list_add_rcu(struct list_head *new,
86705 + struct list_head *prev, struct list_head *next)
86706 +{
86707 +#ifdef CONFIG_DEBUG_LIST
86708 + if (!__list_add_debug(new, prev, next))
86709 + return;
86710 +#endif
86711 +
86712 + pax_open_kernel();
86713 + new->next = next;
86714 + new->prev = prev;
86715 + rcu_assign_pointer(list_next_rcu(prev), new);
86716 + next->prev = new;
86717 + pax_close_kernel();
86718 +}
86719 +EXPORT_SYMBOL(__pax_list_add_rcu);
86720 +
86721 +void pax_list_del_rcu(struct list_head *entry)
86722 +{
86723 +#ifdef CONFIG_DEBUG_LIST
86724 + if (!__list_del_entry_debug(entry))
86725 + return;
86726 +#endif
86727 +
86728 + pax_open_kernel();
86729 + __list_del(entry->prev, entry->next);
86730 + entry->next = LIST_POISON1;
86731 + entry->prev = LIST_POISON2;
86732 + pax_close_kernel();
86733 +}
86734 +EXPORT_SYMBOL(pax_list_del_rcu);
86735 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
86736 index 1a53d49..ace934c 100644
86737 --- a/lib/percpu-refcount.c
86738 +++ b/lib/percpu-refcount.c
86739 @@ -29,7 +29,7 @@
86740 * can't hit 0 before we've added up all the percpu refs.
86741 */
86742
86743 -#define PCPU_COUNT_BIAS (1U << 31)
86744 +#define PCPU_COUNT_BIAS (1U << 30)
86745
86746 /**
86747 * percpu_ref_init - initialize a percpu refcount
86748 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
86749 index 7811ed3..f80ca19 100644
86750 --- a/lib/radix-tree.c
86751 +++ b/lib/radix-tree.c
86752 @@ -93,7 +93,7 @@ struct radix_tree_preload {
86753 int nr;
86754 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
86755 };
86756 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
86757 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
86758
86759 static inline void *ptr_to_indirect(void *ptr)
86760 {
86761 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
86762 index bb2b201..46abaf9 100644
86763 --- a/lib/strncpy_from_user.c
86764 +++ b/lib/strncpy_from_user.c
86765 @@ -21,7 +21,7 @@
86766 */
86767 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
86768 {
86769 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86770 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86771 long res = 0;
86772
86773 /*
86774 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
86775 index a28df52..3d55877 100644
86776 --- a/lib/strnlen_user.c
86777 +++ b/lib/strnlen_user.c
86778 @@ -26,7 +26,7 @@
86779 */
86780 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
86781 {
86782 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86783 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86784 long align, res = 0;
86785 unsigned long c;
86786
86787 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
86788 index 4e8686c..3e8c92f 100644
86789 --- a/lib/swiotlb.c
86790 +++ b/lib/swiotlb.c
86791 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
86792
86793 void
86794 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
86795 - dma_addr_t dev_addr)
86796 + dma_addr_t dev_addr, struct dma_attrs *attrs)
86797 {
86798 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
86799
86800 diff --git a/lib/usercopy.c b/lib/usercopy.c
86801 index 4f5b1dd..7cab418 100644
86802 --- a/lib/usercopy.c
86803 +++ b/lib/usercopy.c
86804 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
86805 WARN(1, "Buffer overflow detected!\n");
86806 }
86807 EXPORT_SYMBOL(copy_from_user_overflow);
86808 +
86809 +void copy_to_user_overflow(void)
86810 +{
86811 + WARN(1, "Buffer overflow detected!\n");
86812 +}
86813 +EXPORT_SYMBOL(copy_to_user_overflow);
86814 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
86815 index 26559bd..ed614df 100644
86816 --- a/lib/vsprintf.c
86817 +++ b/lib/vsprintf.c
86818 @@ -16,6 +16,9 @@
86819 * - scnprintf and vscnprintf
86820 */
86821
86822 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86823 +#define __INCLUDED_BY_HIDESYM 1
86824 +#endif
86825 #include <stdarg.h>
86826 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
86827 #include <linux/types.h>
86828 @@ -1154,7 +1157,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
86829 return number(buf, end, *(const netdev_features_t *)addr, spec);
86830 }
86831
86832 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86833 +int kptr_restrict __read_mostly = 2;
86834 +#else
86835 int kptr_restrict __read_mostly;
86836 +#endif
86837
86838 /*
86839 * Show a '%p' thing. A kernel extension is that the '%p' is followed
86840 @@ -1167,6 +1174,7 @@ int kptr_restrict __read_mostly;
86841 * - 'f' For simple symbolic function names without offset
86842 * - 'S' For symbolic direct pointers with offset
86843 * - 's' For symbolic direct pointers without offset
86844 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
86845 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
86846 * - 'B' For backtraced symbolic direct pointers with offset
86847 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
86848 @@ -1231,12 +1239,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86849
86850 if (!ptr && *fmt != 'K') {
86851 /*
86852 - * Print (null) with the same width as a pointer so it makes
86853 + * Print (nil) with the same width as a pointer so it makes
86854 * tabular output look nice.
86855 */
86856 if (spec.field_width == -1)
86857 spec.field_width = default_width;
86858 - return string(buf, end, "(null)", spec);
86859 + return string(buf, end, "(nil)", spec);
86860 }
86861
86862 switch (*fmt) {
86863 @@ -1246,6 +1254,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86864 /* Fallthrough */
86865 case 'S':
86866 case 's':
86867 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86868 + break;
86869 +#else
86870 + return symbol_string(buf, end, ptr, spec, fmt);
86871 +#endif
86872 + case 'A':
86873 case 'B':
86874 return symbol_string(buf, end, ptr, spec, fmt);
86875 case 'R':
86876 @@ -1301,6 +1315,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86877 va_end(va);
86878 return buf;
86879 }
86880 + case 'P':
86881 + break;
86882 case 'K':
86883 /*
86884 * %pK cannot be used in IRQ context because its test
86885 @@ -1336,6 +1352,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
86886 ((const struct file *)ptr)->f_path.dentry,
86887 spec, fmt);
86888 }
86889 +
86890 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86891 + /* 'P' = approved pointers to copy to userland,
86892 + as in the /proc/kallsyms case, as we make it display nothing
86893 + for non-root users, and the real contents for root users
86894 + Also ignore 'K' pointers, since we force their NULLing for non-root users
86895 + above
86896 + */
86897 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
86898 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
86899 + dump_stack();
86900 + ptr = NULL;
86901 + }
86902 +#endif
86903 +
86904 spec.flags |= SMALL;
86905 if (spec.field_width == -1) {
86906 spec.field_width = default_width;
86907 @@ -2059,11 +2090,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
86908 typeof(type) value; \
86909 if (sizeof(type) == 8) { \
86910 args = PTR_ALIGN(args, sizeof(u32)); \
86911 - *(u32 *)&value = *(u32 *)args; \
86912 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
86913 + *(u32 *)&value = *(const u32 *)args; \
86914 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
86915 } else { \
86916 args = PTR_ALIGN(args, sizeof(type)); \
86917 - value = *(typeof(type) *)args; \
86918 + value = *(const typeof(type) *)args; \
86919 } \
86920 args += sizeof(type); \
86921 value; \
86922 @@ -2126,7 +2157,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
86923 case FORMAT_TYPE_STR: {
86924 const char *str_arg = args;
86925 args += strlen(str_arg) + 1;
86926 - str = string(str, end, (char *)str_arg, spec);
86927 + str = string(str, end, str_arg, spec);
86928 break;
86929 }
86930
86931 diff --git a/localversion-grsec b/localversion-grsec
86932 new file mode 100644
86933 index 0000000..7cd6065
86934 --- /dev/null
86935 +++ b/localversion-grsec
86936 @@ -0,0 +1 @@
86937 +-grsec
86938 diff --git a/mm/Kconfig b/mm/Kconfig
86939 index 394838f..0e5f816 100644
86940 --- a/mm/Kconfig
86941 +++ b/mm/Kconfig
86942 @@ -317,10 +317,11 @@ config KSM
86943 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
86944
86945 config DEFAULT_MMAP_MIN_ADDR
86946 - int "Low address space to protect from user allocation"
86947 + int "Low address space to protect from user allocation"
86948 depends on MMU
86949 - default 4096
86950 - help
86951 + default 32768 if ALPHA || ARM || PARISC || SPARC32
86952 + default 65536
86953 + help
86954 This is the portion of low virtual memory which should be protected
86955 from userspace allocation. Keeping a user from writing to low pages
86956 can help reduce the impact of kernel NULL pointer bugs.
86957 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
86958
86959 config HWPOISON_INJECT
86960 tristate "HWPoison pages injector"
86961 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
86962 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
86963 select PROC_PAGE_MONITOR
86964
86965 config NOMMU_INITIAL_TRIM_EXCESS
86966 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
86967 index ce682f7..1fb54f9 100644
86968 --- a/mm/backing-dev.c
86969 +++ b/mm/backing-dev.c
86970 @@ -12,7 +12,7 @@
86971 #include <linux/device.h>
86972 #include <trace/events/writeback.h>
86973
86974 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
86975 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
86976
86977 struct backing_dev_info default_backing_dev_info = {
86978 .name = "default",
86979 @@ -525,7 +525,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
86980 return err;
86981
86982 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
86983 - atomic_long_inc_return(&bdi_seq));
86984 + atomic_long_inc_return_unchecked(&bdi_seq));
86985 if (err) {
86986 bdi_destroy(bdi);
86987 return err;
86988 diff --git a/mm/filemap.c b/mm/filemap.c
86989 index ae4846f..b0acebe 100644
86990 --- a/mm/filemap.c
86991 +++ b/mm/filemap.c
86992 @@ -1768,7 +1768,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
86993 struct address_space *mapping = file->f_mapping;
86994
86995 if (!mapping->a_ops->readpage)
86996 - return -ENOEXEC;
86997 + return -ENODEV;
86998 file_accessed(file);
86999 vma->vm_ops = &generic_file_vm_ops;
87000 return 0;
87001 @@ -1950,7 +1950,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
87002
87003 while (bytes) {
87004 char __user *buf = iov->iov_base + base;
87005 - int copy = min(bytes, iov->iov_len - base);
87006 + size_t copy = min(bytes, iov->iov_len - base);
87007
87008 base = 0;
87009 left = __copy_from_user_inatomic(vaddr, buf, copy);
87010 @@ -1979,7 +1979,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
87011 BUG_ON(!in_atomic());
87012 kaddr = kmap_atomic(page);
87013 if (likely(i->nr_segs == 1)) {
87014 - int left;
87015 + size_t left;
87016 char __user *buf = i->iov->iov_base + i->iov_offset;
87017 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
87018 copied = bytes - left;
87019 @@ -2007,7 +2007,7 @@ size_t iov_iter_copy_from_user(struct page *page,
87020
87021 kaddr = kmap(page);
87022 if (likely(i->nr_segs == 1)) {
87023 - int left;
87024 + size_t left;
87025 char __user *buf = i->iov->iov_base + i->iov_offset;
87026 left = __copy_from_user(kaddr + offset, buf, bytes);
87027 copied = bytes - left;
87028 @@ -2037,7 +2037,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
87029 * zero-length segments (without overruning the iovec).
87030 */
87031 while (bytes || unlikely(i->count && !iov->iov_len)) {
87032 - int copy;
87033 + size_t copy;
87034
87035 copy = min(bytes, iov->iov_len - base);
87036 BUG_ON(!i->count || i->count < copy);
87037 @@ -2108,6 +2108,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
87038 *pos = i_size_read(inode);
87039
87040 if (limit != RLIM_INFINITY) {
87041 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
87042 if (*pos >= limit) {
87043 send_sig(SIGXFSZ, current, 0);
87044 return -EFBIG;
87045 diff --git a/mm/fremap.c b/mm/fremap.c
87046 index 5bff081..d8189a9 100644
87047 --- a/mm/fremap.c
87048 +++ b/mm/fremap.c
87049 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
87050 retry:
87051 vma = find_vma(mm, start);
87052
87053 +#ifdef CONFIG_PAX_SEGMEXEC
87054 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
87055 + goto out;
87056 +#endif
87057 +
87058 /*
87059 * Make sure the vma is shared, that it supports prefaulting,
87060 * and that the remapped range is valid and fully within
87061 diff --git a/mm/highmem.c b/mm/highmem.c
87062 index b32b70c..e512eb0 100644
87063 --- a/mm/highmem.c
87064 +++ b/mm/highmem.c
87065 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
87066 * So no dangers, even with speculative execution.
87067 */
87068 page = pte_page(pkmap_page_table[i]);
87069 + pax_open_kernel();
87070 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
87071 -
87072 + pax_close_kernel();
87073 set_page_address(page, NULL);
87074 need_flush = 1;
87075 }
87076 @@ -198,9 +199,11 @@ start:
87077 }
87078 }
87079 vaddr = PKMAP_ADDR(last_pkmap_nr);
87080 +
87081 + pax_open_kernel();
87082 set_pte_at(&init_mm, vaddr,
87083 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
87084 -
87085 + pax_close_kernel();
87086 pkmap_count[last_pkmap_nr] = 1;
87087 set_page_address(page, (void *)vaddr);
87088
87089 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
87090 index 0b7656e..d21cefc 100644
87091 --- a/mm/hugetlb.c
87092 +++ b/mm/hugetlb.c
87093 @@ -2094,15 +2094,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
87094 struct hstate *h = &default_hstate;
87095 unsigned long tmp;
87096 int ret;
87097 + ctl_table_no_const hugetlb_table;
87098
87099 tmp = h->max_huge_pages;
87100
87101 if (write && h->order >= MAX_ORDER)
87102 return -EINVAL;
87103
87104 - table->data = &tmp;
87105 - table->maxlen = sizeof(unsigned long);
87106 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87107 + hugetlb_table = *table;
87108 + hugetlb_table.data = &tmp;
87109 + hugetlb_table.maxlen = sizeof(unsigned long);
87110 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87111 if (ret)
87112 goto out;
87113
87114 @@ -2147,15 +2149,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
87115 struct hstate *h = &default_hstate;
87116 unsigned long tmp;
87117 int ret;
87118 + ctl_table_no_const hugetlb_table;
87119
87120 tmp = h->nr_overcommit_huge_pages;
87121
87122 if (write && h->order >= MAX_ORDER)
87123 return -EINVAL;
87124
87125 - table->data = &tmp;
87126 - table->maxlen = sizeof(unsigned long);
87127 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87128 + hugetlb_table = *table;
87129 + hugetlb_table.data = &tmp;
87130 + hugetlb_table.maxlen = sizeof(unsigned long);
87131 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87132 if (ret)
87133 goto out;
87134
87135 @@ -2605,6 +2609,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
87136 return 1;
87137 }
87138
87139 +#ifdef CONFIG_PAX_SEGMEXEC
87140 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
87141 +{
87142 + struct mm_struct *mm = vma->vm_mm;
87143 + struct vm_area_struct *vma_m;
87144 + unsigned long address_m;
87145 + pte_t *ptep_m;
87146 +
87147 + vma_m = pax_find_mirror_vma(vma);
87148 + if (!vma_m)
87149 + return;
87150 +
87151 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87152 + address_m = address + SEGMEXEC_TASK_SIZE;
87153 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
87154 + get_page(page_m);
87155 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
87156 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
87157 +}
87158 +#endif
87159 +
87160 /*
87161 * Hugetlb_cow() should be called with page lock of the original hugepage held.
87162 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
87163 @@ -2721,6 +2746,11 @@ retry_avoidcopy:
87164 make_huge_pte(vma, new_page, 1));
87165 page_remove_rmap(old_page);
87166 hugepage_add_new_anon_rmap(new_page, vma, address);
87167 +
87168 +#ifdef CONFIG_PAX_SEGMEXEC
87169 + pax_mirror_huge_pte(vma, address, new_page);
87170 +#endif
87171 +
87172 /* Make the old page be freed below */
87173 new_page = old_page;
87174 }
87175 @@ -2883,6 +2913,10 @@ retry:
87176 && (vma->vm_flags & VM_SHARED)));
87177 set_huge_pte_at(mm, address, ptep, new_pte);
87178
87179 +#ifdef CONFIG_PAX_SEGMEXEC
87180 + pax_mirror_huge_pte(vma, address, page);
87181 +#endif
87182 +
87183 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
87184 /* Optimization, do the COW without a second fault */
87185 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
87186 @@ -2912,6 +2946,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87187 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
87188 struct hstate *h = hstate_vma(vma);
87189
87190 +#ifdef CONFIG_PAX_SEGMEXEC
87191 + struct vm_area_struct *vma_m;
87192 +#endif
87193 +
87194 address &= huge_page_mask(h);
87195
87196 ptep = huge_pte_offset(mm, address);
87197 @@ -2925,6 +2963,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87198 VM_FAULT_SET_HINDEX(hstate_index(h));
87199 }
87200
87201 +#ifdef CONFIG_PAX_SEGMEXEC
87202 + vma_m = pax_find_mirror_vma(vma);
87203 + if (vma_m) {
87204 + unsigned long address_m;
87205 +
87206 + if (vma->vm_start > vma_m->vm_start) {
87207 + address_m = address;
87208 + address -= SEGMEXEC_TASK_SIZE;
87209 + vma = vma_m;
87210 + h = hstate_vma(vma);
87211 + } else
87212 + address_m = address + SEGMEXEC_TASK_SIZE;
87213 +
87214 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
87215 + return VM_FAULT_OOM;
87216 + address_m &= HPAGE_MASK;
87217 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
87218 + }
87219 +#endif
87220 +
87221 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
87222 if (!ptep)
87223 return VM_FAULT_OOM;
87224 diff --git a/mm/internal.h b/mm/internal.h
87225 index 684f7aa..9eb9edc 100644
87226 --- a/mm/internal.h
87227 +++ b/mm/internal.h
87228 @@ -97,6 +97,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
87229 * in mm/page_alloc.c
87230 */
87231 extern void __free_pages_bootmem(struct page *page, unsigned int order);
87232 +extern void free_compound_page(struct page *page);
87233 extern void prep_compound_page(struct page *page, unsigned long order);
87234 #ifdef CONFIG_MEMORY_FAILURE
87235 extern bool is_free_buddy_page(struct page *page);
87236 @@ -352,7 +353,7 @@ extern u32 hwpoison_filter_enable;
87237
87238 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
87239 unsigned long, unsigned long,
87240 - unsigned long, unsigned long);
87241 + unsigned long, unsigned long) __intentional_overflow(-1);
87242
87243 extern void set_pageblock_order(void);
87244 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
87245 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
87246 index e126b0e..e986018 100644
87247 --- a/mm/kmemleak.c
87248 +++ b/mm/kmemleak.c
87249 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
87250
87251 for (i = 0; i < object->trace_len; i++) {
87252 void *ptr = (void *)object->trace[i];
87253 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
87254 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
87255 }
87256 }
87257
87258 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
87259 return -ENOMEM;
87260 }
87261
87262 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
87263 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
87264 &kmemleak_fops);
87265 if (!dentry)
87266 pr_warning("Failed to create the debugfs kmemleak file\n");
87267 diff --git a/mm/maccess.c b/mm/maccess.c
87268 index d53adf9..03a24bf 100644
87269 --- a/mm/maccess.c
87270 +++ b/mm/maccess.c
87271 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
87272 set_fs(KERNEL_DS);
87273 pagefault_disable();
87274 ret = __copy_from_user_inatomic(dst,
87275 - (__force const void __user *)src, size);
87276 + (const void __force_user *)src, size);
87277 pagefault_enable();
87278 set_fs(old_fs);
87279
87280 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
87281
87282 set_fs(KERNEL_DS);
87283 pagefault_disable();
87284 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
87285 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
87286 pagefault_enable();
87287 set_fs(old_fs);
87288
87289 diff --git a/mm/madvise.c b/mm/madvise.c
87290 index 539eeb9..e24a987 100644
87291 --- a/mm/madvise.c
87292 +++ b/mm/madvise.c
87293 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
87294 pgoff_t pgoff;
87295 unsigned long new_flags = vma->vm_flags;
87296
87297 +#ifdef CONFIG_PAX_SEGMEXEC
87298 + struct vm_area_struct *vma_m;
87299 +#endif
87300 +
87301 switch (behavior) {
87302 case MADV_NORMAL:
87303 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
87304 @@ -126,6 +130,13 @@ success:
87305 /*
87306 * vm_flags is protected by the mmap_sem held in write mode.
87307 */
87308 +
87309 +#ifdef CONFIG_PAX_SEGMEXEC
87310 + vma_m = pax_find_mirror_vma(vma);
87311 + if (vma_m)
87312 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
87313 +#endif
87314 +
87315 vma->vm_flags = new_flags;
87316
87317 out:
87318 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
87319 struct vm_area_struct **prev,
87320 unsigned long start, unsigned long end)
87321 {
87322 +
87323 +#ifdef CONFIG_PAX_SEGMEXEC
87324 + struct vm_area_struct *vma_m;
87325 +#endif
87326 +
87327 *prev = vma;
87328 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
87329 return -EINVAL;
87330 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
87331 zap_page_range(vma, start, end - start, &details);
87332 } else
87333 zap_page_range(vma, start, end - start, NULL);
87334 +
87335 +#ifdef CONFIG_PAX_SEGMEXEC
87336 + vma_m = pax_find_mirror_vma(vma);
87337 + if (vma_m) {
87338 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
87339 + struct zap_details details = {
87340 + .nonlinear_vma = vma_m,
87341 + .last_index = ULONG_MAX,
87342 + };
87343 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
87344 + } else
87345 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
87346 + }
87347 +#endif
87348 +
87349 return 0;
87350 }
87351
87352 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
87353 if (end < start)
87354 return error;
87355
87356 +#ifdef CONFIG_PAX_SEGMEXEC
87357 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
87358 + if (end > SEGMEXEC_TASK_SIZE)
87359 + return error;
87360 + } else
87361 +#endif
87362 +
87363 + if (end > TASK_SIZE)
87364 + return error;
87365 +
87366 error = 0;
87367 if (end == start)
87368 return error;
87369 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
87370 index bf3351b..aea800d 100644
87371 --- a/mm/memory-failure.c
87372 +++ b/mm/memory-failure.c
87373 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
87374
87375 int sysctl_memory_failure_recovery __read_mostly = 1;
87376
87377 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87378 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87379
87380 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
87381
87382 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
87383 pfn, t->comm, t->pid);
87384 si.si_signo = SIGBUS;
87385 si.si_errno = 0;
87386 - si.si_addr = (void *)addr;
87387 + si.si_addr = (void __user *)addr;
87388 #ifdef __ARCH_SI_TRAPNO
87389 si.si_trapno = trapno;
87390 #endif
87391 @@ -762,7 +762,7 @@ static struct page_state {
87392 unsigned long res;
87393 char *msg;
87394 int (*action)(struct page *p, unsigned long pfn);
87395 -} error_states[] = {
87396 +} __do_const error_states[] = {
87397 { reserved, reserved, "reserved kernel", me_kernel },
87398 /*
87399 * free pages are specially detected outside this table:
87400 @@ -1053,7 +1053,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87401 nr_pages = 1 << compound_order(hpage);
87402 else /* normal page or thp */
87403 nr_pages = 1;
87404 - atomic_long_add(nr_pages, &num_poisoned_pages);
87405 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
87406
87407 /*
87408 * We need/can do nothing about count=0 pages.
87409 @@ -1083,7 +1083,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87410 if (!PageHWPoison(hpage)
87411 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
87412 || (p != hpage && TestSetPageHWPoison(hpage))) {
87413 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87414 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87415 return 0;
87416 }
87417 set_page_hwpoison_huge_page(hpage);
87418 @@ -1152,7 +1152,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87419 }
87420 if (hwpoison_filter(p)) {
87421 if (TestClearPageHWPoison(p))
87422 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87423 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87424 unlock_page(hpage);
87425 put_page(hpage);
87426 return 0;
87427 @@ -1370,7 +1370,7 @@ int unpoison_memory(unsigned long pfn)
87428 return 0;
87429 }
87430 if (TestClearPageHWPoison(p))
87431 - atomic_long_dec(&num_poisoned_pages);
87432 + atomic_long_dec_unchecked(&num_poisoned_pages);
87433 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
87434 return 0;
87435 }
87436 @@ -1384,7 +1384,7 @@ int unpoison_memory(unsigned long pfn)
87437 */
87438 if (TestClearPageHWPoison(page)) {
87439 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
87440 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87441 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87442 freeit = 1;
87443 if (PageHuge(page))
87444 clear_page_hwpoison_huge_page(page);
87445 @@ -1521,7 +1521,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
87446 } else {
87447 set_page_hwpoison_huge_page(hpage);
87448 dequeue_hwpoisoned_huge_page(hpage);
87449 - atomic_long_add(1 << compound_order(hpage),
87450 + atomic_long_add_unchecked(1 << compound_order(hpage),
87451 &num_poisoned_pages);
87452 }
87453 return ret;
87454 @@ -1560,7 +1560,7 @@ static int __soft_offline_page(struct page *page, int flags)
87455 put_page(page);
87456 pr_info("soft_offline: %#lx: invalidated\n", pfn);
87457 SetPageHWPoison(page);
87458 - atomic_long_inc(&num_poisoned_pages);
87459 + atomic_long_inc_unchecked(&num_poisoned_pages);
87460 return 0;
87461 }
87462
87463 @@ -1605,7 +1605,7 @@ static int __soft_offline_page(struct page *page, int flags)
87464 if (!is_free_buddy_page(page))
87465 pr_info("soft offline: %#lx: page leaked\n",
87466 pfn);
87467 - atomic_long_inc(&num_poisoned_pages);
87468 + atomic_long_inc_unchecked(&num_poisoned_pages);
87469 }
87470 } else {
87471 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
87472 @@ -1666,11 +1666,11 @@ int soft_offline_page(struct page *page, int flags)
87473 if (PageHuge(page)) {
87474 set_page_hwpoison_huge_page(hpage);
87475 dequeue_hwpoisoned_huge_page(hpage);
87476 - atomic_long_add(1 << compound_order(hpage),
87477 + atomic_long_add_unchecked(1 << compound_order(hpage),
87478 &num_poisoned_pages);
87479 } else {
87480 SetPageHWPoison(page);
87481 - atomic_long_inc(&num_poisoned_pages);
87482 + atomic_long_inc_unchecked(&num_poisoned_pages);
87483 }
87484 }
87485 unset:
87486 diff --git a/mm/memory.c b/mm/memory.c
87487 index d176154..cd1b387 100644
87488 --- a/mm/memory.c
87489 +++ b/mm/memory.c
87490 @@ -402,6 +402,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87491 free_pte_range(tlb, pmd, addr);
87492 } while (pmd++, addr = next, addr != end);
87493
87494 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
87495 start &= PUD_MASK;
87496 if (start < floor)
87497 return;
87498 @@ -416,6 +417,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87499 pmd = pmd_offset(pud, start);
87500 pud_clear(pud);
87501 pmd_free_tlb(tlb, pmd, start);
87502 +#endif
87503 +
87504 }
87505
87506 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87507 @@ -435,6 +438,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87508 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
87509 } while (pud++, addr = next, addr != end);
87510
87511 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
87512 start &= PGDIR_MASK;
87513 if (start < floor)
87514 return;
87515 @@ -449,6 +453,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87516 pud = pud_offset(pgd, start);
87517 pgd_clear(pgd);
87518 pud_free_tlb(tlb, pud, start);
87519 +#endif
87520 +
87521 }
87522
87523 /*
87524 @@ -1636,12 +1642,6 @@ no_page_table:
87525 return page;
87526 }
87527
87528 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
87529 -{
87530 - return stack_guard_page_start(vma, addr) ||
87531 - stack_guard_page_end(vma, addr+PAGE_SIZE);
87532 -}
87533 -
87534 /**
87535 * __get_user_pages() - pin user pages in memory
87536 * @tsk: task_struct of target task
87537 @@ -1728,10 +1728,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87538
87539 i = 0;
87540
87541 - do {
87542 + while (nr_pages) {
87543 struct vm_area_struct *vma;
87544
87545 - vma = find_extend_vma(mm, start);
87546 + vma = find_vma(mm, start);
87547 if (!vma && in_gate_area(mm, start)) {
87548 unsigned long pg = start & PAGE_MASK;
87549 pgd_t *pgd;
87550 @@ -1780,7 +1780,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87551 goto next_page;
87552 }
87553
87554 - if (!vma ||
87555 + if (!vma || start < vma->vm_start ||
87556 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
87557 !(vm_flags & vma->vm_flags))
87558 return i ? : -EFAULT;
87559 @@ -1809,11 +1809,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87560 int ret;
87561 unsigned int fault_flags = 0;
87562
87563 - /* For mlock, just skip the stack guard page. */
87564 - if (foll_flags & FOLL_MLOCK) {
87565 - if (stack_guard_page(vma, start))
87566 - goto next_page;
87567 - }
87568 if (foll_flags & FOLL_WRITE)
87569 fault_flags |= FAULT_FLAG_WRITE;
87570 if (nonblocking)
87571 @@ -1893,7 +1888,7 @@ next_page:
87572 start += page_increm * PAGE_SIZE;
87573 nr_pages -= page_increm;
87574 } while (nr_pages && start < vma->vm_end);
87575 - } while (nr_pages);
87576 + }
87577 return i;
87578 }
87579 EXPORT_SYMBOL(__get_user_pages);
87580 @@ -2100,6 +2095,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
87581 page_add_file_rmap(page);
87582 set_pte_at(mm, addr, pte, mk_pte(page, prot));
87583
87584 +#ifdef CONFIG_PAX_SEGMEXEC
87585 + pax_mirror_file_pte(vma, addr, page, ptl);
87586 +#endif
87587 +
87588 retval = 0;
87589 pte_unmap_unlock(pte, ptl);
87590 return retval;
87591 @@ -2144,9 +2143,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
87592 if (!page_count(page))
87593 return -EINVAL;
87594 if (!(vma->vm_flags & VM_MIXEDMAP)) {
87595 +
87596 +#ifdef CONFIG_PAX_SEGMEXEC
87597 + struct vm_area_struct *vma_m;
87598 +#endif
87599 +
87600 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
87601 BUG_ON(vma->vm_flags & VM_PFNMAP);
87602 vma->vm_flags |= VM_MIXEDMAP;
87603 +
87604 +#ifdef CONFIG_PAX_SEGMEXEC
87605 + vma_m = pax_find_mirror_vma(vma);
87606 + if (vma_m)
87607 + vma_m->vm_flags |= VM_MIXEDMAP;
87608 +#endif
87609 +
87610 }
87611 return insert_page(vma, addr, page, vma->vm_page_prot);
87612 }
87613 @@ -2229,6 +2240,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
87614 unsigned long pfn)
87615 {
87616 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
87617 + BUG_ON(vma->vm_mirror);
87618
87619 if (addr < vma->vm_start || addr >= vma->vm_end)
87620 return -EFAULT;
87621 @@ -2476,7 +2488,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
87622
87623 BUG_ON(pud_huge(*pud));
87624
87625 - pmd = pmd_alloc(mm, pud, addr);
87626 + pmd = (mm == &init_mm) ?
87627 + pmd_alloc_kernel(mm, pud, addr) :
87628 + pmd_alloc(mm, pud, addr);
87629 if (!pmd)
87630 return -ENOMEM;
87631 do {
87632 @@ -2496,7 +2510,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
87633 unsigned long next;
87634 int err;
87635
87636 - pud = pud_alloc(mm, pgd, addr);
87637 + pud = (mm == &init_mm) ?
87638 + pud_alloc_kernel(mm, pgd, addr) :
87639 + pud_alloc(mm, pgd, addr);
87640 if (!pud)
87641 return -ENOMEM;
87642 do {
87643 @@ -2584,6 +2600,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
87644 copy_user_highpage(dst, src, va, vma);
87645 }
87646
87647 +#ifdef CONFIG_PAX_SEGMEXEC
87648 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
87649 +{
87650 + struct mm_struct *mm = vma->vm_mm;
87651 + spinlock_t *ptl;
87652 + pte_t *pte, entry;
87653 +
87654 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
87655 + entry = *pte;
87656 + if (!pte_present(entry)) {
87657 + if (!pte_none(entry)) {
87658 + BUG_ON(pte_file(entry));
87659 + free_swap_and_cache(pte_to_swp_entry(entry));
87660 + pte_clear_not_present_full(mm, address, pte, 0);
87661 + }
87662 + } else {
87663 + struct page *page;
87664 +
87665 + flush_cache_page(vma, address, pte_pfn(entry));
87666 + entry = ptep_clear_flush(vma, address, pte);
87667 + BUG_ON(pte_dirty(entry));
87668 + page = vm_normal_page(vma, address, entry);
87669 + if (page) {
87670 + update_hiwater_rss(mm);
87671 + if (PageAnon(page))
87672 + dec_mm_counter_fast(mm, MM_ANONPAGES);
87673 + else
87674 + dec_mm_counter_fast(mm, MM_FILEPAGES);
87675 + page_remove_rmap(page);
87676 + page_cache_release(page);
87677 + }
87678 + }
87679 + pte_unmap_unlock(pte, ptl);
87680 +}
87681 +
87682 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
87683 + *
87684 + * the ptl of the lower mapped page is held on entry and is not released on exit
87685 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
87686 + */
87687 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87688 +{
87689 + struct mm_struct *mm = vma->vm_mm;
87690 + unsigned long address_m;
87691 + spinlock_t *ptl_m;
87692 + struct vm_area_struct *vma_m;
87693 + pmd_t *pmd_m;
87694 + pte_t *pte_m, entry_m;
87695 +
87696 + BUG_ON(!page_m || !PageAnon(page_m));
87697 +
87698 + vma_m = pax_find_mirror_vma(vma);
87699 + if (!vma_m)
87700 + return;
87701 +
87702 + BUG_ON(!PageLocked(page_m));
87703 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87704 + address_m = address + SEGMEXEC_TASK_SIZE;
87705 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87706 + pte_m = pte_offset_map(pmd_m, address_m);
87707 + ptl_m = pte_lockptr(mm, pmd_m);
87708 + if (ptl != ptl_m) {
87709 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87710 + if (!pte_none(*pte_m))
87711 + goto out;
87712 + }
87713 +
87714 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87715 + page_cache_get(page_m);
87716 + page_add_anon_rmap(page_m, vma_m, address_m);
87717 + inc_mm_counter_fast(mm, MM_ANONPAGES);
87718 + set_pte_at(mm, address_m, pte_m, entry_m);
87719 + update_mmu_cache(vma_m, address_m, pte_m);
87720 +out:
87721 + if (ptl != ptl_m)
87722 + spin_unlock(ptl_m);
87723 + pte_unmap(pte_m);
87724 + unlock_page(page_m);
87725 +}
87726 +
87727 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87728 +{
87729 + struct mm_struct *mm = vma->vm_mm;
87730 + unsigned long address_m;
87731 + spinlock_t *ptl_m;
87732 + struct vm_area_struct *vma_m;
87733 + pmd_t *pmd_m;
87734 + pte_t *pte_m, entry_m;
87735 +
87736 + BUG_ON(!page_m || PageAnon(page_m));
87737 +
87738 + vma_m = pax_find_mirror_vma(vma);
87739 + if (!vma_m)
87740 + return;
87741 +
87742 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87743 + address_m = address + SEGMEXEC_TASK_SIZE;
87744 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87745 + pte_m = pte_offset_map(pmd_m, address_m);
87746 + ptl_m = pte_lockptr(mm, pmd_m);
87747 + if (ptl != ptl_m) {
87748 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87749 + if (!pte_none(*pte_m))
87750 + goto out;
87751 + }
87752 +
87753 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87754 + page_cache_get(page_m);
87755 + page_add_file_rmap(page_m);
87756 + inc_mm_counter_fast(mm, MM_FILEPAGES);
87757 + set_pte_at(mm, address_m, pte_m, entry_m);
87758 + update_mmu_cache(vma_m, address_m, pte_m);
87759 +out:
87760 + if (ptl != ptl_m)
87761 + spin_unlock(ptl_m);
87762 + pte_unmap(pte_m);
87763 +}
87764 +
87765 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
87766 +{
87767 + struct mm_struct *mm = vma->vm_mm;
87768 + unsigned long address_m;
87769 + spinlock_t *ptl_m;
87770 + struct vm_area_struct *vma_m;
87771 + pmd_t *pmd_m;
87772 + pte_t *pte_m, entry_m;
87773 +
87774 + vma_m = pax_find_mirror_vma(vma);
87775 + if (!vma_m)
87776 + return;
87777 +
87778 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87779 + address_m = address + SEGMEXEC_TASK_SIZE;
87780 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87781 + pte_m = pte_offset_map(pmd_m, address_m);
87782 + ptl_m = pte_lockptr(mm, pmd_m);
87783 + if (ptl != ptl_m) {
87784 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87785 + if (!pte_none(*pte_m))
87786 + goto out;
87787 + }
87788 +
87789 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
87790 + set_pte_at(mm, address_m, pte_m, entry_m);
87791 +out:
87792 + if (ptl != ptl_m)
87793 + spin_unlock(ptl_m);
87794 + pte_unmap(pte_m);
87795 +}
87796 +
87797 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
87798 +{
87799 + struct page *page_m;
87800 + pte_t entry;
87801 +
87802 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
87803 + goto out;
87804 +
87805 + entry = *pte;
87806 + page_m = vm_normal_page(vma, address, entry);
87807 + if (!page_m)
87808 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
87809 + else if (PageAnon(page_m)) {
87810 + if (pax_find_mirror_vma(vma)) {
87811 + pte_unmap_unlock(pte, ptl);
87812 + lock_page(page_m);
87813 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
87814 + if (pte_same(entry, *pte))
87815 + pax_mirror_anon_pte(vma, address, page_m, ptl);
87816 + else
87817 + unlock_page(page_m);
87818 + }
87819 + } else
87820 + pax_mirror_file_pte(vma, address, page_m, ptl);
87821 +
87822 +out:
87823 + pte_unmap_unlock(pte, ptl);
87824 +}
87825 +#endif
87826 +
87827 /*
87828 * This routine handles present pages, when users try to write
87829 * to a shared page. It is done by copying the page to a new address
87830 @@ -2800,6 +2996,12 @@ gotten:
87831 */
87832 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87833 if (likely(pte_same(*page_table, orig_pte))) {
87834 +
87835 +#ifdef CONFIG_PAX_SEGMEXEC
87836 + if (pax_find_mirror_vma(vma))
87837 + BUG_ON(!trylock_page(new_page));
87838 +#endif
87839 +
87840 if (old_page) {
87841 if (!PageAnon(old_page)) {
87842 dec_mm_counter_fast(mm, MM_FILEPAGES);
87843 @@ -2851,6 +3053,10 @@ gotten:
87844 page_remove_rmap(old_page);
87845 }
87846
87847 +#ifdef CONFIG_PAX_SEGMEXEC
87848 + pax_mirror_anon_pte(vma, address, new_page, ptl);
87849 +#endif
87850 +
87851 /* Free the old page.. */
87852 new_page = old_page;
87853 ret |= VM_FAULT_WRITE;
87854 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
87855 swap_free(entry);
87856 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
87857 try_to_free_swap(page);
87858 +
87859 +#ifdef CONFIG_PAX_SEGMEXEC
87860 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
87861 +#endif
87862 +
87863 unlock_page(page);
87864 if (page != swapcache) {
87865 /*
87866 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
87867
87868 /* No need to invalidate - it was non-present before */
87869 update_mmu_cache(vma, address, page_table);
87870 +
87871 +#ifdef CONFIG_PAX_SEGMEXEC
87872 + pax_mirror_anon_pte(vma, address, page, ptl);
87873 +#endif
87874 +
87875 unlock:
87876 pte_unmap_unlock(page_table, ptl);
87877 out:
87878 @@ -3170,40 +3386,6 @@ out_release:
87879 }
87880
87881 /*
87882 - * This is like a special single-page "expand_{down|up}wards()",
87883 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
87884 - * doesn't hit another vma.
87885 - */
87886 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
87887 -{
87888 - address &= PAGE_MASK;
87889 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
87890 - struct vm_area_struct *prev = vma->vm_prev;
87891 -
87892 - /*
87893 - * Is there a mapping abutting this one below?
87894 - *
87895 - * That's only ok if it's the same stack mapping
87896 - * that has gotten split..
87897 - */
87898 - if (prev && prev->vm_end == address)
87899 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
87900 -
87901 - expand_downwards(vma, address - PAGE_SIZE);
87902 - }
87903 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
87904 - struct vm_area_struct *next = vma->vm_next;
87905 -
87906 - /* As VM_GROWSDOWN but s/below/above/ */
87907 - if (next && next->vm_start == address + PAGE_SIZE)
87908 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
87909 -
87910 - expand_upwards(vma, address + PAGE_SIZE);
87911 - }
87912 - return 0;
87913 -}
87914 -
87915 -/*
87916 * We enter with non-exclusive mmap_sem (to exclude vma changes,
87917 * but allow concurrent faults), and pte mapped but not yet locked.
87918 * We return with mmap_sem still held, but pte unmapped and unlocked.
87919 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87920 unsigned long address, pte_t *page_table, pmd_t *pmd,
87921 unsigned int flags)
87922 {
87923 - struct page *page;
87924 + struct page *page = NULL;
87925 spinlock_t *ptl;
87926 pte_t entry;
87927
87928 - pte_unmap(page_table);
87929 -
87930 - /* Check if we need to add a guard page to the stack */
87931 - if (check_stack_guard_page(vma, address) < 0)
87932 - return VM_FAULT_SIGBUS;
87933 -
87934 - /* Use the zero-page for reads */
87935 if (!(flags & FAULT_FLAG_WRITE)) {
87936 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
87937 vma->vm_page_prot));
87938 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87939 + ptl = pte_lockptr(mm, pmd);
87940 + spin_lock(ptl);
87941 if (!pte_none(*page_table))
87942 goto unlock;
87943 goto setpte;
87944 }
87945
87946 /* Allocate our own private page. */
87947 + pte_unmap(page_table);
87948 +
87949 if (unlikely(anon_vma_prepare(vma)))
87950 goto oom;
87951 page = alloc_zeroed_user_highpage_movable(vma, address);
87952 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87953 if (!pte_none(*page_table))
87954 goto release;
87955
87956 +#ifdef CONFIG_PAX_SEGMEXEC
87957 + if (pax_find_mirror_vma(vma))
87958 + BUG_ON(!trylock_page(page));
87959 +#endif
87960 +
87961 inc_mm_counter_fast(mm, MM_ANONPAGES);
87962 page_add_new_anon_rmap(page, vma, address);
87963 setpte:
87964 @@ -3263,6 +3446,12 @@ setpte:
87965
87966 /* No need to invalidate - it was non-present before */
87967 update_mmu_cache(vma, address, page_table);
87968 +
87969 +#ifdef CONFIG_PAX_SEGMEXEC
87970 + if (page)
87971 + pax_mirror_anon_pte(vma, address, page, ptl);
87972 +#endif
87973 +
87974 unlock:
87975 pte_unmap_unlock(page_table, ptl);
87976 return 0;
87977 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87978 */
87979 /* Only go through if we didn't race with anybody else... */
87980 if (likely(pte_same(*page_table, orig_pte))) {
87981 +
87982 +#ifdef CONFIG_PAX_SEGMEXEC
87983 + if (anon && pax_find_mirror_vma(vma))
87984 + BUG_ON(!trylock_page(page));
87985 +#endif
87986 +
87987 flush_icache_page(vma, page);
87988 entry = mk_pte(page, vma->vm_page_prot);
87989 if (flags & FAULT_FLAG_WRITE)
87990 @@ -3427,6 +3622,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87991
87992 /* no need to invalidate: a not-present page won't be cached */
87993 update_mmu_cache(vma, address, page_table);
87994 +
87995 +#ifdef CONFIG_PAX_SEGMEXEC
87996 + if (anon)
87997 + pax_mirror_anon_pte(vma, address, page, ptl);
87998 + else
87999 + pax_mirror_file_pte(vma, address, page, ptl);
88000 +#endif
88001 +
88002 } else {
88003 if (cow_page)
88004 mem_cgroup_uncharge_page(cow_page);
88005 @@ -3737,6 +3940,12 @@ static int handle_pte_fault(struct mm_struct *mm,
88006 if (flags & FAULT_FLAG_WRITE)
88007 flush_tlb_fix_spurious_fault(vma, address);
88008 }
88009 +
88010 +#ifdef CONFIG_PAX_SEGMEXEC
88011 + pax_mirror_pte(vma, address, pte, pmd, ptl);
88012 + return 0;
88013 +#endif
88014 +
88015 unlock:
88016 pte_unmap_unlock(pte, ptl);
88017 return 0;
88018 @@ -3753,9 +3962,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88019 pmd_t *pmd;
88020 pte_t *pte;
88021
88022 +#ifdef CONFIG_PAX_SEGMEXEC
88023 + struct vm_area_struct *vma_m;
88024 +#endif
88025 +
88026 if (unlikely(is_vm_hugetlb_page(vma)))
88027 return hugetlb_fault(mm, vma, address, flags);
88028
88029 +#ifdef CONFIG_PAX_SEGMEXEC
88030 + vma_m = pax_find_mirror_vma(vma);
88031 + if (vma_m) {
88032 + unsigned long address_m;
88033 + pgd_t *pgd_m;
88034 + pud_t *pud_m;
88035 + pmd_t *pmd_m;
88036 +
88037 + if (vma->vm_start > vma_m->vm_start) {
88038 + address_m = address;
88039 + address -= SEGMEXEC_TASK_SIZE;
88040 + vma = vma_m;
88041 + } else
88042 + address_m = address + SEGMEXEC_TASK_SIZE;
88043 +
88044 + pgd_m = pgd_offset(mm, address_m);
88045 + pud_m = pud_alloc(mm, pgd_m, address_m);
88046 + if (!pud_m)
88047 + return VM_FAULT_OOM;
88048 + pmd_m = pmd_alloc(mm, pud_m, address_m);
88049 + if (!pmd_m)
88050 + return VM_FAULT_OOM;
88051 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
88052 + return VM_FAULT_OOM;
88053 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
88054 + }
88055 +#endif
88056 +
88057 retry:
88058 pgd = pgd_offset(mm, address);
88059 pud = pud_alloc(mm, pgd, address);
88060 @@ -3894,6 +4135,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88061 spin_unlock(&mm->page_table_lock);
88062 return 0;
88063 }
88064 +
88065 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88066 +{
88067 + pud_t *new = pud_alloc_one(mm, address);
88068 + if (!new)
88069 + return -ENOMEM;
88070 +
88071 + smp_wmb(); /* See comment in __pte_alloc */
88072 +
88073 + spin_lock(&mm->page_table_lock);
88074 + if (pgd_present(*pgd)) /* Another has populated it */
88075 + pud_free(mm, new);
88076 + else
88077 + pgd_populate_kernel(mm, pgd, new);
88078 + spin_unlock(&mm->page_table_lock);
88079 + return 0;
88080 +}
88081 #endif /* __PAGETABLE_PUD_FOLDED */
88082
88083 #ifndef __PAGETABLE_PMD_FOLDED
88084 @@ -3924,6 +4182,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
88085 spin_unlock(&mm->page_table_lock);
88086 return 0;
88087 }
88088 +
88089 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
88090 +{
88091 + pmd_t *new = pmd_alloc_one(mm, address);
88092 + if (!new)
88093 + return -ENOMEM;
88094 +
88095 + smp_wmb(); /* See comment in __pte_alloc */
88096 +
88097 + spin_lock(&mm->page_table_lock);
88098 +#ifndef __ARCH_HAS_4LEVEL_HACK
88099 + if (pud_present(*pud)) /* Another has populated it */
88100 + pmd_free(mm, new);
88101 + else
88102 + pud_populate_kernel(mm, pud, new);
88103 +#else
88104 + if (pgd_present(*pud)) /* Another has populated it */
88105 + pmd_free(mm, new);
88106 + else
88107 + pgd_populate_kernel(mm, pud, new);
88108 +#endif /* __ARCH_HAS_4LEVEL_HACK */
88109 + spin_unlock(&mm->page_table_lock);
88110 + return 0;
88111 +}
88112 #endif /* __PAGETABLE_PMD_FOLDED */
88113
88114 #if !defined(__HAVE_ARCH_GATE_AREA)
88115 @@ -3937,7 +4219,7 @@ static int __init gate_vma_init(void)
88116 gate_vma.vm_start = FIXADDR_USER_START;
88117 gate_vma.vm_end = FIXADDR_USER_END;
88118 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
88119 - gate_vma.vm_page_prot = __P101;
88120 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
88121
88122 return 0;
88123 }
88124 @@ -4071,8 +4353,8 @@ out:
88125 return ret;
88126 }
88127
88128 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88129 - void *buf, int len, int write)
88130 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88131 + void *buf, size_t len, int write)
88132 {
88133 resource_size_t phys_addr;
88134 unsigned long prot = 0;
88135 @@ -4098,8 +4380,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
88136 * Access another process' address space as given in mm. If non-NULL, use the
88137 * given task for page fault accounting.
88138 */
88139 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88140 - unsigned long addr, void *buf, int len, int write)
88141 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88142 + unsigned long addr, void *buf, size_t len, int write)
88143 {
88144 struct vm_area_struct *vma;
88145 void *old_buf = buf;
88146 @@ -4107,7 +4389,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88147 down_read(&mm->mmap_sem);
88148 /* ignore errors, just check how much was successfully transferred */
88149 while (len) {
88150 - int bytes, ret, offset;
88151 + ssize_t bytes, ret, offset;
88152 void *maddr;
88153 struct page *page = NULL;
88154
88155 @@ -4166,8 +4448,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88156 *
88157 * The caller must hold a reference on @mm.
88158 */
88159 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88160 - void *buf, int len, int write)
88161 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88162 + void *buf, size_t len, int write)
88163 {
88164 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88165 }
88166 @@ -4177,11 +4459,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88167 * Source/target buffer must be kernel space,
88168 * Do not walk the page table directly, use get_user_pages
88169 */
88170 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
88171 - void *buf, int len, int write)
88172 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
88173 + void *buf, size_t len, int write)
88174 {
88175 struct mm_struct *mm;
88176 - int ret;
88177 + ssize_t ret;
88178
88179 mm = get_task_mm(tsk);
88180 if (!mm)
88181 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
88182 index 0472964..7d5a0ea 100644
88183 --- a/mm/mempolicy.c
88184 +++ b/mm/mempolicy.c
88185 @@ -746,6 +746,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88186 unsigned long vmstart;
88187 unsigned long vmend;
88188
88189 +#ifdef CONFIG_PAX_SEGMEXEC
88190 + struct vm_area_struct *vma_m;
88191 +#endif
88192 +
88193 vma = find_vma(mm, start);
88194 if (!vma || vma->vm_start > start)
88195 return -EFAULT;
88196 @@ -789,6 +793,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88197 err = vma_replace_policy(vma, new_pol);
88198 if (err)
88199 goto out;
88200 +
88201 +#ifdef CONFIG_PAX_SEGMEXEC
88202 + vma_m = pax_find_mirror_vma(vma);
88203 + if (vma_m) {
88204 + err = vma_replace_policy(vma_m, new_pol);
88205 + if (err)
88206 + goto out;
88207 + }
88208 +#endif
88209 +
88210 }
88211
88212 out:
88213 @@ -1252,6 +1266,17 @@ static long do_mbind(unsigned long start, unsigned long len,
88214
88215 if (end < start)
88216 return -EINVAL;
88217 +
88218 +#ifdef CONFIG_PAX_SEGMEXEC
88219 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88220 + if (end > SEGMEXEC_TASK_SIZE)
88221 + return -EINVAL;
88222 + } else
88223 +#endif
88224 +
88225 + if (end > TASK_SIZE)
88226 + return -EINVAL;
88227 +
88228 if (end == start)
88229 return 0;
88230
88231 @@ -1480,8 +1505,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88232 */
88233 tcred = __task_cred(task);
88234 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88235 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88236 - !capable(CAP_SYS_NICE)) {
88237 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88238 rcu_read_unlock();
88239 err = -EPERM;
88240 goto out_put;
88241 @@ -1512,6 +1536,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88242 goto out;
88243 }
88244
88245 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
88246 + if (mm != current->mm &&
88247 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
88248 + mmput(mm);
88249 + err = -EPERM;
88250 + goto out;
88251 + }
88252 +#endif
88253 +
88254 err = do_migrate_pages(mm, old, new,
88255 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
88256
88257 diff --git a/mm/migrate.c b/mm/migrate.c
88258 index c046927..6996b40 100644
88259 --- a/mm/migrate.c
88260 +++ b/mm/migrate.c
88261 @@ -1404,8 +1404,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
88262 */
88263 tcred = __task_cred(task);
88264 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88265 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88266 - !capable(CAP_SYS_NICE)) {
88267 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88268 rcu_read_unlock();
88269 err = -EPERM;
88270 goto out;
88271 diff --git a/mm/mlock.c b/mm/mlock.c
88272 index d480cd6..0f98458 100644
88273 --- a/mm/mlock.c
88274 +++ b/mm/mlock.c
88275 @@ -14,6 +14,7 @@
88276 #include <linux/pagevec.h>
88277 #include <linux/mempolicy.h>
88278 #include <linux/syscalls.h>
88279 +#include <linux/security.h>
88280 #include <linux/sched.h>
88281 #include <linux/export.h>
88282 #include <linux/rmap.h>
88283 @@ -568,7 +569,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
88284 {
88285 unsigned long nstart, end, tmp;
88286 struct vm_area_struct * vma, * prev;
88287 - int error;
88288 + int error = 0;
88289
88290 VM_BUG_ON(start & ~PAGE_MASK);
88291 VM_BUG_ON(len != PAGE_ALIGN(len));
88292 @@ -577,6 +578,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
88293 return -EINVAL;
88294 if (end == start)
88295 return 0;
88296 + if (end > TASK_SIZE)
88297 + return -EINVAL;
88298 +
88299 vma = find_vma(current->mm, start);
88300 if (!vma || vma->vm_start > start)
88301 return -ENOMEM;
88302 @@ -588,6 +592,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
88303 for (nstart = start ; ; ) {
88304 vm_flags_t newflags;
88305
88306 +#ifdef CONFIG_PAX_SEGMEXEC
88307 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88308 + break;
88309 +#endif
88310 +
88311 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
88312
88313 newflags = vma->vm_flags & ~VM_LOCKED;
88314 @@ -700,6 +709,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
88315 lock_limit >>= PAGE_SHIFT;
88316
88317 /* check against resource limits */
88318 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
88319 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
88320 error = do_mlock(start, len, 1);
88321 up_write(&current->mm->mmap_sem);
88322 @@ -734,6 +744,11 @@ static int do_mlockall(int flags)
88323 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
88324 vm_flags_t newflags;
88325
88326 +#ifdef CONFIG_PAX_SEGMEXEC
88327 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88328 + break;
88329 +#endif
88330 +
88331 newflags = vma->vm_flags & ~VM_LOCKED;
88332 if (flags & MCL_CURRENT)
88333 newflags |= VM_LOCKED;
88334 @@ -767,6 +782,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
88335 lock_limit >>= PAGE_SHIFT;
88336
88337 ret = -ENOMEM;
88338 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
88339 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
88340 capable(CAP_IPC_LOCK))
88341 ret = do_mlockall(flags);
88342 diff --git a/mm/mmap.c b/mm/mmap.c
88343 index 9d54851..e8c6035 100644
88344 --- a/mm/mmap.c
88345 +++ b/mm/mmap.c
88346 @@ -36,6 +36,7 @@
88347 #include <linux/sched/sysctl.h>
88348 #include <linux/notifier.h>
88349 #include <linux/memory.h>
88350 +#include <linux/random.h>
88351
88352 #include <asm/uaccess.h>
88353 #include <asm/cacheflush.h>
88354 @@ -52,6 +53,16 @@
88355 #define arch_rebalance_pgtables(addr, len) (addr)
88356 #endif
88357
88358 +static inline void verify_mm_writelocked(struct mm_struct *mm)
88359 +{
88360 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
88361 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88362 + up_read(&mm->mmap_sem);
88363 + BUG();
88364 + }
88365 +#endif
88366 +}
88367 +
88368 static void unmap_region(struct mm_struct *mm,
88369 struct vm_area_struct *vma, struct vm_area_struct *prev,
88370 unsigned long start, unsigned long end);
88371 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
88372 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
88373 *
88374 */
88375 -pgprot_t protection_map[16] = {
88376 +pgprot_t protection_map[16] __read_only = {
88377 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
88378 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
88379 };
88380
88381 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
88382 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
88383 {
88384 - return __pgprot(pgprot_val(protection_map[vm_flags &
88385 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
88386 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
88387 pgprot_val(arch_vm_get_page_prot(vm_flags)));
88388 +
88389 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88390 + if (!(__supported_pte_mask & _PAGE_NX) &&
88391 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
88392 + (vm_flags & (VM_READ | VM_WRITE)))
88393 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
88394 +#endif
88395 +
88396 + return prot;
88397 }
88398 EXPORT_SYMBOL(vm_get_page_prot);
88399
88400 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
88401 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
88402 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88403 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88404 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
88405 /*
88406 * Make sure vm_committed_as in one cacheline and not cacheline shared with
88407 * other variables. It can be updated by several CPUs frequently.
88408 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
88409 struct vm_area_struct *next = vma->vm_next;
88410
88411 might_sleep();
88412 + BUG_ON(vma->vm_mirror);
88413 if (vma->vm_ops && vma->vm_ops->close)
88414 vma->vm_ops->close(vma);
88415 if (vma->vm_file)
88416 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
88417 * not page aligned -Ram Gupta
88418 */
88419 rlim = rlimit(RLIMIT_DATA);
88420 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
88421 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
88422 (mm->end_data - mm->start_data) > rlim)
88423 goto out;
88424 @@ -933,6 +956,12 @@ static int
88425 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
88426 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88427 {
88428 +
88429 +#ifdef CONFIG_PAX_SEGMEXEC
88430 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
88431 + return 0;
88432 +#endif
88433 +
88434 if (is_mergeable_vma(vma, file, vm_flags) &&
88435 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88436 if (vma->vm_pgoff == vm_pgoff)
88437 @@ -952,6 +981,12 @@ static int
88438 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88439 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88440 {
88441 +
88442 +#ifdef CONFIG_PAX_SEGMEXEC
88443 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
88444 + return 0;
88445 +#endif
88446 +
88447 if (is_mergeable_vma(vma, file, vm_flags) &&
88448 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88449 pgoff_t vm_pglen;
88450 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88451 struct vm_area_struct *vma_merge(struct mm_struct *mm,
88452 struct vm_area_struct *prev, unsigned long addr,
88453 unsigned long end, unsigned long vm_flags,
88454 - struct anon_vma *anon_vma, struct file *file,
88455 + struct anon_vma *anon_vma, struct file *file,
88456 pgoff_t pgoff, struct mempolicy *policy)
88457 {
88458 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
88459 struct vm_area_struct *area, *next;
88460 int err;
88461
88462 +#ifdef CONFIG_PAX_SEGMEXEC
88463 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
88464 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
88465 +
88466 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
88467 +#endif
88468 +
88469 /*
88470 * We later require that vma->vm_flags == vm_flags,
88471 * so this tests vma->vm_flags & VM_SPECIAL, too.
88472 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88473 if (next && next->vm_end == end) /* cases 6, 7, 8 */
88474 next = next->vm_next;
88475
88476 +#ifdef CONFIG_PAX_SEGMEXEC
88477 + if (prev)
88478 + prev_m = pax_find_mirror_vma(prev);
88479 + if (area)
88480 + area_m = pax_find_mirror_vma(area);
88481 + if (next)
88482 + next_m = pax_find_mirror_vma(next);
88483 +#endif
88484 +
88485 /*
88486 * Can it merge with the predecessor?
88487 */
88488 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88489 /* cases 1, 6 */
88490 err = vma_adjust(prev, prev->vm_start,
88491 next->vm_end, prev->vm_pgoff, NULL);
88492 - } else /* cases 2, 5, 7 */
88493 +
88494 +#ifdef CONFIG_PAX_SEGMEXEC
88495 + if (!err && prev_m)
88496 + err = vma_adjust(prev_m, prev_m->vm_start,
88497 + next_m->vm_end, prev_m->vm_pgoff, NULL);
88498 +#endif
88499 +
88500 + } else { /* cases 2, 5, 7 */
88501 err = vma_adjust(prev, prev->vm_start,
88502 end, prev->vm_pgoff, NULL);
88503 +
88504 +#ifdef CONFIG_PAX_SEGMEXEC
88505 + if (!err && prev_m)
88506 + err = vma_adjust(prev_m, prev_m->vm_start,
88507 + end_m, prev_m->vm_pgoff, NULL);
88508 +#endif
88509 +
88510 + }
88511 if (err)
88512 return NULL;
88513 khugepaged_enter_vma_merge(prev);
88514 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88515 mpol_equal(policy, vma_policy(next)) &&
88516 can_vma_merge_before(next, vm_flags,
88517 anon_vma, file, pgoff+pglen)) {
88518 - if (prev && addr < prev->vm_end) /* case 4 */
88519 + if (prev && addr < prev->vm_end) { /* case 4 */
88520 err = vma_adjust(prev, prev->vm_start,
88521 addr, prev->vm_pgoff, NULL);
88522 - else /* cases 3, 8 */
88523 +
88524 +#ifdef CONFIG_PAX_SEGMEXEC
88525 + if (!err && prev_m)
88526 + err = vma_adjust(prev_m, prev_m->vm_start,
88527 + addr_m, prev_m->vm_pgoff, NULL);
88528 +#endif
88529 +
88530 + } else { /* cases 3, 8 */
88531 err = vma_adjust(area, addr, next->vm_end,
88532 next->vm_pgoff - pglen, NULL);
88533 +
88534 +#ifdef CONFIG_PAX_SEGMEXEC
88535 + if (!err && area_m)
88536 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
88537 + next_m->vm_pgoff - pglen, NULL);
88538 +#endif
88539 +
88540 + }
88541 if (err)
88542 return NULL;
88543 khugepaged_enter_vma_merge(area);
88544 @@ -1165,8 +1246,10 @@ none:
88545 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88546 struct file *file, long pages)
88547 {
88548 - const unsigned long stack_flags
88549 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
88550 +
88551 +#ifdef CONFIG_PAX_RANDMMAP
88552 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88553 +#endif
88554
88555 mm->total_vm += pages;
88556
88557 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88558 mm->shared_vm += pages;
88559 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
88560 mm->exec_vm += pages;
88561 - } else if (flags & stack_flags)
88562 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
88563 mm->stack_vm += pages;
88564 }
88565 #endif /* CONFIG_PROC_FS */
88566 @@ -1212,7 +1295,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88567 * (the exception is when the underlying filesystem is noexec
88568 * mounted, in which case we dont add PROT_EXEC.)
88569 */
88570 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88571 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88572 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
88573 prot |= PROT_EXEC;
88574
88575 @@ -1238,7 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88576 /* Obtain the address to map to. we verify (or select) it and ensure
88577 * that it represents a valid section of the address space.
88578 */
88579 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
88580 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
88581 if (addr & ~PAGE_MASK)
88582 return addr;
88583
88584 @@ -1249,6 +1332,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88585 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
88586 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
88587
88588 +#ifdef CONFIG_PAX_MPROTECT
88589 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88590 +
88591 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
88592 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
88593 + mm->binfmt->handle_mmap)
88594 + mm->binfmt->handle_mmap(file);
88595 +#endif
88596 +
88597 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88598 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
88599 + gr_log_rwxmmap(file);
88600 +
88601 +#ifdef CONFIG_PAX_EMUPLT
88602 + vm_flags &= ~VM_EXEC;
88603 +#else
88604 + return -EPERM;
88605 +#endif
88606 +
88607 + }
88608 +
88609 + if (!(vm_flags & VM_EXEC))
88610 + vm_flags &= ~VM_MAYEXEC;
88611 +#else
88612 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88613 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88614 +#endif
88615 + else
88616 + vm_flags &= ~VM_MAYWRITE;
88617 + }
88618 +#endif
88619 +
88620 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88621 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
88622 + vm_flags &= ~VM_PAGEEXEC;
88623 +#endif
88624 +
88625 if (flags & MAP_LOCKED)
88626 if (!can_do_mlock())
88627 return -EPERM;
88628 @@ -1260,6 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88629 locked += mm->locked_vm;
88630 lock_limit = rlimit(RLIMIT_MEMLOCK);
88631 lock_limit >>= PAGE_SHIFT;
88632 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88633 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
88634 return -EAGAIN;
88635 }
88636 @@ -1344,6 +1465,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88637 vm_flags |= VM_NORESERVE;
88638 }
88639
88640 + if (!gr_acl_handle_mmap(file, prot))
88641 + return -EACCES;
88642 +
88643 addr = mmap_region(file, addr, len, vm_flags, pgoff);
88644 if (!IS_ERR_VALUE(addr) &&
88645 ((vm_flags & VM_LOCKED) ||
88646 @@ -1437,7 +1561,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
88647 vm_flags_t vm_flags = vma->vm_flags;
88648
88649 /* If it was private or non-writable, the write bit is already clear */
88650 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
88651 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
88652 return 0;
88653
88654 /* The backer wishes to know when pages are first written to? */
88655 @@ -1483,7 +1607,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88656 struct rb_node **rb_link, *rb_parent;
88657 unsigned long charged = 0;
88658
88659 +#ifdef CONFIG_PAX_SEGMEXEC
88660 + struct vm_area_struct *vma_m = NULL;
88661 +#endif
88662 +
88663 + /*
88664 + * mm->mmap_sem is required to protect against another thread
88665 + * changing the mappings in case we sleep.
88666 + */
88667 + verify_mm_writelocked(mm);
88668 +
88669 /* Check against address space limit. */
88670 +
88671 +#ifdef CONFIG_PAX_RANDMMAP
88672 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88673 +#endif
88674 +
88675 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
88676 unsigned long nr_pages;
88677
88678 @@ -1502,11 +1641,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88679
88680 /* Clear old maps */
88681 error = -ENOMEM;
88682 -munmap_back:
88683 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88684 if (do_munmap(mm, addr, len))
88685 return -ENOMEM;
88686 - goto munmap_back;
88687 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88688 }
88689
88690 /*
88691 @@ -1537,6 +1675,16 @@ munmap_back:
88692 goto unacct_error;
88693 }
88694
88695 +#ifdef CONFIG_PAX_SEGMEXEC
88696 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
88697 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88698 + if (!vma_m) {
88699 + error = -ENOMEM;
88700 + goto free_vma;
88701 + }
88702 + }
88703 +#endif
88704 +
88705 vma->vm_mm = mm;
88706 vma->vm_start = addr;
88707 vma->vm_end = addr + len;
88708 @@ -1556,6 +1704,13 @@ munmap_back:
88709 if (error)
88710 goto unmap_and_free_vma;
88711
88712 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88713 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
88714 + vma->vm_flags |= VM_PAGEEXEC;
88715 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88716 + }
88717 +#endif
88718 +
88719 /* Can addr have changed??
88720 *
88721 * Answer: Yes, several device drivers can do it in their
88722 @@ -1589,6 +1744,12 @@ munmap_back:
88723 }
88724
88725 vma_link(mm, vma, prev, rb_link, rb_parent);
88726 +
88727 +#ifdef CONFIG_PAX_SEGMEXEC
88728 + if (vma_m)
88729 + BUG_ON(pax_mirror_vma(vma_m, vma));
88730 +#endif
88731 +
88732 /* Once vma denies write, undo our temporary denial count */
88733 if (vm_flags & VM_DENYWRITE)
88734 allow_write_access(file);
88735 @@ -1597,6 +1758,7 @@ out:
88736 perf_event_mmap(vma);
88737
88738 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
88739 + track_exec_limit(mm, addr, addr + len, vm_flags);
88740 if (vm_flags & VM_LOCKED) {
88741 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
88742 vma == get_gate_vma(current->mm)))
88743 @@ -1629,6 +1791,12 @@ unmap_and_free_vma:
88744 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
88745 charged = 0;
88746 free_vma:
88747 +
88748 +#ifdef CONFIG_PAX_SEGMEXEC
88749 + if (vma_m)
88750 + kmem_cache_free(vm_area_cachep, vma_m);
88751 +#endif
88752 +
88753 kmem_cache_free(vm_area_cachep, vma);
88754 unacct_error:
88755 if (charged)
88756 @@ -1636,7 +1804,63 @@ unacct_error:
88757 return error;
88758 }
88759
88760 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88761 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
88762 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
88763 +{
88764 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
88765 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
88766 +
88767 + return 0;
88768 +}
88769 +#endif
88770 +
88771 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
88772 +{
88773 + if (!vma) {
88774 +#ifdef CONFIG_STACK_GROWSUP
88775 + if (addr > sysctl_heap_stack_gap)
88776 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
88777 + else
88778 + vma = find_vma(current->mm, 0);
88779 + if (vma && (vma->vm_flags & VM_GROWSUP))
88780 + return false;
88781 +#endif
88782 + return true;
88783 + }
88784 +
88785 + if (addr + len > vma->vm_start)
88786 + return false;
88787 +
88788 + if (vma->vm_flags & VM_GROWSDOWN)
88789 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
88790 +#ifdef CONFIG_STACK_GROWSUP
88791 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
88792 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
88793 +#endif
88794 + else if (offset)
88795 + return offset <= vma->vm_start - addr - len;
88796 +
88797 + return true;
88798 +}
88799 +
88800 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
88801 +{
88802 + if (vma->vm_start < len)
88803 + return -ENOMEM;
88804 +
88805 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
88806 + if (offset <= vma->vm_start - len)
88807 + return vma->vm_start - len - offset;
88808 + else
88809 + return -ENOMEM;
88810 + }
88811 +
88812 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
88813 + return vma->vm_start - len - sysctl_heap_stack_gap;
88814 + return -ENOMEM;
88815 +}
88816 +
88817 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
88818 {
88819 /*
88820 * We implement the search by looking for an rbtree node that
88821 @@ -1684,11 +1908,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88822 }
88823 }
88824
88825 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
88826 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
88827 check_current:
88828 /* Check if current node has a suitable gap */
88829 if (gap_start > high_limit)
88830 return -ENOMEM;
88831 +
88832 + if (gap_end - gap_start > info->threadstack_offset)
88833 + gap_start += info->threadstack_offset;
88834 + else
88835 + gap_start = gap_end;
88836 +
88837 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
88838 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88839 + gap_start += sysctl_heap_stack_gap;
88840 + else
88841 + gap_start = gap_end;
88842 + }
88843 + if (vma->vm_flags & VM_GROWSDOWN) {
88844 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88845 + gap_end -= sysctl_heap_stack_gap;
88846 + else
88847 + gap_end = gap_start;
88848 + }
88849 if (gap_end >= low_limit && gap_end - gap_start >= length)
88850 goto found;
88851
88852 @@ -1738,7 +1980,7 @@ found:
88853 return gap_start;
88854 }
88855
88856 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
88857 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
88858 {
88859 struct mm_struct *mm = current->mm;
88860 struct vm_area_struct *vma;
88861 @@ -1792,6 +2034,24 @@ check_current:
88862 gap_end = vma->vm_start;
88863 if (gap_end < low_limit)
88864 return -ENOMEM;
88865 +
88866 + if (gap_end - gap_start > info->threadstack_offset)
88867 + gap_end -= info->threadstack_offset;
88868 + else
88869 + gap_end = gap_start;
88870 +
88871 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
88872 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88873 + gap_start += sysctl_heap_stack_gap;
88874 + else
88875 + gap_start = gap_end;
88876 + }
88877 + if (vma->vm_flags & VM_GROWSDOWN) {
88878 + if (gap_end - gap_start > sysctl_heap_stack_gap)
88879 + gap_end -= sysctl_heap_stack_gap;
88880 + else
88881 + gap_end = gap_start;
88882 + }
88883 if (gap_start <= high_limit && gap_end - gap_start >= length)
88884 goto found;
88885
88886 @@ -1855,6 +2115,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
88887 struct mm_struct *mm = current->mm;
88888 struct vm_area_struct *vma;
88889 struct vm_unmapped_area_info info;
88890 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88891
88892 if (len > TASK_SIZE)
88893 return -ENOMEM;
88894 @@ -1862,19 +2123,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
88895 if (flags & MAP_FIXED)
88896 return addr;
88897
88898 +#ifdef CONFIG_PAX_RANDMMAP
88899 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88900 +#endif
88901 +
88902 if (addr) {
88903 addr = PAGE_ALIGN(addr);
88904 vma = find_vma(mm, addr);
88905 - if (TASK_SIZE - len >= addr &&
88906 - (!vma || addr + len <= vma->vm_start))
88907 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88908 return addr;
88909 }
88910
88911 info.flags = 0;
88912 info.length = len;
88913 info.low_limit = TASK_UNMAPPED_BASE;
88914 +
88915 +#ifdef CONFIG_PAX_RANDMMAP
88916 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88917 + info.low_limit += mm->delta_mmap;
88918 +#endif
88919 +
88920 info.high_limit = TASK_SIZE;
88921 info.align_mask = 0;
88922 + info.threadstack_offset = offset;
88923 return vm_unmapped_area(&info);
88924 }
88925 #endif
88926 @@ -1893,6 +2164,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88927 struct mm_struct *mm = current->mm;
88928 unsigned long addr = addr0;
88929 struct vm_unmapped_area_info info;
88930 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88931
88932 /* requested length too big for entire address space */
88933 if (len > TASK_SIZE)
88934 @@ -1901,12 +2173,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88935 if (flags & MAP_FIXED)
88936 return addr;
88937
88938 +#ifdef CONFIG_PAX_RANDMMAP
88939 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88940 +#endif
88941 +
88942 /* requesting a specific address */
88943 if (addr) {
88944 addr = PAGE_ALIGN(addr);
88945 vma = find_vma(mm, addr);
88946 - if (TASK_SIZE - len >= addr &&
88947 - (!vma || addr + len <= vma->vm_start))
88948 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88949 return addr;
88950 }
88951
88952 @@ -1915,6 +2190,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88953 info.low_limit = PAGE_SIZE;
88954 info.high_limit = mm->mmap_base;
88955 info.align_mask = 0;
88956 + info.threadstack_offset = offset;
88957 addr = vm_unmapped_area(&info);
88958
88959 /*
88960 @@ -1927,6 +2203,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88961 VM_BUG_ON(addr != -ENOMEM);
88962 info.flags = 0;
88963 info.low_limit = TASK_UNMAPPED_BASE;
88964 +
88965 +#ifdef CONFIG_PAX_RANDMMAP
88966 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88967 + info.low_limit += mm->delta_mmap;
88968 +#endif
88969 +
88970 info.high_limit = TASK_SIZE;
88971 addr = vm_unmapped_area(&info);
88972 }
88973 @@ -2028,6 +2310,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
88974 return vma;
88975 }
88976
88977 +#ifdef CONFIG_PAX_SEGMEXEC
88978 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
88979 +{
88980 + struct vm_area_struct *vma_m;
88981 +
88982 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
88983 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
88984 + BUG_ON(vma->vm_mirror);
88985 + return NULL;
88986 + }
88987 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
88988 + vma_m = vma->vm_mirror;
88989 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
88990 + BUG_ON(vma->vm_file != vma_m->vm_file);
88991 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
88992 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
88993 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
88994 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
88995 + return vma_m;
88996 +}
88997 +#endif
88998 +
88999 /*
89000 * Verify that the stack growth is acceptable and
89001 * update accounting. This is shared with both the
89002 @@ -2044,6 +2348,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89003 return -ENOMEM;
89004
89005 /* Stack limit test */
89006 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
89007 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
89008 return -ENOMEM;
89009
89010 @@ -2054,6 +2359,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89011 locked = mm->locked_vm + grow;
89012 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
89013 limit >>= PAGE_SHIFT;
89014 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
89015 if (locked > limit && !capable(CAP_IPC_LOCK))
89016 return -ENOMEM;
89017 }
89018 @@ -2083,37 +2389,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89019 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
89020 * vma is the last one with address > vma->vm_end. Have to extend vma.
89021 */
89022 +#ifndef CONFIG_IA64
89023 +static
89024 +#endif
89025 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89026 {
89027 int error;
89028 + bool locknext;
89029
89030 if (!(vma->vm_flags & VM_GROWSUP))
89031 return -EFAULT;
89032
89033 + /* Also guard against wrapping around to address 0. */
89034 + if (address < PAGE_ALIGN(address+1))
89035 + address = PAGE_ALIGN(address+1);
89036 + else
89037 + return -ENOMEM;
89038 +
89039 /*
89040 * We must make sure the anon_vma is allocated
89041 * so that the anon_vma locking is not a noop.
89042 */
89043 if (unlikely(anon_vma_prepare(vma)))
89044 return -ENOMEM;
89045 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
89046 + if (locknext && anon_vma_prepare(vma->vm_next))
89047 + return -ENOMEM;
89048 vma_lock_anon_vma(vma);
89049 + if (locknext)
89050 + vma_lock_anon_vma(vma->vm_next);
89051
89052 /*
89053 * vma->vm_start/vm_end cannot change under us because the caller
89054 * is required to hold the mmap_sem in read mode. We need the
89055 - * anon_vma lock to serialize against concurrent expand_stacks.
89056 - * Also guard against wrapping around to address 0.
89057 + * anon_vma locks to serialize against concurrent expand_stacks
89058 + * and expand_upwards.
89059 */
89060 - if (address < PAGE_ALIGN(address+4))
89061 - address = PAGE_ALIGN(address+4);
89062 - else {
89063 - vma_unlock_anon_vma(vma);
89064 - return -ENOMEM;
89065 - }
89066 error = 0;
89067
89068 /* Somebody else might have raced and expanded it already */
89069 - if (address > vma->vm_end) {
89070 + 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)
89071 + error = -ENOMEM;
89072 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
89073 unsigned long size, grow;
89074
89075 size = address - vma->vm_start;
89076 @@ -2148,6 +2465,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89077 }
89078 }
89079 }
89080 + if (locknext)
89081 + vma_unlock_anon_vma(vma->vm_next);
89082 vma_unlock_anon_vma(vma);
89083 khugepaged_enter_vma_merge(vma);
89084 validate_mm(vma->vm_mm);
89085 @@ -2162,6 +2481,8 @@ int expand_downwards(struct vm_area_struct *vma,
89086 unsigned long address)
89087 {
89088 int error;
89089 + bool lockprev = false;
89090 + struct vm_area_struct *prev;
89091
89092 /*
89093 * We must make sure the anon_vma is allocated
89094 @@ -2175,6 +2496,15 @@ int expand_downwards(struct vm_area_struct *vma,
89095 if (error)
89096 return error;
89097
89098 + prev = vma->vm_prev;
89099 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
89100 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
89101 +#endif
89102 + if (lockprev && anon_vma_prepare(prev))
89103 + return -ENOMEM;
89104 + if (lockprev)
89105 + vma_lock_anon_vma(prev);
89106 +
89107 vma_lock_anon_vma(vma);
89108
89109 /*
89110 @@ -2184,9 +2514,17 @@ int expand_downwards(struct vm_area_struct *vma,
89111 */
89112
89113 /* Somebody else might have raced and expanded it already */
89114 - if (address < vma->vm_start) {
89115 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
89116 + error = -ENOMEM;
89117 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
89118 unsigned long size, grow;
89119
89120 +#ifdef CONFIG_PAX_SEGMEXEC
89121 + struct vm_area_struct *vma_m;
89122 +
89123 + vma_m = pax_find_mirror_vma(vma);
89124 +#endif
89125 +
89126 size = vma->vm_end - address;
89127 grow = (vma->vm_start - address) >> PAGE_SHIFT;
89128
89129 @@ -2211,13 +2549,27 @@ int expand_downwards(struct vm_area_struct *vma,
89130 vma->vm_pgoff -= grow;
89131 anon_vma_interval_tree_post_update_vma(vma);
89132 vma_gap_update(vma);
89133 +
89134 +#ifdef CONFIG_PAX_SEGMEXEC
89135 + if (vma_m) {
89136 + anon_vma_interval_tree_pre_update_vma(vma_m);
89137 + vma_m->vm_start -= grow << PAGE_SHIFT;
89138 + vma_m->vm_pgoff -= grow;
89139 + anon_vma_interval_tree_post_update_vma(vma_m);
89140 + vma_gap_update(vma_m);
89141 + }
89142 +#endif
89143 +
89144 spin_unlock(&vma->vm_mm->page_table_lock);
89145
89146 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
89147 perf_event_mmap(vma);
89148 }
89149 }
89150 }
89151 vma_unlock_anon_vma(vma);
89152 + if (lockprev)
89153 + vma_unlock_anon_vma(prev);
89154 khugepaged_enter_vma_merge(vma);
89155 validate_mm(vma->vm_mm);
89156 return error;
89157 @@ -2315,6 +2667,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
89158 do {
89159 long nrpages = vma_pages(vma);
89160
89161 +#ifdef CONFIG_PAX_SEGMEXEC
89162 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
89163 + vma = remove_vma(vma);
89164 + continue;
89165 + }
89166 +#endif
89167 +
89168 if (vma->vm_flags & VM_ACCOUNT)
89169 nr_accounted += nrpages;
89170 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
89171 @@ -2359,6 +2718,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
89172 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
89173 vma->vm_prev = NULL;
89174 do {
89175 +
89176 +#ifdef CONFIG_PAX_SEGMEXEC
89177 + if (vma->vm_mirror) {
89178 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
89179 + vma->vm_mirror->vm_mirror = NULL;
89180 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
89181 + vma->vm_mirror = NULL;
89182 + }
89183 +#endif
89184 +
89185 vma_rb_erase(vma, &mm->mm_rb);
89186 mm->map_count--;
89187 tail_vma = vma;
89188 @@ -2384,14 +2753,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89189 struct vm_area_struct *new;
89190 int err = -ENOMEM;
89191
89192 +#ifdef CONFIG_PAX_SEGMEXEC
89193 + struct vm_area_struct *vma_m, *new_m = NULL;
89194 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
89195 +#endif
89196 +
89197 if (is_vm_hugetlb_page(vma) && (addr &
89198 ~(huge_page_mask(hstate_vma(vma)))))
89199 return -EINVAL;
89200
89201 +#ifdef CONFIG_PAX_SEGMEXEC
89202 + vma_m = pax_find_mirror_vma(vma);
89203 +#endif
89204 +
89205 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89206 if (!new)
89207 goto out_err;
89208
89209 +#ifdef CONFIG_PAX_SEGMEXEC
89210 + if (vma_m) {
89211 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89212 + if (!new_m) {
89213 + kmem_cache_free(vm_area_cachep, new);
89214 + goto out_err;
89215 + }
89216 + }
89217 +#endif
89218 +
89219 /* most fields are the same, copy all, and then fixup */
89220 *new = *vma;
89221
89222 @@ -2404,6 +2792,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89223 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
89224 }
89225
89226 +#ifdef CONFIG_PAX_SEGMEXEC
89227 + if (vma_m) {
89228 + *new_m = *vma_m;
89229 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
89230 + new_m->vm_mirror = new;
89231 + new->vm_mirror = new_m;
89232 +
89233 + if (new_below)
89234 + new_m->vm_end = addr_m;
89235 + else {
89236 + new_m->vm_start = addr_m;
89237 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
89238 + }
89239 + }
89240 +#endif
89241 +
89242 err = vma_dup_policy(vma, new);
89243 if (err)
89244 goto out_free_vma;
89245 @@ -2423,6 +2827,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89246 else
89247 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
89248
89249 +#ifdef CONFIG_PAX_SEGMEXEC
89250 + if (!err && vma_m) {
89251 + struct mempolicy *pol = vma_policy(new);
89252 +
89253 + if (anon_vma_clone(new_m, vma_m))
89254 + goto out_free_mpol;
89255 +
89256 + mpol_get(pol);
89257 + set_vma_policy(new_m, pol);
89258 +
89259 + if (new_m->vm_file)
89260 + get_file(new_m->vm_file);
89261 +
89262 + if (new_m->vm_ops && new_m->vm_ops->open)
89263 + new_m->vm_ops->open(new_m);
89264 +
89265 + if (new_below)
89266 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
89267 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
89268 + else
89269 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
89270 +
89271 + if (err) {
89272 + if (new_m->vm_ops && new_m->vm_ops->close)
89273 + new_m->vm_ops->close(new_m);
89274 + if (new_m->vm_file)
89275 + fput(new_m->vm_file);
89276 + mpol_put(pol);
89277 + }
89278 + }
89279 +#endif
89280 +
89281 /* Success. */
89282 if (!err)
89283 return 0;
89284 @@ -2432,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89285 new->vm_ops->close(new);
89286 if (new->vm_file)
89287 fput(new->vm_file);
89288 - unlink_anon_vmas(new);
89289 out_free_mpol:
89290 mpol_put(vma_policy(new));
89291 out_free_vma:
89292 +
89293 +#ifdef CONFIG_PAX_SEGMEXEC
89294 + if (new_m) {
89295 + unlink_anon_vmas(new_m);
89296 + kmem_cache_free(vm_area_cachep, new_m);
89297 + }
89298 +#endif
89299 +
89300 + unlink_anon_vmas(new);
89301 kmem_cache_free(vm_area_cachep, new);
89302 out_err:
89303 return err;
89304 @@ -2448,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89305 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89306 unsigned long addr, int new_below)
89307 {
89308 +
89309 +#ifdef CONFIG_PAX_SEGMEXEC
89310 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89311 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
89312 + if (mm->map_count >= sysctl_max_map_count-1)
89313 + return -ENOMEM;
89314 + } else
89315 +#endif
89316 +
89317 if (mm->map_count >= sysctl_max_map_count)
89318 return -ENOMEM;
89319
89320 @@ -2459,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89321 * work. This now handles partial unmappings.
89322 * Jeremy Fitzhardinge <jeremy@goop.org>
89323 */
89324 +#ifdef CONFIG_PAX_SEGMEXEC
89325 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89326 {
89327 + int ret = __do_munmap(mm, start, len);
89328 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
89329 + return ret;
89330 +
89331 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
89332 +}
89333 +
89334 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89335 +#else
89336 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89337 +#endif
89338 +{
89339 unsigned long end;
89340 struct vm_area_struct *vma, *prev, *last;
89341
89342 + /*
89343 + * mm->mmap_sem is required to protect against another thread
89344 + * changing the mappings in case we sleep.
89345 + */
89346 + verify_mm_writelocked(mm);
89347 +
89348 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
89349 return -EINVAL;
89350
89351 @@ -2538,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89352 /* Fix up all other VM information */
89353 remove_vma_list(mm, vma);
89354
89355 + track_exec_limit(mm, start, end, 0UL);
89356 +
89357 return 0;
89358 }
89359
89360 @@ -2546,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
89361 int ret;
89362 struct mm_struct *mm = current->mm;
89363
89364 +
89365 +#ifdef CONFIG_PAX_SEGMEXEC
89366 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
89367 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
89368 + return -EINVAL;
89369 +#endif
89370 +
89371 down_write(&mm->mmap_sem);
89372 ret = do_munmap(mm, start, len);
89373 up_write(&mm->mmap_sem);
89374 @@ -2559,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
89375 return vm_munmap(addr, len);
89376 }
89377
89378 -static inline void verify_mm_writelocked(struct mm_struct *mm)
89379 -{
89380 -#ifdef CONFIG_DEBUG_VM
89381 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89382 - WARN_ON(1);
89383 - up_read(&mm->mmap_sem);
89384 - }
89385 -#endif
89386 -}
89387 -
89388 /*
89389 * this is really a simplified "do_mmap". it only handles
89390 * anonymous maps. eventually we may be able to do some
89391 @@ -2582,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89392 struct rb_node ** rb_link, * rb_parent;
89393 pgoff_t pgoff = addr >> PAGE_SHIFT;
89394 int error;
89395 + unsigned long charged;
89396
89397 len = PAGE_ALIGN(len);
89398 if (!len)
89399 @@ -2589,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89400
89401 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
89402
89403 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
89404 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
89405 + flags &= ~VM_EXEC;
89406 +
89407 +#ifdef CONFIG_PAX_MPROTECT
89408 + if (mm->pax_flags & MF_PAX_MPROTECT)
89409 + flags &= ~VM_MAYEXEC;
89410 +#endif
89411 +
89412 + }
89413 +#endif
89414 +
89415 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
89416 if (error & ~PAGE_MASK)
89417 return error;
89418
89419 + charged = len >> PAGE_SHIFT;
89420 +
89421 /*
89422 * mlock MCL_FUTURE?
89423 */
89424 if (mm->def_flags & VM_LOCKED) {
89425 unsigned long locked, lock_limit;
89426 - locked = len >> PAGE_SHIFT;
89427 + locked = charged;
89428 locked += mm->locked_vm;
89429 lock_limit = rlimit(RLIMIT_MEMLOCK);
89430 lock_limit >>= PAGE_SHIFT;
89431 @@ -2615,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89432 /*
89433 * Clear old maps. this also does some error checking for us
89434 */
89435 - munmap_back:
89436 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89437 if (do_munmap(mm, addr, len))
89438 return -ENOMEM;
89439 - goto munmap_back;
89440 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89441 }
89442
89443 /* Check against address space limits *after* clearing old maps... */
89444 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
89445 + if (!may_expand_vm(mm, charged))
89446 return -ENOMEM;
89447
89448 if (mm->map_count > sysctl_max_map_count)
89449 return -ENOMEM;
89450
89451 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
89452 + if (security_vm_enough_memory_mm(mm, charged))
89453 return -ENOMEM;
89454
89455 /* Can we just expand an old private anonymous mapping? */
89456 @@ -2643,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89457 */
89458 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89459 if (!vma) {
89460 - vm_unacct_memory(len >> PAGE_SHIFT);
89461 + vm_unacct_memory(charged);
89462 return -ENOMEM;
89463 }
89464
89465 @@ -2657,10 +3142,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89466 vma_link(mm, vma, prev, rb_link, rb_parent);
89467 out:
89468 perf_event_mmap(vma);
89469 - mm->total_vm += len >> PAGE_SHIFT;
89470 + mm->total_vm += charged;
89471 if (flags & VM_LOCKED)
89472 - mm->locked_vm += (len >> PAGE_SHIFT);
89473 + mm->locked_vm += charged;
89474 vma->vm_flags |= VM_SOFTDIRTY;
89475 + track_exec_limit(mm, addr, addr + len, flags);
89476 return addr;
89477 }
89478
89479 @@ -2722,6 +3208,7 @@ void exit_mmap(struct mm_struct *mm)
89480 while (vma) {
89481 if (vma->vm_flags & VM_ACCOUNT)
89482 nr_accounted += vma_pages(vma);
89483 + vma->vm_mirror = NULL;
89484 vma = remove_vma(vma);
89485 }
89486 vm_unacct_memory(nr_accounted);
89487 @@ -2738,6 +3225,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89488 struct vm_area_struct *prev;
89489 struct rb_node **rb_link, *rb_parent;
89490
89491 +#ifdef CONFIG_PAX_SEGMEXEC
89492 + struct vm_area_struct *vma_m = NULL;
89493 +#endif
89494 +
89495 + if (security_mmap_addr(vma->vm_start))
89496 + return -EPERM;
89497 +
89498 /*
89499 * The vm_pgoff of a purely anonymous vma should be irrelevant
89500 * until its first write fault, when page's anon_vma and index
89501 @@ -2761,7 +3255,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89502 security_vm_enough_memory_mm(mm, vma_pages(vma)))
89503 return -ENOMEM;
89504
89505 +#ifdef CONFIG_PAX_SEGMEXEC
89506 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
89507 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89508 + if (!vma_m)
89509 + return -ENOMEM;
89510 + }
89511 +#endif
89512 +
89513 vma_link(mm, vma, prev, rb_link, rb_parent);
89514 +
89515 +#ifdef CONFIG_PAX_SEGMEXEC
89516 + if (vma_m)
89517 + BUG_ON(pax_mirror_vma(vma_m, vma));
89518 +#endif
89519 +
89520 return 0;
89521 }
89522
89523 @@ -2780,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89524 struct rb_node **rb_link, *rb_parent;
89525 bool faulted_in_anon_vma = true;
89526
89527 + BUG_ON(vma->vm_mirror);
89528 +
89529 /*
89530 * If anonymous vma has not yet been faulted, update new pgoff
89531 * to match new location, to increase its chance of merging.
89532 @@ -2844,6 +3354,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89533 return NULL;
89534 }
89535
89536 +#ifdef CONFIG_PAX_SEGMEXEC
89537 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
89538 +{
89539 + struct vm_area_struct *prev_m;
89540 + struct rb_node **rb_link_m, *rb_parent_m;
89541 + struct mempolicy *pol_m;
89542 +
89543 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
89544 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
89545 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
89546 + *vma_m = *vma;
89547 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
89548 + if (anon_vma_clone(vma_m, vma))
89549 + return -ENOMEM;
89550 + pol_m = vma_policy(vma_m);
89551 + mpol_get(pol_m);
89552 + set_vma_policy(vma_m, pol_m);
89553 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
89554 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
89555 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
89556 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
89557 + if (vma_m->vm_file)
89558 + get_file(vma_m->vm_file);
89559 + if (vma_m->vm_ops && vma_m->vm_ops->open)
89560 + vma_m->vm_ops->open(vma_m);
89561 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
89562 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
89563 + vma_m->vm_mirror = vma;
89564 + vma->vm_mirror = vma_m;
89565 + return 0;
89566 +}
89567 +#endif
89568 +
89569 /*
89570 * Return true if the calling process may expand its vm space by the passed
89571 * number of pages
89572 @@ -2855,6 +3398,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
89573
89574 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
89575
89576 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
89577 if (cur + npages > lim)
89578 return 0;
89579 return 1;
89580 @@ -2925,6 +3469,22 @@ int install_special_mapping(struct mm_struct *mm,
89581 vma->vm_start = addr;
89582 vma->vm_end = addr + len;
89583
89584 +#ifdef CONFIG_PAX_MPROTECT
89585 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89586 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89587 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
89588 + return -EPERM;
89589 + if (!(vm_flags & VM_EXEC))
89590 + vm_flags &= ~VM_MAYEXEC;
89591 +#else
89592 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89593 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89594 +#endif
89595 + else
89596 + vm_flags &= ~VM_MAYWRITE;
89597 + }
89598 +#endif
89599 +
89600 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
89601 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89602
89603 diff --git a/mm/mprotect.c b/mm/mprotect.c
89604 index 412ba2b..cb41d42 100644
89605 --- a/mm/mprotect.c
89606 +++ b/mm/mprotect.c
89607 @@ -23,10 +23,18 @@
89608 #include <linux/mmu_notifier.h>
89609 #include <linux/migrate.h>
89610 #include <linux/perf_event.h>
89611 +#include <linux/sched/sysctl.h>
89612 +
89613 +#ifdef CONFIG_PAX_MPROTECT
89614 +#include <linux/elf.h>
89615 +#include <linux/binfmts.h>
89616 +#endif
89617 +
89618 #include <asm/uaccess.h>
89619 #include <asm/pgtable.h>
89620 #include <asm/cacheflush.h>
89621 #include <asm/tlbflush.h>
89622 +#include <asm/mmu_context.h>
89623
89624 #ifndef pgprot_modify
89625 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
89626 @@ -236,6 +244,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
89627 return pages;
89628 }
89629
89630 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89631 +/* called while holding the mmap semaphor for writing except stack expansion */
89632 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
89633 +{
89634 + unsigned long oldlimit, newlimit = 0UL;
89635 +
89636 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
89637 + return;
89638 +
89639 + spin_lock(&mm->page_table_lock);
89640 + oldlimit = mm->context.user_cs_limit;
89641 + if ((prot & VM_EXEC) && oldlimit < end)
89642 + /* USER_CS limit moved up */
89643 + newlimit = end;
89644 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
89645 + /* USER_CS limit moved down */
89646 + newlimit = start;
89647 +
89648 + if (newlimit) {
89649 + mm->context.user_cs_limit = newlimit;
89650 +
89651 +#ifdef CONFIG_SMP
89652 + wmb();
89653 + cpus_clear(mm->context.cpu_user_cs_mask);
89654 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
89655 +#endif
89656 +
89657 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
89658 + }
89659 + spin_unlock(&mm->page_table_lock);
89660 + if (newlimit == end) {
89661 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
89662 +
89663 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
89664 + if (is_vm_hugetlb_page(vma))
89665 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
89666 + else
89667 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
89668 + }
89669 +}
89670 +#endif
89671 +
89672 int
89673 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89674 unsigned long start, unsigned long end, unsigned long newflags)
89675 @@ -248,11 +298,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89676 int error;
89677 int dirty_accountable = 0;
89678
89679 +#ifdef CONFIG_PAX_SEGMEXEC
89680 + struct vm_area_struct *vma_m = NULL;
89681 + unsigned long start_m, end_m;
89682 +
89683 + start_m = start + SEGMEXEC_TASK_SIZE;
89684 + end_m = end + SEGMEXEC_TASK_SIZE;
89685 +#endif
89686 +
89687 if (newflags == oldflags) {
89688 *pprev = vma;
89689 return 0;
89690 }
89691
89692 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
89693 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
89694 +
89695 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
89696 + return -ENOMEM;
89697 +
89698 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
89699 + return -ENOMEM;
89700 + }
89701 +
89702 /*
89703 * If we make a private mapping writable we increase our commit;
89704 * but (without finer accounting) cannot reduce our commit if we
89705 @@ -269,6 +337,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89706 }
89707 }
89708
89709 +#ifdef CONFIG_PAX_SEGMEXEC
89710 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
89711 + if (start != vma->vm_start) {
89712 + error = split_vma(mm, vma, start, 1);
89713 + if (error)
89714 + goto fail;
89715 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
89716 + *pprev = (*pprev)->vm_next;
89717 + }
89718 +
89719 + if (end != vma->vm_end) {
89720 + error = split_vma(mm, vma, end, 0);
89721 + if (error)
89722 + goto fail;
89723 + }
89724 +
89725 + if (pax_find_mirror_vma(vma)) {
89726 + error = __do_munmap(mm, start_m, end_m - start_m);
89727 + if (error)
89728 + goto fail;
89729 + } else {
89730 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89731 + if (!vma_m) {
89732 + error = -ENOMEM;
89733 + goto fail;
89734 + }
89735 + vma->vm_flags = newflags;
89736 + error = pax_mirror_vma(vma_m, vma);
89737 + if (error) {
89738 + vma->vm_flags = oldflags;
89739 + goto fail;
89740 + }
89741 + }
89742 + }
89743 +#endif
89744 +
89745 /*
89746 * First try to merge with previous and/or next vma.
89747 */
89748 @@ -299,9 +403,21 @@ success:
89749 * vm_flags and vm_page_prot are protected by the mmap_sem
89750 * held in write mode.
89751 */
89752 +
89753 +#ifdef CONFIG_PAX_SEGMEXEC
89754 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
89755 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
89756 +#endif
89757 +
89758 vma->vm_flags = newflags;
89759 +
89760 +#ifdef CONFIG_PAX_MPROTECT
89761 + if (mm->binfmt && mm->binfmt->handle_mprotect)
89762 + mm->binfmt->handle_mprotect(vma, newflags);
89763 +#endif
89764 +
89765 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
89766 - vm_get_page_prot(newflags));
89767 + vm_get_page_prot(vma->vm_flags));
89768
89769 if (vma_wants_writenotify(vma)) {
89770 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
89771 @@ -340,6 +456,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89772 end = start + len;
89773 if (end <= start)
89774 return -ENOMEM;
89775 +
89776 +#ifdef CONFIG_PAX_SEGMEXEC
89777 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
89778 + if (end > SEGMEXEC_TASK_SIZE)
89779 + return -EINVAL;
89780 + } else
89781 +#endif
89782 +
89783 + if (end > TASK_SIZE)
89784 + return -EINVAL;
89785 +
89786 if (!arch_validate_prot(prot))
89787 return -EINVAL;
89788
89789 @@ -347,7 +474,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89790 /*
89791 * Does the application expect PROT_READ to imply PROT_EXEC:
89792 */
89793 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
89794 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
89795 prot |= PROT_EXEC;
89796
89797 vm_flags = calc_vm_prot_bits(prot);
89798 @@ -379,6 +506,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89799 if (start > vma->vm_start)
89800 prev = vma;
89801
89802 +#ifdef CONFIG_PAX_MPROTECT
89803 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
89804 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
89805 +#endif
89806 +
89807 for (nstart = start ; ; ) {
89808 unsigned long newflags;
89809
89810 @@ -389,6 +521,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89811
89812 /* newflags >> 4 shift VM_MAY% in place of VM_% */
89813 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
89814 + if (prot & (PROT_WRITE | PROT_EXEC))
89815 + gr_log_rwxmprotect(vma);
89816 +
89817 + error = -EACCES;
89818 + goto out;
89819 + }
89820 +
89821 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
89822 error = -EACCES;
89823 goto out;
89824 }
89825 @@ -403,6 +543,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89826 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
89827 if (error)
89828 goto out;
89829 +
89830 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
89831 +
89832 nstart = tmp;
89833
89834 if (nstart < prev->vm_end)
89835 diff --git a/mm/mremap.c b/mm/mremap.c
89836 index 0843feb..4f5b2e6 100644
89837 --- a/mm/mremap.c
89838 +++ b/mm/mremap.c
89839 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
89840 continue;
89841 pte = ptep_get_and_clear(mm, old_addr, old_pte);
89842 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
89843 +
89844 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89845 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
89846 + pte = pte_exprotect(pte);
89847 +#endif
89848 +
89849 pte = move_soft_dirty_pte(pte);
89850 set_pte_at(mm, new_addr, new_pte, pte);
89851 }
89852 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
89853 if (is_vm_hugetlb_page(vma))
89854 goto Einval;
89855
89856 +#ifdef CONFIG_PAX_SEGMEXEC
89857 + if (pax_find_mirror_vma(vma))
89858 + goto Einval;
89859 +#endif
89860 +
89861 /* We can't remap across vm area boundaries */
89862 if (old_len > vma->vm_end - addr)
89863 goto Efault;
89864 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
89865 unsigned long ret = -EINVAL;
89866 unsigned long charged = 0;
89867 unsigned long map_flags;
89868 + unsigned long pax_task_size = TASK_SIZE;
89869
89870 if (new_addr & ~PAGE_MASK)
89871 goto out;
89872
89873 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
89874 +#ifdef CONFIG_PAX_SEGMEXEC
89875 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
89876 + pax_task_size = SEGMEXEC_TASK_SIZE;
89877 +#endif
89878 +
89879 + pax_task_size -= PAGE_SIZE;
89880 +
89881 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
89882 goto out;
89883
89884 /* Check if the location we're moving into overlaps the
89885 * old location at all, and fail if it does.
89886 */
89887 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
89888 - goto out;
89889 -
89890 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
89891 + if (addr + old_len > new_addr && new_addr + new_len > addr)
89892 goto out;
89893
89894 ret = do_munmap(mm, new_addr, new_len);
89895 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89896 unsigned long ret = -EINVAL;
89897 unsigned long charged = 0;
89898 bool locked = false;
89899 + unsigned long pax_task_size = TASK_SIZE;
89900
89901 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
89902 return ret;
89903 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89904 if (!new_len)
89905 return ret;
89906
89907 +#ifdef CONFIG_PAX_SEGMEXEC
89908 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
89909 + pax_task_size = SEGMEXEC_TASK_SIZE;
89910 +#endif
89911 +
89912 + pax_task_size -= PAGE_SIZE;
89913 +
89914 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
89915 + old_len > pax_task_size || addr > pax_task_size-old_len)
89916 + return ret;
89917 +
89918 down_write(&current->mm->mmap_sem);
89919
89920 if (flags & MREMAP_FIXED) {
89921 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89922 new_addr = addr;
89923 }
89924 ret = addr;
89925 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
89926 goto out;
89927 }
89928 }
89929 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89930 goto out;
89931 }
89932
89933 + map_flags = vma->vm_flags;
89934 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
89935 + if (!(ret & ~PAGE_MASK)) {
89936 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
89937 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
89938 + }
89939 }
89940 out:
89941 if (ret & ~PAGE_MASK)
89942 diff --git a/mm/nommu.c b/mm/nommu.c
89943 index ecd1f15..77039bd 100644
89944 --- a/mm/nommu.c
89945 +++ b/mm/nommu.c
89946 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
89947 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
89948 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
89949 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
89950 -int heap_stack_gap = 0;
89951
89952 atomic_long_t mmap_pages_allocated;
89953
89954 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
89955 EXPORT_SYMBOL(find_vma);
89956
89957 /*
89958 - * find a VMA
89959 - * - we don't extend stack VMAs under NOMMU conditions
89960 - */
89961 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
89962 -{
89963 - return find_vma(mm, addr);
89964 -}
89965 -
89966 -/*
89967 * expand a stack to a given address
89968 * - not supported under NOMMU conditions
89969 */
89970 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89971
89972 /* most fields are the same, copy all, and then fixup */
89973 *new = *vma;
89974 + INIT_LIST_HEAD(&new->anon_vma_chain);
89975 *region = *vma->vm_region;
89976 new->vm_region = region;
89977
89978 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
89979 }
89980 EXPORT_SYMBOL(generic_file_remap_pages);
89981
89982 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89983 - unsigned long addr, void *buf, int len, int write)
89984 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89985 + unsigned long addr, void *buf, size_t len, int write)
89986 {
89987 struct vm_area_struct *vma;
89988
89989 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89990 *
89991 * The caller must hold a reference on @mm.
89992 */
89993 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89994 - void *buf, int len, int write)
89995 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89996 + void *buf, size_t len, int write)
89997 {
89998 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89999 }
90000 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90001 * Access another process' address space.
90002 * - source/target buffer must be kernel space
90003 */
90004 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
90005 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
90006 {
90007 struct mm_struct *mm;
90008
90009 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
90010 index 6380758..4064aec 100644
90011 --- a/mm/page-writeback.c
90012 +++ b/mm/page-writeback.c
90013 @@ -690,7 +690,7 @@ static inline long long pos_ratio_polynom(unsigned long setpoint,
90014 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
90015 * - the bdi dirty thresh drops quickly due to change of JBOD workload
90016 */
90017 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
90018 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
90019 unsigned long thresh,
90020 unsigned long bg_thresh,
90021 unsigned long dirty,
90022 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
90023 index dd886fa..7686339 100644
90024 --- a/mm/page_alloc.c
90025 +++ b/mm/page_alloc.c
90026 @@ -61,6 +61,7 @@
90027 #include <linux/page-debug-flags.h>
90028 #include <linux/hugetlb.h>
90029 #include <linux/sched/rt.h>
90030 +#include <linux/random.h>
90031
90032 #include <asm/sections.h>
90033 #include <asm/tlbflush.h>
90034 @@ -354,7 +355,7 @@ out:
90035 * This usage means that zero-order pages may not be compound.
90036 */
90037
90038 -static void free_compound_page(struct page *page)
90039 +void free_compound_page(struct page *page)
90040 {
90041 __free_pages_ok(page, compound_order(page));
90042 }
90043 @@ -712,6 +713,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90044 int i;
90045 int bad = 0;
90046
90047 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90048 + unsigned long index = 1UL << order;
90049 +#endif
90050 +
90051 trace_mm_page_free(page, order);
90052 kmemcheck_free_shadow(page, order);
90053
90054 @@ -728,6 +733,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90055 debug_check_no_obj_freed(page_address(page),
90056 PAGE_SIZE << order);
90057 }
90058 +
90059 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90060 + for (; index; --index)
90061 + sanitize_highpage(page + index - 1);
90062 +#endif
90063 +
90064 arch_free_page(page, order);
90065 kernel_map_pages(page, 1 << order, 0);
90066
90067 @@ -750,6 +761,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
90068 local_irq_restore(flags);
90069 }
90070
90071 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90072 +bool __meminitdata extra_latent_entropy;
90073 +
90074 +static int __init setup_pax_extra_latent_entropy(char *str)
90075 +{
90076 + extra_latent_entropy = true;
90077 + return 0;
90078 +}
90079 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
90080 +
90081 +volatile u64 latent_entropy __latent_entropy;
90082 +EXPORT_SYMBOL(latent_entropy);
90083 +#endif
90084 +
90085 void __init __free_pages_bootmem(struct page *page, unsigned int order)
90086 {
90087 unsigned int nr_pages = 1 << order;
90088 @@ -765,6 +790,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
90089 __ClearPageReserved(p);
90090 set_page_count(p, 0);
90091
90092 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90093 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
90094 + u64 hash = 0;
90095 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
90096 + const u64 *data = lowmem_page_address(page);
90097 +
90098 + for (index = 0; index < end; index++)
90099 + hash ^= hash + data[index];
90100 + latent_entropy ^= hash;
90101 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
90102 + }
90103 +#endif
90104 +
90105 page_zone(page)->managed_pages += nr_pages;
90106 set_page_refcounted(page);
90107 __free_pages(page, order);
90108 @@ -870,8 +908,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
90109 arch_alloc_page(page, order);
90110 kernel_map_pages(page, 1 << order, 1);
90111
90112 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
90113 if (gfp_flags & __GFP_ZERO)
90114 prep_zero_page(page, order, gfp_flags);
90115 +#endif
90116
90117 if (order && (gfp_flags & __GFP_COMP))
90118 prep_compound_page(page, order);
90119 diff --git a/mm/page_io.c b/mm/page_io.c
90120 index 8c79a47..a689e0d 100644
90121 --- a/mm/page_io.c
90122 +++ b/mm/page_io.c
90123 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
90124 struct file *swap_file = sis->swap_file;
90125 struct address_space *mapping = swap_file->f_mapping;
90126 struct iovec iov = {
90127 - .iov_base = kmap(page),
90128 + .iov_base = (void __force_user *)kmap(page),
90129 .iov_len = PAGE_SIZE,
90130 };
90131
90132 diff --git a/mm/percpu.c b/mm/percpu.c
90133 index 8c8e08f..73a5cda 100644
90134 --- a/mm/percpu.c
90135 +++ b/mm/percpu.c
90136 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
90137 static unsigned int pcpu_high_unit_cpu __read_mostly;
90138
90139 /* the address of the first chunk which starts with the kernel static area */
90140 -void *pcpu_base_addr __read_mostly;
90141 +void *pcpu_base_addr __read_only;
90142 EXPORT_SYMBOL_GPL(pcpu_base_addr);
90143
90144 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
90145 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
90146 index fd26d04..0cea1b0 100644
90147 --- a/mm/process_vm_access.c
90148 +++ b/mm/process_vm_access.c
90149 @@ -13,6 +13,7 @@
90150 #include <linux/uio.h>
90151 #include <linux/sched.h>
90152 #include <linux/highmem.h>
90153 +#include <linux/security.h>
90154 #include <linux/ptrace.h>
90155 #include <linux/slab.h>
90156 #include <linux/syscalls.h>
90157 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90158 size_t iov_l_curr_offset = 0;
90159 ssize_t iov_len;
90160
90161 + return -ENOSYS; // PaX: until properly audited
90162 +
90163 /*
90164 * Work out how many pages of struct pages we're going to need
90165 * when eventually calling get_user_pages
90166 */
90167 for (i = 0; i < riovcnt; i++) {
90168 iov_len = rvec[i].iov_len;
90169 - if (iov_len > 0) {
90170 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
90171 - + iov_len)
90172 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
90173 - / PAGE_SIZE + 1;
90174 - nr_pages = max(nr_pages, nr_pages_iov);
90175 - }
90176 + if (iov_len <= 0)
90177 + continue;
90178 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
90179 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
90180 + nr_pages = max(nr_pages, nr_pages_iov);
90181 }
90182
90183 if (nr_pages == 0)
90184 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90185 goto free_proc_pages;
90186 }
90187
90188 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
90189 + rc = -EPERM;
90190 + goto put_task_struct;
90191 + }
90192 +
90193 mm = mm_access(task, PTRACE_MODE_ATTACH);
90194 if (!mm || IS_ERR(mm)) {
90195 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
90196 diff --git a/mm/rmap.c b/mm/rmap.c
90197 index fd3ee7a..3613079 100644
90198 --- a/mm/rmap.c
90199 +++ b/mm/rmap.c
90200 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90201 struct anon_vma *anon_vma = vma->anon_vma;
90202 struct anon_vma_chain *avc;
90203
90204 +#ifdef CONFIG_PAX_SEGMEXEC
90205 + struct anon_vma_chain *avc_m = NULL;
90206 +#endif
90207 +
90208 might_sleep();
90209 if (unlikely(!anon_vma)) {
90210 struct mm_struct *mm = vma->vm_mm;
90211 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90212 if (!avc)
90213 goto out_enomem;
90214
90215 +#ifdef CONFIG_PAX_SEGMEXEC
90216 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
90217 + if (!avc_m)
90218 + goto out_enomem_free_avc;
90219 +#endif
90220 +
90221 anon_vma = find_mergeable_anon_vma(vma);
90222 allocated = NULL;
90223 if (!anon_vma) {
90224 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90225 /* page_table_lock to protect against threads */
90226 spin_lock(&mm->page_table_lock);
90227 if (likely(!vma->anon_vma)) {
90228 +
90229 +#ifdef CONFIG_PAX_SEGMEXEC
90230 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
90231 +
90232 + if (vma_m) {
90233 + BUG_ON(vma_m->anon_vma);
90234 + vma_m->anon_vma = anon_vma;
90235 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
90236 + avc_m = NULL;
90237 + }
90238 +#endif
90239 +
90240 vma->anon_vma = anon_vma;
90241 anon_vma_chain_link(vma, avc, anon_vma);
90242 allocated = NULL;
90243 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90244
90245 if (unlikely(allocated))
90246 put_anon_vma(allocated);
90247 +
90248 +#ifdef CONFIG_PAX_SEGMEXEC
90249 + if (unlikely(avc_m))
90250 + anon_vma_chain_free(avc_m);
90251 +#endif
90252 +
90253 if (unlikely(avc))
90254 anon_vma_chain_free(avc);
90255 }
90256 return 0;
90257
90258 out_enomem_free_avc:
90259 +
90260 +#ifdef CONFIG_PAX_SEGMEXEC
90261 + if (avc_m)
90262 + anon_vma_chain_free(avc_m);
90263 +#endif
90264 +
90265 anon_vma_chain_free(avc);
90266 out_enomem:
90267 return -ENOMEM;
90268 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
90269 * Attach the anon_vmas from src to dst.
90270 * Returns 0 on success, -ENOMEM on failure.
90271 */
90272 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90273 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
90274 {
90275 struct anon_vma_chain *avc, *pavc;
90276 struct anon_vma *root = NULL;
90277 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90278 * the corresponding VMA in the parent process is attached to.
90279 * Returns 0 on success, non-zero on failure.
90280 */
90281 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
90282 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
90283 {
90284 struct anon_vma_chain *avc;
90285 struct anon_vma *anon_vma;
90286 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
90287 void __init anon_vma_init(void)
90288 {
90289 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
90290 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
90291 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
90292 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
90293 + anon_vma_ctor);
90294 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
90295 + SLAB_PANIC|SLAB_NO_SANITIZE);
90296 }
90297
90298 /*
90299 diff --git a/mm/shmem.c b/mm/shmem.c
90300 index 8297623..6b9dfe9 100644
90301 --- a/mm/shmem.c
90302 +++ b/mm/shmem.c
90303 @@ -33,7 +33,7 @@
90304 #include <linux/swap.h>
90305 #include <linux/aio.h>
90306
90307 -static struct vfsmount *shm_mnt;
90308 +struct vfsmount *shm_mnt;
90309
90310 #ifdef CONFIG_SHMEM
90311 /*
90312 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
90313 #define BOGO_DIRENT_SIZE 20
90314
90315 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
90316 -#define SHORT_SYMLINK_LEN 128
90317 +#define SHORT_SYMLINK_LEN 64
90318
90319 /*
90320 * shmem_fallocate and shmem_writepage communicate via inode->i_private
90321 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
90322 static int shmem_xattr_validate(const char *name)
90323 {
90324 struct { const char *prefix; size_t len; } arr[] = {
90325 +
90326 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90327 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
90328 +#endif
90329 +
90330 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
90331 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
90332 };
90333 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
90334 if (err)
90335 return err;
90336
90337 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90338 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
90339 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
90340 + return -EOPNOTSUPP;
90341 + if (size > 8)
90342 + return -EINVAL;
90343 + }
90344 +#endif
90345 +
90346 return simple_xattr_set(&info->xattrs, name, value, size, flags);
90347 }
90348
90349 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
90350 int err = -ENOMEM;
90351
90352 /* Round up to L1_CACHE_BYTES to resist false sharing */
90353 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
90354 - L1_CACHE_BYTES), GFP_KERNEL);
90355 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
90356 if (!sbinfo)
90357 return -ENOMEM;
90358
90359 diff --git a/mm/slab.c b/mm/slab.c
90360 index 2580db0..0523956 100644
90361 --- a/mm/slab.c
90362 +++ b/mm/slab.c
90363 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90364 if ((x)->max_freeable < i) \
90365 (x)->max_freeable = i; \
90366 } while (0)
90367 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
90368 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
90369 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
90370 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
90371 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
90372 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
90373 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
90374 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
90375 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
90376 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
90377 #else
90378 #define STATS_INC_ACTIVE(x) do { } while (0)
90379 #define STATS_DEC_ACTIVE(x) do { } while (0)
90380 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90381 #define STATS_INC_ALLOCMISS(x) do { } while (0)
90382 #define STATS_INC_FREEHIT(x) do { } while (0)
90383 #define STATS_INC_FREEMISS(x) do { } while (0)
90384 +#define STATS_INC_SANITIZED(x) do { } while (0)
90385 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
90386 #endif
90387
90388 #if DEBUG
90389 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
90390 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
90391 */
90392 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
90393 - const struct slab *slab, void *obj)
90394 + const struct slab *slab, const void *obj)
90395 {
90396 u32 offset = (obj - slab->s_mem);
90397 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
90398 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
90399 */
90400
90401 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
90402 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
90403 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90404
90405 if (INDEX_AC != INDEX_NODE)
90406 kmalloc_caches[INDEX_NODE] =
90407 create_kmalloc_cache("kmalloc-node",
90408 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
90409 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90410
90411 slab_early_init = 0;
90412
90413 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
90414 struct array_cache *ac = cpu_cache_get(cachep);
90415
90416 check_irq_off();
90417 +
90418 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90419 + if (pax_sanitize_slab) {
90420 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
90421 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
90422 +
90423 + if (cachep->ctor)
90424 + cachep->ctor(objp);
90425 +
90426 + STATS_INC_SANITIZED(cachep);
90427 + } else
90428 + STATS_INC_NOT_SANITIZED(cachep);
90429 + }
90430 +#endif
90431 +
90432 kmemleak_free_recursive(objp, cachep->flags);
90433 objp = cache_free_debugcheck(cachep, objp, caller);
90434
90435 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
90436
90437 if (unlikely(ZERO_OR_NULL_PTR(objp)))
90438 return;
90439 + VM_BUG_ON(!virt_addr_valid(objp));
90440 local_irq_save(flags);
90441 kfree_debugcheck(objp);
90442 c = virt_to_cache(objp);
90443 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
90444 }
90445 /* cpu stats */
90446 {
90447 - unsigned long allochit = atomic_read(&cachep->allochit);
90448 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
90449 - unsigned long freehit = atomic_read(&cachep->freehit);
90450 - unsigned long freemiss = atomic_read(&cachep->freemiss);
90451 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
90452 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
90453 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
90454 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
90455
90456 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
90457 allochit, allocmiss, freehit, freemiss);
90458 }
90459 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90460 + {
90461 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
90462 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
90463 +
90464 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
90465 + }
90466 +#endif
90467 #endif
90468 }
90469
90470 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
90471 static int __init slab_proc_init(void)
90472 {
90473 #ifdef CONFIG_DEBUG_SLAB_LEAK
90474 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
90475 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
90476 #endif
90477 return 0;
90478 }
90479 module_init(slab_proc_init);
90480 #endif
90481
90482 +bool is_usercopy_object(const void *ptr)
90483 +{
90484 + struct page *page;
90485 + struct kmem_cache *cachep;
90486 +
90487 + if (ZERO_OR_NULL_PTR(ptr))
90488 + return false;
90489 +
90490 + if (!slab_is_available())
90491 + return false;
90492 +
90493 + if (!virt_addr_valid(ptr))
90494 + return false;
90495 +
90496 + page = virt_to_head_page(ptr);
90497 +
90498 + if (!PageSlab(page))
90499 + return false;
90500 +
90501 + cachep = page->slab_cache;
90502 + return cachep->flags & SLAB_USERCOPY;
90503 +}
90504 +
90505 +#ifdef CONFIG_PAX_USERCOPY
90506 +const char *check_heap_object(const void *ptr, unsigned long n)
90507 +{
90508 + struct page *page;
90509 + struct kmem_cache *cachep;
90510 + struct slab *slabp;
90511 + unsigned int objnr;
90512 + unsigned long offset;
90513 +
90514 + if (ZERO_OR_NULL_PTR(ptr))
90515 + return "<null>";
90516 +
90517 + if (!virt_addr_valid(ptr))
90518 + return NULL;
90519 +
90520 + page = virt_to_head_page(ptr);
90521 +
90522 + if (!PageSlab(page))
90523 + return NULL;
90524 +
90525 + cachep = page->slab_cache;
90526 + if (!(cachep->flags & SLAB_USERCOPY))
90527 + return cachep->name;
90528 +
90529 + slabp = page->slab_page;
90530 + objnr = obj_to_index(cachep, slabp, ptr);
90531 + BUG_ON(objnr >= cachep->num);
90532 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
90533 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
90534 + return NULL;
90535 +
90536 + return cachep->name;
90537 +}
90538 +#endif
90539 +
90540 /**
90541 * ksize - get the actual amount of memory allocated for a given object
90542 * @objp: Pointer to the object
90543 diff --git a/mm/slab.h b/mm/slab.h
90544 index a535033..2f98fe5 100644
90545 --- a/mm/slab.h
90546 +++ b/mm/slab.h
90547 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
90548 /* The slab cache that manages slab cache information */
90549 extern struct kmem_cache *kmem_cache;
90550
90551 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90552 +#ifdef CONFIG_X86_64
90553 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
90554 +#else
90555 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
90556 +#endif
90557 +extern bool pax_sanitize_slab;
90558 +#endif
90559 +
90560 unsigned long calculate_alignment(unsigned long flags,
90561 unsigned long align, unsigned long size);
90562
90563 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90564
90565 /* Legal flag mask for kmem_cache_create(), for various configurations */
90566 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
90567 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
90568 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
90569 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
90570
90571 #if defined(CONFIG_DEBUG_SLAB)
90572 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
90573 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
90574 return s;
90575
90576 page = virt_to_head_page(x);
90577 +
90578 + BUG_ON(!PageSlab(page));
90579 +
90580 cachep = page->slab_cache;
90581 if (slab_equal_or_root(cachep, s))
90582 return cachep;
90583 diff --git a/mm/slab_common.c b/mm/slab_common.c
90584 index e2e98af..3b1a163 100644
90585 --- a/mm/slab_common.c
90586 +++ b/mm/slab_common.c
90587 @@ -23,11 +23,22 @@
90588
90589 #include "slab.h"
90590
90591 -enum slab_state slab_state;
90592 +enum slab_state slab_state __read_only;
90593 LIST_HEAD(slab_caches);
90594 DEFINE_MUTEX(slab_mutex);
90595 struct kmem_cache *kmem_cache;
90596
90597 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90598 +bool pax_sanitize_slab __read_only = true;
90599 +static int __init pax_sanitize_slab_setup(char *str)
90600 +{
90601 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
90602 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
90603 + return 1;
90604 +}
90605 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
90606 +#endif
90607 +
90608 #ifdef CONFIG_DEBUG_VM
90609 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
90610 size_t size)
90611 @@ -212,7 +223,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
90612
90613 err = __kmem_cache_create(s, flags);
90614 if (!err) {
90615 - s->refcount = 1;
90616 + atomic_set(&s->refcount, 1);
90617 list_add(&s->list, &slab_caches);
90618 memcg_cache_list_add(memcg, s);
90619 } else {
90620 @@ -258,8 +269,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
90621
90622 get_online_cpus();
90623 mutex_lock(&slab_mutex);
90624 - s->refcount--;
90625 - if (!s->refcount) {
90626 + if (atomic_dec_and_test(&s->refcount)) {
90627 list_del(&s->list);
90628
90629 if (!__kmem_cache_shutdown(s)) {
90630 @@ -305,7 +315,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
90631 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
90632 name, size, err);
90633
90634 - s->refcount = -1; /* Exempt from merging for now */
90635 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
90636 }
90637
90638 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90639 @@ -318,7 +328,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90640
90641 create_boot_cache(s, name, size, flags);
90642 list_add(&s->list, &slab_caches);
90643 - s->refcount = 1;
90644 + atomic_set(&s->refcount, 1);
90645 return s;
90646 }
90647
90648 @@ -330,6 +340,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
90649 EXPORT_SYMBOL(kmalloc_dma_caches);
90650 #endif
90651
90652 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90653 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
90654 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
90655 +#endif
90656 +
90657 /*
90658 * Conversion table for small slabs sizes / 8 to the index in the
90659 * kmalloc array. This is necessary for slabs < 192 since we have non power
90660 @@ -394,6 +409,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
90661 return kmalloc_dma_caches[index];
90662
90663 #endif
90664 +
90665 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90666 + if (unlikely((flags & GFP_USERCOPY)))
90667 + return kmalloc_usercopy_caches[index];
90668 +
90669 +#endif
90670 +
90671 return kmalloc_caches[index];
90672 }
90673
90674 @@ -450,7 +472,7 @@ void __init create_kmalloc_caches(unsigned long flags)
90675 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
90676 if (!kmalloc_caches[i]) {
90677 kmalloc_caches[i] = create_kmalloc_cache(NULL,
90678 - 1 << i, flags);
90679 + 1 << i, SLAB_USERCOPY | flags);
90680 }
90681
90682 /*
90683 @@ -459,10 +481,10 @@ void __init create_kmalloc_caches(unsigned long flags)
90684 * earlier power of two caches
90685 */
90686 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
90687 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
90688 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
90689
90690 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
90691 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
90692 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
90693 }
90694
90695 /* Kmalloc array is now usable */
90696 @@ -495,6 +517,23 @@ void __init create_kmalloc_caches(unsigned long flags)
90697 }
90698 }
90699 #endif
90700 +
90701 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90702 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
90703 + struct kmem_cache *s = kmalloc_caches[i];
90704 +
90705 + if (s) {
90706 + int size = kmalloc_size(i);
90707 + char *n = kasprintf(GFP_NOWAIT,
90708 + "usercopy-kmalloc-%d", size);
90709 +
90710 + BUG_ON(!n);
90711 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
90712 + size, SLAB_USERCOPY | flags);
90713 + }
90714 + }
90715 +#endif
90716 +
90717 }
90718 #endif /* !CONFIG_SLOB */
90719
90720 @@ -535,6 +574,9 @@ void print_slabinfo_header(struct seq_file *m)
90721 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
90722 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
90723 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
90724 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90725 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
90726 +#endif
90727 #endif
90728 seq_putc(m, '\n');
90729 }
90730 diff --git a/mm/slob.c b/mm/slob.c
90731 index 4bf8809..98a6914 100644
90732 --- a/mm/slob.c
90733 +++ b/mm/slob.c
90734 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
90735 /*
90736 * Return the size of a slob block.
90737 */
90738 -static slobidx_t slob_units(slob_t *s)
90739 +static slobidx_t slob_units(const slob_t *s)
90740 {
90741 if (s->units > 0)
90742 return s->units;
90743 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
90744 /*
90745 * Return the next free slob block pointer after this one.
90746 */
90747 -static slob_t *slob_next(slob_t *s)
90748 +static slob_t *slob_next(const slob_t *s)
90749 {
90750 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
90751 slobidx_t next;
90752 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
90753 /*
90754 * Returns true if s is the last free block in its page.
90755 */
90756 -static int slob_last(slob_t *s)
90757 +static int slob_last(const slob_t *s)
90758 {
90759 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
90760 }
90761
90762 -static void *slob_new_pages(gfp_t gfp, int order, int node)
90763 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
90764 {
90765 - void *page;
90766 + struct page *page;
90767
90768 #ifdef CONFIG_NUMA
90769 if (node != NUMA_NO_NODE)
90770 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
90771 if (!page)
90772 return NULL;
90773
90774 - return page_address(page);
90775 + __SetPageSlab(page);
90776 + return page;
90777 }
90778
90779 -static void slob_free_pages(void *b, int order)
90780 +static void slob_free_pages(struct page *sp, int order)
90781 {
90782 if (current->reclaim_state)
90783 current->reclaim_state->reclaimed_slab += 1 << order;
90784 - free_pages((unsigned long)b, order);
90785 + __ClearPageSlab(sp);
90786 + page_mapcount_reset(sp);
90787 + sp->private = 0;
90788 + __free_pages(sp, order);
90789 }
90790
90791 /*
90792 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
90793
90794 /* Not enough space: must allocate a new page */
90795 if (!b) {
90796 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90797 - if (!b)
90798 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90799 + if (!sp)
90800 return NULL;
90801 - sp = virt_to_page(b);
90802 - __SetPageSlab(sp);
90803 + b = page_address(sp);
90804
90805 spin_lock_irqsave(&slob_lock, flags);
90806 sp->units = SLOB_UNITS(PAGE_SIZE);
90807 sp->freelist = b;
90808 + sp->private = 0;
90809 INIT_LIST_HEAD(&sp->list);
90810 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
90811 set_slob_page_free(sp, slob_list);
90812 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
90813 if (slob_page_free(sp))
90814 clear_slob_page_free(sp);
90815 spin_unlock_irqrestore(&slob_lock, flags);
90816 - __ClearPageSlab(sp);
90817 - page_mapcount_reset(sp);
90818 - slob_free_pages(b, 0);
90819 + slob_free_pages(sp, 0);
90820 return;
90821 }
90822
90823 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90824 + if (pax_sanitize_slab)
90825 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
90826 +#endif
90827 +
90828 if (!slob_page_free(sp)) {
90829 /* This slob page is about to become partially free. Easy! */
90830 sp->units = units;
90831 @@ -424,11 +431,10 @@ out:
90832 */
90833
90834 static __always_inline void *
90835 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90836 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
90837 {
90838 - unsigned int *m;
90839 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90840 - void *ret;
90841 + slob_t *m;
90842 + void *ret = NULL;
90843
90844 gfp &= gfp_allowed_mask;
90845
90846 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90847
90848 if (!m)
90849 return NULL;
90850 - *m = size;
90851 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
90852 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
90853 + m[0].units = size;
90854 + m[1].units = align;
90855 ret = (void *)m + align;
90856
90857 trace_kmalloc_node(caller, ret,
90858 size, size + align, gfp, node);
90859 } else {
90860 unsigned int order = get_order(size);
90861 + struct page *page;
90862
90863 if (likely(order))
90864 gfp |= __GFP_COMP;
90865 - ret = slob_new_pages(gfp, order, node);
90866 + page = slob_new_pages(gfp, order, node);
90867 + if (page) {
90868 + ret = page_address(page);
90869 + page->private = size;
90870 + }
90871
90872 trace_kmalloc_node(caller, ret,
90873 size, PAGE_SIZE << order, gfp, node);
90874 }
90875
90876 - kmemleak_alloc(ret, size, 1, gfp);
90877 + return ret;
90878 +}
90879 +
90880 +static __always_inline void *
90881 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
90882 +{
90883 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90884 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
90885 +
90886 + if (!ZERO_OR_NULL_PTR(ret))
90887 + kmemleak_alloc(ret, size, 1, gfp);
90888 return ret;
90889 }
90890
90891 @@ -493,34 +517,112 @@ void kfree(const void *block)
90892 return;
90893 kmemleak_free(block);
90894
90895 + VM_BUG_ON(!virt_addr_valid(block));
90896 sp = virt_to_page(block);
90897 - if (PageSlab(sp)) {
90898 + VM_BUG_ON(!PageSlab(sp));
90899 + if (!sp->private) {
90900 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90901 - unsigned int *m = (unsigned int *)(block - align);
90902 - slob_free(m, *m + align);
90903 - } else
90904 + slob_t *m = (slob_t *)(block - align);
90905 + slob_free(m, m[0].units + align);
90906 + } else {
90907 + __ClearPageSlab(sp);
90908 + page_mapcount_reset(sp);
90909 + sp->private = 0;
90910 __free_pages(sp, compound_order(sp));
90911 + }
90912 }
90913 EXPORT_SYMBOL(kfree);
90914
90915 +bool is_usercopy_object(const void *ptr)
90916 +{
90917 + if (!slab_is_available())
90918 + return false;
90919 +
90920 + // PAX: TODO
90921 +
90922 + return false;
90923 +}
90924 +
90925 +#ifdef CONFIG_PAX_USERCOPY
90926 +const char *check_heap_object(const void *ptr, unsigned long n)
90927 +{
90928 + struct page *page;
90929 + const slob_t *free;
90930 + const void *base;
90931 + unsigned long flags;
90932 +
90933 + if (ZERO_OR_NULL_PTR(ptr))
90934 + return "<null>";
90935 +
90936 + if (!virt_addr_valid(ptr))
90937 + return NULL;
90938 +
90939 + page = virt_to_head_page(ptr);
90940 + if (!PageSlab(page))
90941 + return NULL;
90942 +
90943 + if (page->private) {
90944 + base = page;
90945 + if (base <= ptr && n <= page->private - (ptr - base))
90946 + return NULL;
90947 + return "<slob>";
90948 + }
90949 +
90950 + /* some tricky double walking to find the chunk */
90951 + spin_lock_irqsave(&slob_lock, flags);
90952 + base = (void *)((unsigned long)ptr & PAGE_MASK);
90953 + free = page->freelist;
90954 +
90955 + while (!slob_last(free) && (void *)free <= ptr) {
90956 + base = free + slob_units(free);
90957 + free = slob_next(free);
90958 + }
90959 +
90960 + while (base < (void *)free) {
90961 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
90962 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
90963 + int offset;
90964 +
90965 + if (ptr < base + align)
90966 + break;
90967 +
90968 + offset = ptr - base - align;
90969 + if (offset >= m) {
90970 + base += size;
90971 + continue;
90972 + }
90973 +
90974 + if (n > m - offset)
90975 + break;
90976 +
90977 + spin_unlock_irqrestore(&slob_lock, flags);
90978 + return NULL;
90979 + }
90980 +
90981 + spin_unlock_irqrestore(&slob_lock, flags);
90982 + return "<slob>";
90983 +}
90984 +#endif
90985 +
90986 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
90987 size_t ksize(const void *block)
90988 {
90989 struct page *sp;
90990 int align;
90991 - unsigned int *m;
90992 + slob_t *m;
90993
90994 BUG_ON(!block);
90995 if (unlikely(block == ZERO_SIZE_PTR))
90996 return 0;
90997
90998 sp = virt_to_page(block);
90999 - if (unlikely(!PageSlab(sp)))
91000 - return PAGE_SIZE << compound_order(sp);
91001 + VM_BUG_ON(!PageSlab(sp));
91002 + if (sp->private)
91003 + return sp->private;
91004
91005 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91006 - m = (unsigned int *)(block - align);
91007 - return SLOB_UNITS(*m) * SLOB_UNIT;
91008 + m = (slob_t *)(block - align);
91009 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
91010 }
91011 EXPORT_SYMBOL(ksize);
91012
91013 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
91014
91015 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
91016 {
91017 - void *b;
91018 + void *b = NULL;
91019
91020 flags &= gfp_allowed_mask;
91021
91022 lockdep_trace_alloc(flags);
91023
91024 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91025 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
91026 +#else
91027 if (c->size < PAGE_SIZE) {
91028 b = slob_alloc(c->size, flags, c->align, node);
91029 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91030 SLOB_UNITS(c->size) * SLOB_UNIT,
91031 flags, node);
91032 } else {
91033 - b = slob_new_pages(flags, get_order(c->size), node);
91034 + struct page *sp;
91035 +
91036 + sp = slob_new_pages(flags, get_order(c->size), node);
91037 + if (sp) {
91038 + b = page_address(sp);
91039 + sp->private = c->size;
91040 + }
91041 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91042 PAGE_SIZE << get_order(c->size),
91043 flags, node);
91044 }
91045 +#endif
91046
91047 if (b && c->ctor)
91048 c->ctor(b);
91049 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
91050
91051 static void __kmem_cache_free(void *b, int size)
91052 {
91053 - if (size < PAGE_SIZE)
91054 + struct page *sp;
91055 +
91056 + sp = virt_to_page(b);
91057 + BUG_ON(!PageSlab(sp));
91058 + if (!sp->private)
91059 slob_free(b, size);
91060 else
91061 - slob_free_pages(b, get_order(size));
91062 + slob_free_pages(sp, get_order(size));
91063 }
91064
91065 static void kmem_rcu_free(struct rcu_head *head)
91066 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
91067
91068 void kmem_cache_free(struct kmem_cache *c, void *b)
91069 {
91070 + int size = c->size;
91071 +
91072 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91073 + if (size + c->align < PAGE_SIZE) {
91074 + size += c->align;
91075 + b -= c->align;
91076 + }
91077 +#endif
91078 +
91079 kmemleak_free_recursive(b, c->flags);
91080 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
91081 struct slob_rcu *slob_rcu;
91082 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
91083 - slob_rcu->size = c->size;
91084 + slob_rcu = b + (size - sizeof(struct slob_rcu));
91085 + slob_rcu->size = size;
91086 call_rcu(&slob_rcu->head, kmem_rcu_free);
91087 } else {
91088 - __kmem_cache_free(b, c->size);
91089 + __kmem_cache_free(b, size);
91090 }
91091
91092 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91093 + trace_kfree(_RET_IP_, b);
91094 +#else
91095 trace_kmem_cache_free(_RET_IP_, b);
91096 +#endif
91097 +
91098 }
91099 EXPORT_SYMBOL(kmem_cache_free);
91100
91101 diff --git a/mm/slub.c b/mm/slub.c
91102 index c3eb3d3..022c9fa 100644
91103 --- a/mm/slub.c
91104 +++ b/mm/slub.c
91105 @@ -207,7 +207,7 @@ struct track {
91106
91107 enum track_item { TRACK_ALLOC, TRACK_FREE };
91108
91109 -#ifdef CONFIG_SYSFS
91110 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91111 static int sysfs_slab_add(struct kmem_cache *);
91112 static int sysfs_slab_alias(struct kmem_cache *, const char *);
91113 static void sysfs_slab_remove(struct kmem_cache *);
91114 @@ -530,7 +530,7 @@ static void print_track(const char *s, struct track *t)
91115 if (!t->addr)
91116 return;
91117
91118 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
91119 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
91120 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
91121 #ifdef CONFIG_STACKTRACE
91122 {
91123 @@ -2616,6 +2616,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
91124
91125 slab_free_hook(s, x);
91126
91127 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91128 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
91129 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
91130 + if (s->ctor)
91131 + s->ctor(x);
91132 + }
91133 +#endif
91134 +
91135 redo:
91136 /*
91137 * Determine the currently cpus per cpu slab.
91138 @@ -2683,7 +2691,7 @@ static int slub_min_objects;
91139 * Merge control. If this is set then no merging of slab caches will occur.
91140 * (Could be removed. This was introduced to pacify the merge skeptics.)
91141 */
91142 -static int slub_nomerge;
91143 +static int slub_nomerge = 1;
91144
91145 /*
91146 * Calculate the order of allocation given an slab object size.
91147 @@ -2960,6 +2968,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
91148 s->inuse = size;
91149
91150 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
91151 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91152 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
91153 +#endif
91154 s->ctor)) {
91155 /*
91156 * Relocate free pointer after the object if it is not
91157 @@ -3305,6 +3316,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
91158 EXPORT_SYMBOL(__kmalloc_node);
91159 #endif
91160
91161 +bool is_usercopy_object(const void *ptr)
91162 +{
91163 + struct page *page;
91164 + struct kmem_cache *s;
91165 +
91166 + if (ZERO_OR_NULL_PTR(ptr))
91167 + return false;
91168 +
91169 + if (!slab_is_available())
91170 + return false;
91171 +
91172 + if (!virt_addr_valid(ptr))
91173 + return false;
91174 +
91175 + page = virt_to_head_page(ptr);
91176 +
91177 + if (!PageSlab(page))
91178 + return false;
91179 +
91180 + s = page->slab_cache;
91181 + return s->flags & SLAB_USERCOPY;
91182 +}
91183 +
91184 +#ifdef CONFIG_PAX_USERCOPY
91185 +const char *check_heap_object(const void *ptr, unsigned long n)
91186 +{
91187 + struct page *page;
91188 + struct kmem_cache *s;
91189 + unsigned long offset;
91190 +
91191 + if (ZERO_OR_NULL_PTR(ptr))
91192 + return "<null>";
91193 +
91194 + if (!virt_addr_valid(ptr))
91195 + return NULL;
91196 +
91197 + page = virt_to_head_page(ptr);
91198 +
91199 + if (!PageSlab(page))
91200 + return NULL;
91201 +
91202 + s = page->slab_cache;
91203 + if (!(s->flags & SLAB_USERCOPY))
91204 + return s->name;
91205 +
91206 + offset = (ptr - page_address(page)) % s->size;
91207 + if (offset <= s->object_size && n <= s->object_size - offset)
91208 + return NULL;
91209 +
91210 + return s->name;
91211 +}
91212 +#endif
91213 +
91214 size_t ksize(const void *object)
91215 {
91216 struct page *page;
91217 @@ -3333,6 +3397,7 @@ void kfree(const void *x)
91218 if (unlikely(ZERO_OR_NULL_PTR(x)))
91219 return;
91220
91221 + VM_BUG_ON(!virt_addr_valid(x));
91222 page = virt_to_head_page(x);
91223 if (unlikely(!PageSlab(page))) {
91224 BUG_ON(!PageCompound(page));
91225 @@ -3638,7 +3703,7 @@ static int slab_unmergeable(struct kmem_cache *s)
91226 /*
91227 * We may have set a slab to be unmergeable during bootstrap.
91228 */
91229 - if (s->refcount < 0)
91230 + if (atomic_read(&s->refcount) < 0)
91231 return 1;
91232
91233 return 0;
91234 @@ -3696,7 +3761,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91235
91236 s = find_mergeable(memcg, size, align, flags, name, ctor);
91237 if (s) {
91238 - s->refcount++;
91239 + atomic_inc(&s->refcount);
91240 /*
91241 * Adjust the object sizes so that we clear
91242 * the complete object on kzalloc.
91243 @@ -3705,7 +3770,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91244 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
91245
91246 if (sysfs_slab_alias(s, name)) {
91247 - s->refcount--;
91248 + atomic_dec(&s->refcount);
91249 s = NULL;
91250 }
91251 }
91252 @@ -3825,7 +3890,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
91253 }
91254 #endif
91255
91256 -#ifdef CONFIG_SYSFS
91257 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91258 static int count_inuse(struct page *page)
91259 {
91260 return page->inuse;
91261 @@ -4214,12 +4279,12 @@ static void resiliency_test(void)
91262 validate_slab_cache(kmalloc_caches[9]);
91263 }
91264 #else
91265 -#ifdef CONFIG_SYSFS
91266 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91267 static void resiliency_test(void) {};
91268 #endif
91269 #endif
91270
91271 -#ifdef CONFIG_SYSFS
91272 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91273 enum slab_stat_type {
91274 SL_ALL, /* All slabs */
91275 SL_PARTIAL, /* Only partially allocated slabs */
91276 @@ -4459,7 +4524,7 @@ SLAB_ATTR_RO(ctor);
91277
91278 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
91279 {
91280 - return sprintf(buf, "%d\n", s->refcount - 1);
91281 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
91282 }
91283 SLAB_ATTR_RO(aliases);
91284
91285 @@ -4547,6 +4612,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
91286 SLAB_ATTR_RO(cache_dma);
91287 #endif
91288
91289 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91290 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
91291 +{
91292 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
91293 +}
91294 +SLAB_ATTR_RO(usercopy);
91295 +#endif
91296 +
91297 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
91298 {
91299 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
91300 @@ -4881,6 +4954,9 @@ static struct attribute *slab_attrs[] = {
91301 #ifdef CONFIG_ZONE_DMA
91302 &cache_dma_attr.attr,
91303 #endif
91304 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91305 + &usercopy_attr.attr,
91306 +#endif
91307 #ifdef CONFIG_NUMA
91308 &remote_node_defrag_ratio_attr.attr,
91309 #endif
91310 @@ -5113,6 +5189,7 @@ static char *create_unique_id(struct kmem_cache *s)
91311 return name;
91312 }
91313
91314 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91315 static int sysfs_slab_add(struct kmem_cache *s)
91316 {
91317 int err;
91318 @@ -5136,7 +5213,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
91319 }
91320
91321 s->kobj.kset = slab_kset;
91322 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
91323 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
91324 if (err) {
91325 kobject_put(&s->kobj);
91326 return err;
91327 @@ -5170,6 +5247,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
91328 kobject_del(&s->kobj);
91329 kobject_put(&s->kobj);
91330 }
91331 +#endif
91332
91333 /*
91334 * Need to buffer aliases during bootup until sysfs becomes
91335 @@ -5183,6 +5261,7 @@ struct saved_alias {
91336
91337 static struct saved_alias *alias_list;
91338
91339 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91340 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91341 {
91342 struct saved_alias *al;
91343 @@ -5205,6 +5284,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91344 alias_list = al;
91345 return 0;
91346 }
91347 +#endif
91348
91349 static int __init slab_sysfs_init(void)
91350 {
91351 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
91352 index 27eeab3..7c3f7f2 100644
91353 --- a/mm/sparse-vmemmap.c
91354 +++ b/mm/sparse-vmemmap.c
91355 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
91356 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91357 if (!p)
91358 return NULL;
91359 - pud_populate(&init_mm, pud, p);
91360 + pud_populate_kernel(&init_mm, pud, p);
91361 }
91362 return pud;
91363 }
91364 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
91365 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91366 if (!p)
91367 return NULL;
91368 - pgd_populate(&init_mm, pgd, p);
91369 + pgd_populate_kernel(&init_mm, pgd, p);
91370 }
91371 return pgd;
91372 }
91373 diff --git a/mm/sparse.c b/mm/sparse.c
91374 index 4ac1d7e..bbfcb1f 100644
91375 --- a/mm/sparse.c
91376 +++ b/mm/sparse.c
91377 @@ -745,7 +745,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
91378
91379 for (i = 0; i < PAGES_PER_SECTION; i++) {
91380 if (PageHWPoison(&memmap[i])) {
91381 - atomic_long_sub(1, &num_poisoned_pages);
91382 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
91383 ClearPageHWPoison(&memmap[i]);
91384 }
91385 }
91386 diff --git a/mm/swap.c b/mm/swap.c
91387 index 759c3ca..7c1a5b4 100644
91388 --- a/mm/swap.c
91389 +++ b/mm/swap.c
91390 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
91391
91392 __page_cache_release(page);
91393 dtor = get_compound_page_dtor(page);
91394 + if (!PageHuge(page))
91395 + BUG_ON(dtor != free_compound_page);
91396 (*dtor)(page);
91397 }
91398
91399 diff --git a/mm/swapfile.c b/mm/swapfile.c
91400 index de7c904..c84bf11 100644
91401 --- a/mm/swapfile.c
91402 +++ b/mm/swapfile.c
91403 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
91404
91405 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
91406 /* Activity counter to indicate that a swapon or swapoff has occurred */
91407 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
91408 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
91409
91410 static inline unsigned char swap_count(unsigned char ent)
91411 {
91412 @@ -1949,7 +1949,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
91413 }
91414 filp_close(swap_file, NULL);
91415 err = 0;
91416 - atomic_inc(&proc_poll_event);
91417 + atomic_inc_unchecked(&proc_poll_event);
91418 wake_up_interruptible(&proc_poll_wait);
91419
91420 out_dput:
91421 @@ -1966,8 +1966,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
91422
91423 poll_wait(file, &proc_poll_wait, wait);
91424
91425 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
91426 - seq->poll_event = atomic_read(&proc_poll_event);
91427 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
91428 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91429 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
91430 }
91431
91432 @@ -2065,7 +2065,7 @@ static int swaps_open(struct inode *inode, struct file *file)
91433 return ret;
91434
91435 seq = file->private_data;
91436 - seq->poll_event = atomic_read(&proc_poll_event);
91437 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91438 return 0;
91439 }
91440
91441 @@ -2524,7 +2524,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
91442 (frontswap_map) ? "FS" : "");
91443
91444 mutex_unlock(&swapon_mutex);
91445 - atomic_inc(&proc_poll_event);
91446 + atomic_inc_unchecked(&proc_poll_event);
91447 wake_up_interruptible(&proc_poll_wait);
91448
91449 if (S_ISREG(inode->i_mode))
91450 diff --git a/mm/util.c b/mm/util.c
91451 index eaf63fc2..32b2629 100644
91452 --- a/mm/util.c
91453 +++ b/mm/util.c
91454 @@ -294,6 +294,12 @@ done:
91455 void arch_pick_mmap_layout(struct mm_struct *mm)
91456 {
91457 mm->mmap_base = TASK_UNMAPPED_BASE;
91458 +
91459 +#ifdef CONFIG_PAX_RANDMMAP
91460 + if (mm->pax_flags & MF_PAX_RANDMMAP)
91461 + mm->mmap_base += mm->delta_mmap;
91462 +#endif
91463 +
91464 mm->get_unmapped_area = arch_get_unmapped_area;
91465 }
91466 #endif
91467 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
91468 index 1074543..136dbe0 100644
91469 --- a/mm/vmalloc.c
91470 +++ b/mm/vmalloc.c
91471 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
91472
91473 pte = pte_offset_kernel(pmd, addr);
91474 do {
91475 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91476 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91477 +
91478 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91479 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
91480 + BUG_ON(!pte_exec(*pte));
91481 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
91482 + continue;
91483 + }
91484 +#endif
91485 +
91486 + {
91487 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91488 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91489 + }
91490 } while (pte++, addr += PAGE_SIZE, addr != end);
91491 }
91492
91493 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
91494 pte = pte_alloc_kernel(pmd, addr);
91495 if (!pte)
91496 return -ENOMEM;
91497 +
91498 + pax_open_kernel();
91499 do {
91500 struct page *page = pages[*nr];
91501
91502 - if (WARN_ON(!pte_none(*pte)))
91503 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91504 + if (pgprot_val(prot) & _PAGE_NX)
91505 +#endif
91506 +
91507 + if (!pte_none(*pte)) {
91508 + pax_close_kernel();
91509 + WARN_ON(1);
91510 return -EBUSY;
91511 - if (WARN_ON(!page))
91512 + }
91513 + if (!page) {
91514 + pax_close_kernel();
91515 + WARN_ON(1);
91516 return -ENOMEM;
91517 + }
91518 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
91519 (*nr)++;
91520 } while (pte++, addr += PAGE_SIZE, addr != end);
91521 + pax_close_kernel();
91522 return 0;
91523 }
91524
91525 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
91526 pmd_t *pmd;
91527 unsigned long next;
91528
91529 - pmd = pmd_alloc(&init_mm, pud, addr);
91530 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
91531 if (!pmd)
91532 return -ENOMEM;
91533 do {
91534 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
91535 pud_t *pud;
91536 unsigned long next;
91537
91538 - pud = pud_alloc(&init_mm, pgd, addr);
91539 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
91540 if (!pud)
91541 return -ENOMEM;
91542 do {
91543 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
91544 if (addr >= MODULES_VADDR && addr < MODULES_END)
91545 return 1;
91546 #endif
91547 +
91548 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91549 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
91550 + return 1;
91551 +#endif
91552 +
91553 return is_vmalloc_addr(x);
91554 }
91555
91556 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
91557
91558 if (!pgd_none(*pgd)) {
91559 pud_t *pud = pud_offset(pgd, addr);
91560 +#ifdef CONFIG_X86
91561 + if (!pud_large(*pud))
91562 +#endif
91563 if (!pud_none(*pud)) {
91564 pmd_t *pmd = pmd_offset(pud, addr);
91565 +#ifdef CONFIG_X86
91566 + if (!pmd_large(*pmd))
91567 +#endif
91568 if (!pmd_none(*pmd)) {
91569 pte_t *ptep, pte;
91570
91571 @@ -1303,6 +1339,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
91572 struct vm_struct *area;
91573
91574 BUG_ON(in_interrupt());
91575 +
91576 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91577 + if (flags & VM_KERNEXEC) {
91578 + if (start != VMALLOC_START || end != VMALLOC_END)
91579 + return NULL;
91580 + start = (unsigned long)MODULES_EXEC_VADDR;
91581 + end = (unsigned long)MODULES_EXEC_END;
91582 + }
91583 +#endif
91584 +
91585 if (flags & VM_IOREMAP)
91586 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
91587
91588 @@ -1528,6 +1574,11 @@ void *vmap(struct page **pages, unsigned int count,
91589 if (count > totalram_pages)
91590 return NULL;
91591
91592 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91593 + if (!(pgprot_val(prot) & _PAGE_NX))
91594 + flags |= VM_KERNEXEC;
91595 +#endif
91596 +
91597 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
91598 __builtin_return_address(0));
91599 if (!area)
91600 @@ -1629,6 +1680,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
91601 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
91602 goto fail;
91603
91604 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91605 + if (!(pgprot_val(prot) & _PAGE_NX))
91606 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
91607 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
91608 + else
91609 +#endif
91610 +
91611 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
91612 start, end, node, gfp_mask, caller);
91613 if (!area)
91614 @@ -1805,10 +1863,9 @@ EXPORT_SYMBOL(vzalloc_node);
91615 * For tight control over page level allocator and protection flags
91616 * use __vmalloc() instead.
91617 */
91618 -
91619 void *vmalloc_exec(unsigned long size)
91620 {
91621 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
91622 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
91623 NUMA_NO_NODE, __builtin_return_address(0));
91624 }
91625
91626 @@ -2115,6 +2172,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
91627 {
91628 struct vm_struct *area;
91629
91630 + BUG_ON(vma->vm_mirror);
91631 +
91632 size = PAGE_ALIGN(size);
91633
91634 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
91635 @@ -2600,7 +2659,11 @@ static int s_show(struct seq_file *m, void *p)
91636 v->addr, v->addr + v->size, v->size);
91637
91638 if (v->caller)
91639 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91640 + seq_printf(m, " %pK", v->caller);
91641 +#else
91642 seq_printf(m, " %pS", v->caller);
91643 +#endif
91644
91645 if (v->nr_pages)
91646 seq_printf(m, " pages=%d", v->nr_pages);
91647 diff --git a/mm/vmstat.c b/mm/vmstat.c
91648 index 9bb3145..98e5f68 100644
91649 --- a/mm/vmstat.c
91650 +++ b/mm/vmstat.c
91651 @@ -79,7 +79,7 @@ void vm_events_fold_cpu(int cpu)
91652 *
91653 * vm_stat contains the global counters
91654 */
91655 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91656 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91657 EXPORT_SYMBOL(vm_stat);
91658
91659 #ifdef CONFIG_SMP
91660 @@ -423,7 +423,7 @@ static inline void fold_diff(int *diff)
91661
91662 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
91663 if (diff[i])
91664 - atomic_long_add(diff[i], &vm_stat[i]);
91665 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
91666 }
91667
91668 /*
91669 @@ -455,7 +455,7 @@ static void refresh_cpu_vm_stats(void)
91670 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
91671 if (v) {
91672
91673 - atomic_long_add(v, &zone->vm_stat[i]);
91674 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91675 global_diff[i] += v;
91676 #ifdef CONFIG_NUMA
91677 /* 3 seconds idle till flush */
91678 @@ -517,7 +517,7 @@ void cpu_vm_stats_fold(int cpu)
91679
91680 v = p->vm_stat_diff[i];
91681 p->vm_stat_diff[i] = 0;
91682 - atomic_long_add(v, &zone->vm_stat[i]);
91683 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91684 global_diff[i] += v;
91685 }
91686 }
91687 @@ -537,8 +537,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
91688 if (pset->vm_stat_diff[i]) {
91689 int v = pset->vm_stat_diff[i];
91690 pset->vm_stat_diff[i] = 0;
91691 - atomic_long_add(v, &zone->vm_stat[i]);
91692 - atomic_long_add(v, &vm_stat[i]);
91693 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91694 + atomic_long_add_unchecked(v, &vm_stat[i]);
91695 }
91696 }
91697 #endif
91698 @@ -1280,10 +1280,20 @@ static int __init setup_vmstat(void)
91699 start_cpu_timer(cpu);
91700 #endif
91701 #ifdef CONFIG_PROC_FS
91702 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
91703 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
91704 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
91705 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
91706 + {
91707 + mode_t gr_mode = S_IRUGO;
91708 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
91709 + gr_mode = S_IRUSR;
91710 +#endif
91711 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
91712 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
91713 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
91714 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
91715 +#else
91716 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
91717 +#endif
91718 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
91719 + }
91720 #endif
91721 return 0;
91722 }
91723 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
91724 index 61fc573..b5e47d0 100644
91725 --- a/net/8021q/vlan.c
91726 +++ b/net/8021q/vlan.c
91727 @@ -472,7 +472,7 @@ out:
91728 return NOTIFY_DONE;
91729 }
91730
91731 -static struct notifier_block vlan_notifier_block __read_mostly = {
91732 +static struct notifier_block vlan_notifier_block = {
91733 .notifier_call = vlan_device_event,
91734 };
91735
91736 @@ -547,8 +547,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
91737 err = -EPERM;
91738 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
91739 break;
91740 - if ((args.u.name_type >= 0) &&
91741 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
91742 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
91743 struct vlan_net *vn;
91744
91745 vn = net_generic(net, vlan_net_id);
91746 diff --git a/net/9p/mod.c b/net/9p/mod.c
91747 index 6ab36ae..6f1841b 100644
91748 --- a/net/9p/mod.c
91749 +++ b/net/9p/mod.c
91750 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
91751 void v9fs_register_trans(struct p9_trans_module *m)
91752 {
91753 spin_lock(&v9fs_trans_lock);
91754 - list_add_tail(&m->list, &v9fs_trans_list);
91755 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
91756 spin_unlock(&v9fs_trans_lock);
91757 }
91758 EXPORT_SYMBOL(v9fs_register_trans);
91759 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
91760 void v9fs_unregister_trans(struct p9_trans_module *m)
91761 {
91762 spin_lock(&v9fs_trans_lock);
91763 - list_del_init(&m->list);
91764 + pax_list_del_init((struct list_head *)&m->list);
91765 spin_unlock(&v9fs_trans_lock);
91766 }
91767 EXPORT_SYMBOL(v9fs_unregister_trans);
91768 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
91769 index 3ffda1b..fceac96 100644
91770 --- a/net/9p/trans_fd.c
91771 +++ b/net/9p/trans_fd.c
91772 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
91773 oldfs = get_fs();
91774 set_fs(get_ds());
91775 /* The cast to a user pointer is valid due to the set_fs() */
91776 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
91777 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
91778 set_fs(oldfs);
91779
91780 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
91781 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
91782 index 876fbe8..8bbea9f 100644
91783 --- a/net/atm/atm_misc.c
91784 +++ b/net/atm/atm_misc.c
91785 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
91786 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
91787 return 1;
91788 atm_return(vcc, truesize);
91789 - atomic_inc(&vcc->stats->rx_drop);
91790 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91791 return 0;
91792 }
91793 EXPORT_SYMBOL(atm_charge);
91794 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
91795 }
91796 }
91797 atm_return(vcc, guess);
91798 - atomic_inc(&vcc->stats->rx_drop);
91799 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91800 return NULL;
91801 }
91802 EXPORT_SYMBOL(atm_alloc_charge);
91803 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
91804
91805 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91806 {
91807 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91808 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91809 __SONET_ITEMS
91810 #undef __HANDLE_ITEM
91811 }
91812 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
91813
91814 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91815 {
91816 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
91817 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
91818 __SONET_ITEMS
91819 #undef __HANDLE_ITEM
91820 }
91821 diff --git a/net/atm/lec.h b/net/atm/lec.h
91822 index 4149db1..f2ab682 100644
91823 --- a/net/atm/lec.h
91824 +++ b/net/atm/lec.h
91825 @@ -48,7 +48,7 @@ struct lane2_ops {
91826 const u8 *tlvs, u32 sizeoftlvs);
91827 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
91828 const u8 *tlvs, u32 sizeoftlvs);
91829 -};
91830 +} __no_const;
91831
91832 /*
91833 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
91834 diff --git a/net/atm/proc.c b/net/atm/proc.c
91835 index bbb6461..cf04016 100644
91836 --- a/net/atm/proc.c
91837 +++ b/net/atm/proc.c
91838 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
91839 const struct k_atm_aal_stats *stats)
91840 {
91841 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
91842 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
91843 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
91844 - atomic_read(&stats->rx_drop));
91845 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
91846 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
91847 + atomic_read_unchecked(&stats->rx_drop));
91848 }
91849
91850 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
91851 diff --git a/net/atm/resources.c b/net/atm/resources.c
91852 index 0447d5d..3cf4728 100644
91853 --- a/net/atm/resources.c
91854 +++ b/net/atm/resources.c
91855 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
91856 static void copy_aal_stats(struct k_atm_aal_stats *from,
91857 struct atm_aal_stats *to)
91858 {
91859 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91860 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91861 __AAL_STAT_ITEMS
91862 #undef __HANDLE_ITEM
91863 }
91864 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
91865 static void subtract_aal_stats(struct k_atm_aal_stats *from,
91866 struct atm_aal_stats *to)
91867 {
91868 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
91869 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
91870 __AAL_STAT_ITEMS
91871 #undef __HANDLE_ITEM
91872 }
91873 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
91874 index 919a5ce..cc6b444 100644
91875 --- a/net/ax25/sysctl_net_ax25.c
91876 +++ b/net/ax25/sysctl_net_ax25.c
91877 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
91878 {
91879 char path[sizeof("net/ax25/") + IFNAMSIZ];
91880 int k;
91881 - struct ctl_table *table;
91882 + ctl_table_no_const *table;
91883
91884 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
91885 if (!table)
91886 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
91887 index 0a8a80c..f7e89aa 100644
91888 --- a/net/batman-adv/bat_iv_ogm.c
91889 +++ b/net/batman-adv/bat_iv_ogm.c
91890 @@ -121,7 +121,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
91891
91892 /* randomize initial seqno to avoid collision */
91893 get_random_bytes(&random_seqno, sizeof(random_seqno));
91894 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
91895 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
91896
91897 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
91898 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
91899 @@ -703,9 +703,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
91900 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
91901
91902 /* change sequence number to network order */
91903 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
91904 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
91905 batadv_ogm_packet->seqno = htonl(seqno);
91906 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
91907 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
91908
91909 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
91910 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
91911 @@ -1111,7 +1111,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
91912 return;
91913
91914 /* could be changed by schedule_own_packet() */
91915 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
91916 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
91917
91918 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
91919 has_directlink_flag = 1;
91920 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
91921 index c478e6b..469fd2f 100644
91922 --- a/net/batman-adv/hard-interface.c
91923 +++ b/net/batman-adv/hard-interface.c
91924 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
91925 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
91926 dev_add_pack(&hard_iface->batman_adv_ptype);
91927
91928 - atomic_set(&hard_iface->frag_seqno, 1);
91929 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
91930 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
91931 hard_iface->net_dev->name);
91932
91933 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
91934 index 813db4e..847edac 100644
91935 --- a/net/batman-adv/soft-interface.c
91936 +++ b/net/batman-adv/soft-interface.c
91937 @@ -263,7 +263,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
91938 primary_if->net_dev->dev_addr, ETH_ALEN);
91939
91940 /* set broadcast sequence number */
91941 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
91942 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
91943 bcast_packet->seqno = htonl(seqno);
91944
91945 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
91946 @@ -483,7 +483,7 @@ static int batadv_softif_init_late(struct net_device *dev)
91947 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
91948
91949 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
91950 - atomic_set(&bat_priv->bcast_seqno, 1);
91951 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
91952 atomic_set(&bat_priv->tt.vn, 0);
91953 atomic_set(&bat_priv->tt.local_changes, 0);
91954 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
91955 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
91956 index b2c94e1..3d47e07 100644
91957 --- a/net/batman-adv/types.h
91958 +++ b/net/batman-adv/types.h
91959 @@ -51,7 +51,7 @@
91960 struct batadv_hard_iface_bat_iv {
91961 unsigned char *ogm_buff;
91962 int ogm_buff_len;
91963 - atomic_t ogm_seqno;
91964 + atomic_unchecked_t ogm_seqno;
91965 };
91966
91967 /**
91968 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
91969 int16_t if_num;
91970 char if_status;
91971 struct net_device *net_dev;
91972 - atomic_t frag_seqno;
91973 + atomic_unchecked_t frag_seqno;
91974 uint8_t num_bcasts;
91975 struct kobject *hardif_obj;
91976 atomic_t refcount;
91977 @@ -560,7 +560,7 @@ struct batadv_priv {
91978 #ifdef CONFIG_BATMAN_ADV_DEBUG
91979 atomic_t log_level;
91980 #endif
91981 - atomic_t bcast_seqno;
91982 + atomic_unchecked_t bcast_seqno;
91983 atomic_t bcast_queue_left;
91984 atomic_t batman_queue_left;
91985 char num_ifaces;
91986 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
91987 index 48b31d3..62a0bcb 100644
91988 --- a/net/batman-adv/unicast.c
91989 +++ b/net/batman-adv/unicast.c
91990 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
91991 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
91992 frag2->flags = large_tail;
91993
91994 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
91995 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
91996 frag1->seqno = htons(seqno - 1);
91997 frag2->seqno = htons(seqno);
91998
91999 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
92000 index 9bd7d95..6c4884f 100644
92001 --- a/net/bluetooth/hci_sock.c
92002 +++ b/net/bluetooth/hci_sock.c
92003 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
92004 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
92005 }
92006
92007 - len = min_t(unsigned int, len, sizeof(uf));
92008 + len = min((size_t)len, sizeof(uf));
92009 if (copy_from_user(&uf, optval, len)) {
92010 err = -EFAULT;
92011 break;
92012 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
92013 index 63fa111..b166ec6 100644
92014 --- a/net/bluetooth/l2cap_core.c
92015 +++ b/net/bluetooth/l2cap_core.c
92016 @@ -3511,8 +3511,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
92017 break;
92018
92019 case L2CAP_CONF_RFC:
92020 - if (olen == sizeof(rfc))
92021 - memcpy(&rfc, (void *)val, olen);
92022 + if (olen != sizeof(rfc))
92023 + break;
92024 +
92025 + memcpy(&rfc, (void *)val, olen);
92026
92027 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
92028 rfc.mode != chan->mode)
92029 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
92030 index 0098af8..fb5a31f 100644
92031 --- a/net/bluetooth/l2cap_sock.c
92032 +++ b/net/bluetooth/l2cap_sock.c
92033 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92034 struct sock *sk = sock->sk;
92035 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
92036 struct l2cap_options opts;
92037 - int len, err = 0;
92038 + int err = 0;
92039 + size_t len = optlen;
92040 u32 opt;
92041
92042 BT_DBG("sk %p", sk);
92043 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92044 opts.max_tx = chan->max_tx;
92045 opts.txwin_size = chan->tx_win;
92046
92047 - len = min_t(unsigned int, sizeof(opts), optlen);
92048 + len = min(sizeof(opts), len);
92049 if (copy_from_user((char *) &opts, optval, len)) {
92050 err = -EFAULT;
92051 break;
92052 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92053 struct bt_security sec;
92054 struct bt_power pwr;
92055 struct l2cap_conn *conn;
92056 - int len, err = 0;
92057 + int err = 0;
92058 + size_t len = optlen;
92059 u32 opt;
92060
92061 BT_DBG("sk %p", sk);
92062 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92063
92064 sec.level = BT_SECURITY_LOW;
92065
92066 - len = min_t(unsigned int, sizeof(sec), optlen);
92067 + len = min(sizeof(sec), len);
92068 if (copy_from_user((char *) &sec, optval, len)) {
92069 err = -EFAULT;
92070 break;
92071 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92072
92073 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
92074
92075 - len = min_t(unsigned int, sizeof(pwr), optlen);
92076 + len = min(sizeof(pwr), len);
92077 if (copy_from_user((char *) &pwr, optval, len)) {
92078 err = -EFAULT;
92079 break;
92080 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
92081 index 30b3721..c1bd0a0 100644
92082 --- a/net/bluetooth/rfcomm/sock.c
92083 +++ b/net/bluetooth/rfcomm/sock.c
92084 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92085 struct sock *sk = sock->sk;
92086 struct bt_security sec;
92087 int err = 0;
92088 - size_t len;
92089 + size_t len = optlen;
92090 u32 opt;
92091
92092 BT_DBG("sk %p", sk);
92093 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92094
92095 sec.level = BT_SECURITY_LOW;
92096
92097 - len = min_t(unsigned int, sizeof(sec), optlen);
92098 + len = min(sizeof(sec), len);
92099 if (copy_from_user((char *) &sec, optval, len)) {
92100 err = -EFAULT;
92101 break;
92102 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
92103 index 84fcf9f..e389b27 100644
92104 --- a/net/bluetooth/rfcomm/tty.c
92105 +++ b/net/bluetooth/rfcomm/tty.c
92106 @@ -684,7 +684,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
92107 BT_DBG("tty %p id %d", tty, tty->index);
92108
92109 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
92110 - dev->channel, dev->port.count);
92111 + dev->channel, atomic_read(&dev->port.count));
92112
92113 err = tty_port_open(&dev->port, tty, filp);
92114 if (err)
92115 @@ -707,7 +707,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
92116 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
92117
92118 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
92119 - dev->port.count);
92120 + atomic_read(&dev->port.count));
92121
92122 tty_port_close(&dev->port, tty, filp);
92123 }
92124 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
92125 index 5180938..7c470c3 100644
92126 --- a/net/bridge/netfilter/ebt_ulog.c
92127 +++ b/net/bridge/netfilter/ebt_ulog.c
92128 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92129 ub->qlen++;
92130
92131 pm = nlmsg_data(nlh);
92132 + memset(pm, 0, sizeof(*pm));
92133
92134 /* Fill in the ulog data */
92135 pm->version = EBT_ULOG_VERSION;
92136 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92137 pm->hook = hooknr;
92138 if (uloginfo->prefix != NULL)
92139 strcpy(pm->prefix, uloginfo->prefix);
92140 - else
92141 - *(pm->prefix) = '\0';
92142
92143 if (in) {
92144 strcpy(pm->physindev, in->name);
92145 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92146 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
92147 else
92148 strcpy(pm->indev, in->name);
92149 - } else
92150 - pm->indev[0] = pm->physindev[0] = '\0';
92151 + }
92152
92153 if (out) {
92154 /* If out exists, then out is a bridge port */
92155 strcpy(pm->physoutdev, out->name);
92156 /* rcu_read_lock()ed by nf_hook_slow */
92157 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
92158 - } else
92159 - pm->outdev[0] = pm->physoutdev[0] = '\0';
92160 + }
92161
92162 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
92163 BUG();
92164 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
92165 index ac78024..161a80c 100644
92166 --- a/net/bridge/netfilter/ebtables.c
92167 +++ b/net/bridge/netfilter/ebtables.c
92168 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92169 tmp.valid_hooks = t->table->valid_hooks;
92170 }
92171 mutex_unlock(&ebt_mutex);
92172 - if (copy_to_user(user, &tmp, *len) != 0){
92173 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
92174 BUGPRINT("c2u Didn't work\n");
92175 ret = -EFAULT;
92176 break;
92177 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92178 goto out;
92179 tmp.valid_hooks = t->valid_hooks;
92180
92181 - if (copy_to_user(user, &tmp, *len) != 0) {
92182 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92183 ret = -EFAULT;
92184 break;
92185 }
92186 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92187 tmp.entries_size = t->table->entries_size;
92188 tmp.valid_hooks = t->table->valid_hooks;
92189
92190 - if (copy_to_user(user, &tmp, *len) != 0) {
92191 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92192 ret = -EFAULT;
92193 break;
92194 }
92195 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
92196 index 0f45522..dab651f 100644
92197 --- a/net/caif/cfctrl.c
92198 +++ b/net/caif/cfctrl.c
92199 @@ -10,6 +10,7 @@
92200 #include <linux/spinlock.h>
92201 #include <linux/slab.h>
92202 #include <linux/pkt_sched.h>
92203 +#include <linux/sched.h>
92204 #include <net/caif/caif_layer.h>
92205 #include <net/caif/cfpkt.h>
92206 #include <net/caif/cfctrl.h>
92207 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
92208 memset(&dev_info, 0, sizeof(dev_info));
92209 dev_info.id = 0xff;
92210 cfsrvl_init(&this->serv, 0, &dev_info, false);
92211 - atomic_set(&this->req_seq_no, 1);
92212 - atomic_set(&this->rsp_seq_no, 1);
92213 + atomic_set_unchecked(&this->req_seq_no, 1);
92214 + atomic_set_unchecked(&this->rsp_seq_no, 1);
92215 this->serv.layer.receive = cfctrl_recv;
92216 sprintf(this->serv.layer.name, "ctrl");
92217 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
92218 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
92219 struct cfctrl_request_info *req)
92220 {
92221 spin_lock_bh(&ctrl->info_list_lock);
92222 - atomic_inc(&ctrl->req_seq_no);
92223 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
92224 + atomic_inc_unchecked(&ctrl->req_seq_no);
92225 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
92226 list_add_tail(&req->list, &ctrl->list);
92227 spin_unlock_bh(&ctrl->info_list_lock);
92228 }
92229 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
92230 if (p != first)
92231 pr_warn("Requests are not received in order\n");
92232
92233 - atomic_set(&ctrl->rsp_seq_no,
92234 + atomic_set_unchecked(&ctrl->rsp_seq_no,
92235 p->sequence_no);
92236 list_del(&p->list);
92237 goto out;
92238 diff --git a/net/can/af_can.c b/net/can/af_can.c
92239 index 3ab8dd2..b9aef13 100644
92240 --- a/net/can/af_can.c
92241 +++ b/net/can/af_can.c
92242 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
92243 };
92244
92245 /* notifier block for netdevice event */
92246 -static struct notifier_block can_netdev_notifier __read_mostly = {
92247 +static struct notifier_block can_netdev_notifier = {
92248 .notifier_call = can_notifier,
92249 };
92250
92251 diff --git a/net/can/gw.c b/net/can/gw.c
92252 index 3f9b0f3..fc6d4fa 100644
92253 --- a/net/can/gw.c
92254 +++ b/net/can/gw.c
92255 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
92256 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
92257
92258 static HLIST_HEAD(cgw_list);
92259 -static struct notifier_block notifier;
92260
92261 static struct kmem_cache *cgw_cache __read_mostly;
92262
92263 @@ -954,6 +953,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
92264 return err;
92265 }
92266
92267 +static struct notifier_block notifier = {
92268 + .notifier_call = cgw_notifier
92269 +};
92270 +
92271 static __init int cgw_module_init(void)
92272 {
92273 /* sanitize given module parameter */
92274 @@ -969,7 +972,6 @@ static __init int cgw_module_init(void)
92275 return -ENOMEM;
92276
92277 /* set notifier */
92278 - notifier.notifier_call = cgw_notifier;
92279 register_netdevice_notifier(&notifier);
92280
92281 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
92282 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
92283 index 4a5df7b..9ad1f1d 100644
92284 --- a/net/ceph/messenger.c
92285 +++ b/net/ceph/messenger.c
92286 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
92287 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
92288
92289 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
92290 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
92291 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
92292
92293 static struct page *zero_page; /* used in certain error cases */
92294
92295 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
92296 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
92297 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
92298
92299 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92300 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92301 s = addr_str[i];
92302
92303 switch (ss->ss_family) {
92304 diff --git a/net/compat.c b/net/compat.c
92305 index 8903258..24e30e5 100644
92306 --- a/net/compat.c
92307 +++ b/net/compat.c
92308 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
92309 return -EFAULT;
92310 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
92311 return -EINVAL;
92312 - kmsg->msg_name = compat_ptr(tmp1);
92313 - kmsg->msg_iov = compat_ptr(tmp2);
92314 - kmsg->msg_control = compat_ptr(tmp3);
92315 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
92316 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
92317 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
92318 return 0;
92319 }
92320
92321 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92322
92323 if (kern_msg->msg_namelen) {
92324 if (mode == VERIFY_READ) {
92325 - int err = move_addr_to_kernel(kern_msg->msg_name,
92326 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
92327 kern_msg->msg_namelen,
92328 kern_address);
92329 if (err < 0)
92330 @@ -98,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92331 kern_msg->msg_name = NULL;
92332
92333 tot_len = iov_from_user_compat_to_kern(kern_iov,
92334 - (struct compat_iovec __user *)kern_msg->msg_iov,
92335 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
92336 kern_msg->msg_iovlen);
92337 if (tot_len >= 0)
92338 kern_msg->msg_iov = kern_iov;
92339 @@ -118,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92340
92341 #define CMSG_COMPAT_FIRSTHDR(msg) \
92342 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
92343 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
92344 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
92345 (struct compat_cmsghdr __user *)NULL)
92346
92347 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
92348 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
92349 (ucmlen) <= (unsigned long) \
92350 ((mhdr)->msg_controllen - \
92351 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
92352 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
92353
92354 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
92355 struct compat_cmsghdr __user *cmsg, int cmsg_len)
92356 {
92357 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
92358 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
92359 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
92360 msg->msg_controllen)
92361 return NULL;
92362 return (struct compat_cmsghdr __user *)ptr;
92363 @@ -221,7 +221,7 @@ Efault:
92364
92365 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
92366 {
92367 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92368 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92369 struct compat_cmsghdr cmhdr;
92370 struct compat_timeval ctv;
92371 struct compat_timespec cts[3];
92372 @@ -277,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
92373
92374 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
92375 {
92376 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92377 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92378 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
92379 int fdnum = scm->fp->count;
92380 struct file **fp = scm->fp->fp;
92381 @@ -365,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
92382 return -EFAULT;
92383 old_fs = get_fs();
92384 set_fs(KERNEL_DS);
92385 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
92386 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
92387 set_fs(old_fs);
92388
92389 return err;
92390 @@ -426,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
92391 len = sizeof(ktime);
92392 old_fs = get_fs();
92393 set_fs(KERNEL_DS);
92394 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
92395 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
92396 set_fs(old_fs);
92397
92398 if (!err) {
92399 @@ -569,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92400 case MCAST_JOIN_GROUP:
92401 case MCAST_LEAVE_GROUP:
92402 {
92403 - struct compat_group_req __user *gr32 = (void *)optval;
92404 + struct compat_group_req __user *gr32 = (void __user *)optval;
92405 struct group_req __user *kgr =
92406 compat_alloc_user_space(sizeof(struct group_req));
92407 u32 interface;
92408 @@ -590,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92409 case MCAST_BLOCK_SOURCE:
92410 case MCAST_UNBLOCK_SOURCE:
92411 {
92412 - struct compat_group_source_req __user *gsr32 = (void *)optval;
92413 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
92414 struct group_source_req __user *kgsr = compat_alloc_user_space(
92415 sizeof(struct group_source_req));
92416 u32 interface;
92417 @@ -611,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92418 }
92419 case MCAST_MSFILTER:
92420 {
92421 - struct compat_group_filter __user *gf32 = (void *)optval;
92422 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92423 struct group_filter __user *kgf;
92424 u32 interface, fmode, numsrc;
92425
92426 @@ -649,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
92427 char __user *optval, int __user *optlen,
92428 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
92429 {
92430 - struct compat_group_filter __user *gf32 = (void *)optval;
92431 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92432 struct group_filter __user *kgf;
92433 int __user *koptlen;
92434 u32 interface, fmode, numsrc;
92435 @@ -807,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
92436
92437 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
92438 return -EINVAL;
92439 - if (copy_from_user(a, args, nas[call]))
92440 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
92441 return -EFAULT;
92442 a0 = a[0];
92443 a1 = a[1];
92444 diff --git a/net/core/datagram.c b/net/core/datagram.c
92445 index af814e7..3d761de 100644
92446 --- a/net/core/datagram.c
92447 +++ b/net/core/datagram.c
92448 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
92449 }
92450
92451 kfree_skb(skb);
92452 - atomic_inc(&sk->sk_drops);
92453 + atomic_inc_unchecked(&sk->sk_drops);
92454 sk_mem_reclaim_partial(sk);
92455
92456 return err;
92457 diff --git a/net/core/dev.c b/net/core/dev.c
92458 index 3430b1e..d6453ad 100644
92459 --- a/net/core/dev.c
92460 +++ b/net/core/dev.c
92461 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
92462 {
92463 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
92464 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
92465 - atomic_long_inc(&dev->rx_dropped);
92466 + atomic_long_inc_unchecked(&dev->rx_dropped);
92467 kfree_skb(skb);
92468 return NET_RX_DROP;
92469 }
92470 }
92471
92472 if (unlikely(!is_skb_forwardable(dev, skb))) {
92473 - atomic_long_inc(&dev->rx_dropped);
92474 + atomic_long_inc_unchecked(&dev->rx_dropped);
92475 kfree_skb(skb);
92476 return NET_RX_DROP;
92477 }
92478 @@ -2432,7 +2432,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
92479
92480 struct dev_gso_cb {
92481 void (*destructor)(struct sk_buff *skb);
92482 -};
92483 +} __no_const;
92484
92485 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
92486
92487 @@ -3207,7 +3207,7 @@ enqueue:
92488
92489 local_irq_restore(flags);
92490
92491 - atomic_long_inc(&skb->dev->rx_dropped);
92492 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92493 kfree_skb(skb);
92494 return NET_RX_DROP;
92495 }
92496 @@ -3279,7 +3279,7 @@ int netif_rx_ni(struct sk_buff *skb)
92497 }
92498 EXPORT_SYMBOL(netif_rx_ni);
92499
92500 -static void net_tx_action(struct softirq_action *h)
92501 +static __latent_entropy void net_tx_action(void)
92502 {
92503 struct softnet_data *sd = &__get_cpu_var(softnet_data);
92504
92505 @@ -3613,7 +3613,7 @@ ncls:
92506 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
92507 } else {
92508 drop:
92509 - atomic_long_inc(&skb->dev->rx_dropped);
92510 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92511 kfree_skb(skb);
92512 /* Jamal, now you will not able to escape explaining
92513 * me how you were going to use this. :-)
92514 @@ -4273,7 +4273,7 @@ void netif_napi_del(struct napi_struct *napi)
92515 }
92516 EXPORT_SYMBOL(netif_napi_del);
92517
92518 -static void net_rx_action(struct softirq_action *h)
92519 +static __latent_entropy void net_rx_action(void)
92520 {
92521 struct softnet_data *sd = &__get_cpu_var(softnet_data);
92522 unsigned long time_limit = jiffies + 2;
92523 @@ -5977,7 +5977,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
92524 } else {
92525 netdev_stats_to_stats64(storage, &dev->stats);
92526 }
92527 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
92528 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
92529 return storage;
92530 }
92531 EXPORT_SYMBOL(dev_get_stats);
92532 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
92533 index 5b7d0e1..cb960fc 100644
92534 --- a/net/core/dev_ioctl.c
92535 +++ b/net/core/dev_ioctl.c
92536 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
92537 if (no_module && capable(CAP_NET_ADMIN))
92538 no_module = request_module("netdev-%s", name);
92539 if (no_module && capable(CAP_SYS_MODULE)) {
92540 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
92541 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
92542 +#else
92543 if (!request_module("%s", name))
92544 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
92545 name);
92546 +#endif
92547 }
92548 }
92549 EXPORT_SYMBOL(dev_load);
92550 diff --git a/net/core/flow.c b/net/core/flow.c
92551 index dfa602c..3103d88 100644
92552 --- a/net/core/flow.c
92553 +++ b/net/core/flow.c
92554 @@ -61,7 +61,7 @@ struct flow_cache {
92555 struct timer_list rnd_timer;
92556 };
92557
92558 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
92559 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
92560 EXPORT_SYMBOL(flow_cache_genid);
92561 static struct flow_cache flow_cache_global;
92562 static struct kmem_cache *flow_cachep __read_mostly;
92563 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
92564
92565 static int flow_entry_valid(struct flow_cache_entry *fle)
92566 {
92567 - if (atomic_read(&flow_cache_genid) != fle->genid)
92568 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
92569 return 0;
92570 if (fle->object && !fle->object->ops->check(fle->object))
92571 return 0;
92572 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
92573 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
92574 fcp->hash_count++;
92575 }
92576 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
92577 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
92578 flo = fle->object;
92579 if (!flo)
92580 goto ret_object;
92581 @@ -279,7 +279,7 @@ nocache:
92582 }
92583 flo = resolver(net, key, family, dir, flo, ctx);
92584 if (fle) {
92585 - fle->genid = atomic_read(&flow_cache_genid);
92586 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
92587 if (!IS_ERR(flo))
92588 fle->object = flo;
92589 else
92590 diff --git a/net/core/iovec.c b/net/core/iovec.c
92591 index b77eeec..2890aca 100644
92592 --- a/net/core/iovec.c
92593 +++ b/net/core/iovec.c
92594 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92595 if (m->msg_namelen) {
92596 if (mode == VERIFY_READ) {
92597 void __user *namep;
92598 - namep = (void __user __force *) m->msg_name;
92599 + namep = (void __force_user *) m->msg_name;
92600 err = move_addr_to_kernel(namep, m->msg_namelen,
92601 address);
92602 if (err < 0)
92603 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92604 }
92605
92606 size = m->msg_iovlen * sizeof(struct iovec);
92607 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
92608 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
92609 return -EFAULT;
92610
92611 m->msg_iov = iov;
92612 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
92613 index 6072610..7374c18 100644
92614 --- a/net/core/neighbour.c
92615 +++ b/net/core/neighbour.c
92616 @@ -2774,7 +2774,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
92617 void __user *buffer, size_t *lenp, loff_t *ppos)
92618 {
92619 int size, ret;
92620 - struct ctl_table tmp = *ctl;
92621 + ctl_table_no_const tmp = *ctl;
92622
92623 tmp.extra1 = &zero;
92624 tmp.extra2 = &unres_qlen_max;
92625 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
92626 index 2bf8329..7960607 100644
92627 --- a/net/core/net-procfs.c
92628 +++ b/net/core/net-procfs.c
92629 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
92630 else
92631 seq_printf(seq, "%04x", ntohs(pt->type));
92632
92633 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92634 + seq_printf(seq, " %-8s %pf\n",
92635 + pt->dev ? pt->dev->name : "", NULL);
92636 +#else
92637 seq_printf(seq, " %-8s %pf\n",
92638 pt->dev ? pt->dev->name : "", pt->func);
92639 +#endif
92640 }
92641
92642 return 0;
92643 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
92644 index d954b56..b0a0f7a 100644
92645 --- a/net/core/net-sysfs.c
92646 +++ b/net/core/net-sysfs.c
92647 @@ -1356,7 +1356,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
92648 }
92649 EXPORT_SYMBOL(netdev_class_remove_file);
92650
92651 -int netdev_kobject_init(void)
92652 +int __init netdev_kobject_init(void)
92653 {
92654 kobj_ns_type_register(&net_ns_type_operations);
92655 return class_register(&net_class);
92656 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
92657 index 81d3a9a..a0bd7a8 100644
92658 --- a/net/core/net_namespace.c
92659 +++ b/net/core/net_namespace.c
92660 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
92661 int error;
92662 LIST_HEAD(net_exit_list);
92663
92664 - list_add_tail(&ops->list, list);
92665 + pax_list_add_tail((struct list_head *)&ops->list, list);
92666 if (ops->init || (ops->id && ops->size)) {
92667 for_each_net(net) {
92668 error = ops_init(ops, net);
92669 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
92670
92671 out_undo:
92672 /* If I have an error cleanup all namespaces I initialized */
92673 - list_del(&ops->list);
92674 + pax_list_del((struct list_head *)&ops->list);
92675 ops_exit_list(ops, &net_exit_list);
92676 ops_free_list(ops, &net_exit_list);
92677 return error;
92678 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
92679 struct net *net;
92680 LIST_HEAD(net_exit_list);
92681
92682 - list_del(&ops->list);
92683 + pax_list_del((struct list_head *)&ops->list);
92684 for_each_net(net)
92685 list_add_tail(&net->exit_list, &net_exit_list);
92686 ops_exit_list(ops, &net_exit_list);
92687 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
92688 mutex_lock(&net_mutex);
92689 error = register_pernet_operations(&pernet_list, ops);
92690 if (!error && (first_device == &pernet_list))
92691 - first_device = &ops->list;
92692 + first_device = (struct list_head *)&ops->list;
92693 mutex_unlock(&net_mutex);
92694 return error;
92695 }
92696 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
92697 index fc75c9e..8c8e9be 100644
92698 --- a/net/core/netpoll.c
92699 +++ b/net/core/netpoll.c
92700 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92701 struct udphdr *udph;
92702 struct iphdr *iph;
92703 struct ethhdr *eth;
92704 - static atomic_t ip_ident;
92705 + static atomic_unchecked_t ip_ident;
92706 struct ipv6hdr *ip6h;
92707
92708 udp_len = len + sizeof(*udph);
92709 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92710 put_unaligned(0x45, (unsigned char *)iph);
92711 iph->tos = 0;
92712 put_unaligned(htons(ip_len), &(iph->tot_len));
92713 - iph->id = htons(atomic_inc_return(&ip_ident));
92714 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
92715 iph->frag_off = 0;
92716 iph->ttl = 64;
92717 iph->protocol = IPPROTO_UDP;
92718 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
92719 index 2a0e21d..6ad7642 100644
92720 --- a/net/core/rtnetlink.c
92721 +++ b/net/core/rtnetlink.c
92722 @@ -58,7 +58,7 @@ struct rtnl_link {
92723 rtnl_doit_func doit;
92724 rtnl_dumpit_func dumpit;
92725 rtnl_calcit_func calcit;
92726 -};
92727 +} __no_const;
92728
92729 static DEFINE_MUTEX(rtnl_mutex);
92730
92731 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
92732 if (rtnl_link_ops_get(ops->kind))
92733 return -EEXIST;
92734
92735 - if (!ops->dellink)
92736 - ops->dellink = unregister_netdevice_queue;
92737 + if (!ops->dellink) {
92738 + pax_open_kernel();
92739 + *(void **)&ops->dellink = unregister_netdevice_queue;
92740 + pax_close_kernel();
92741 + }
92742
92743 - list_add_tail(&ops->list, &link_ops);
92744 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
92745 return 0;
92746 }
92747 EXPORT_SYMBOL_GPL(__rtnl_link_register);
92748 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
92749 for_each_net(net) {
92750 __rtnl_kill_links(net, ops);
92751 }
92752 - list_del(&ops->list);
92753 + pax_list_del((struct list_head *)&ops->list);
92754 }
92755 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
92756
92757 diff --git a/net/core/scm.c b/net/core/scm.c
92758 index b442e7e..6f5b5a2 100644
92759 --- a/net/core/scm.c
92760 +++ b/net/core/scm.c
92761 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
92762 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92763 {
92764 struct cmsghdr __user *cm
92765 - = (__force struct cmsghdr __user *)msg->msg_control;
92766 + = (struct cmsghdr __force_user *)msg->msg_control;
92767 struct cmsghdr cmhdr;
92768 int cmlen = CMSG_LEN(len);
92769 int err;
92770 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92771 err = -EFAULT;
92772 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
92773 goto out;
92774 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
92775 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
92776 goto out;
92777 cmlen = CMSG_SPACE(len);
92778 if (msg->msg_controllen < cmlen)
92779 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
92780 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92781 {
92782 struct cmsghdr __user *cm
92783 - = (__force struct cmsghdr __user*)msg->msg_control;
92784 + = (struct cmsghdr __force_user *)msg->msg_control;
92785
92786 int fdmax = 0;
92787 int fdnum = scm->fp->count;
92788 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92789 if (fdnum < fdmax)
92790 fdmax = fdnum;
92791
92792 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
92793 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
92794 i++, cmfptr++)
92795 {
92796 struct socket *sock;
92797 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
92798 index d81cff1..e31f952 100644
92799 --- a/net/core/skbuff.c
92800 +++ b/net/core/skbuff.c
92801 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
92802 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
92803 sizeof(struct sk_buff),
92804 0,
92805 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92806 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92807 + SLAB_NO_SANITIZE,
92808 NULL);
92809 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
92810 (2*sizeof(struct sk_buff)) +
92811 sizeof(atomic_t),
92812 0,
92813 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92814 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92815 + SLAB_NO_SANITIZE,
92816 NULL);
92817 }
92818
92819 diff --git a/net/core/sock.c b/net/core/sock.c
92820 index 0b39e7a..5e9f91e 100644
92821 --- a/net/core/sock.c
92822 +++ b/net/core/sock.c
92823 @@ -393,7 +393,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92824 struct sk_buff_head *list = &sk->sk_receive_queue;
92825
92826 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
92827 - atomic_inc(&sk->sk_drops);
92828 + atomic_inc_unchecked(&sk->sk_drops);
92829 trace_sock_rcvqueue_full(sk, skb);
92830 return -ENOMEM;
92831 }
92832 @@ -403,7 +403,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92833 return err;
92834
92835 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
92836 - atomic_inc(&sk->sk_drops);
92837 + atomic_inc_unchecked(&sk->sk_drops);
92838 return -ENOBUFS;
92839 }
92840
92841 @@ -423,7 +423,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
92842 skb_dst_force(skb);
92843
92844 spin_lock_irqsave(&list->lock, flags);
92845 - skb->dropcount = atomic_read(&sk->sk_drops);
92846 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
92847 __skb_queue_tail(list, skb);
92848 spin_unlock_irqrestore(&list->lock, flags);
92849
92850 @@ -443,7 +443,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
92851 skb->dev = NULL;
92852
92853 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
92854 - atomic_inc(&sk->sk_drops);
92855 + atomic_inc_unchecked(&sk->sk_drops);
92856 goto discard_and_relse;
92857 }
92858 if (nested)
92859 @@ -461,7 +461,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
92860 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
92861 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
92862 bh_unlock_sock(sk);
92863 - atomic_inc(&sk->sk_drops);
92864 + atomic_inc_unchecked(&sk->sk_drops);
92865 goto discard_and_relse;
92866 }
92867
92868 @@ -949,12 +949,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92869 struct timeval tm;
92870 } v;
92871
92872 - int lv = sizeof(int);
92873 - int len;
92874 + unsigned int lv = sizeof(int);
92875 + unsigned int len;
92876
92877 if (get_user(len, optlen))
92878 return -EFAULT;
92879 - if (len < 0)
92880 + if (len > INT_MAX)
92881 return -EINVAL;
92882
92883 memset(&v, 0, sizeof(v));
92884 @@ -1106,11 +1106,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92885
92886 case SO_PEERNAME:
92887 {
92888 - char address[128];
92889 + char address[_K_SS_MAXSIZE];
92890
92891 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
92892 return -ENOTCONN;
92893 - if (lv < len)
92894 + if (lv < len || sizeof address < len)
92895 return -EINVAL;
92896 if (copy_to_user(optval, address, len))
92897 return -EFAULT;
92898 @@ -1183,7 +1183,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92899
92900 if (len > lv)
92901 len = lv;
92902 - if (copy_to_user(optval, &v, len))
92903 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
92904 return -EFAULT;
92905 lenout:
92906 if (put_user(len, optlen))
92907 @@ -2326,7 +2326,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
92908 */
92909 smp_wmb();
92910 atomic_set(&sk->sk_refcnt, 1);
92911 - atomic_set(&sk->sk_drops, 0);
92912 + atomic_set_unchecked(&sk->sk_drops, 0);
92913 }
92914 EXPORT_SYMBOL(sock_init_data);
92915
92916 @@ -2451,6 +2451,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
92917 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
92918 int level, int type)
92919 {
92920 + struct sock_extended_err ee;
92921 struct sock_exterr_skb *serr;
92922 struct sk_buff *skb, *skb2;
92923 int copied, err;
92924 @@ -2472,7 +2473,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
92925 sock_recv_timestamp(msg, sk, skb);
92926
92927 serr = SKB_EXT_ERR(skb);
92928 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
92929 + ee = serr->ee;
92930 + put_cmsg(msg, level, type, sizeof ee, &ee);
92931
92932 msg->msg_flags |= MSG_ERRQUEUE;
92933 err = copied;
92934 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
92935 index a0e9cf6..ef7f9ed 100644
92936 --- a/net/core/sock_diag.c
92937 +++ b/net/core/sock_diag.c
92938 @@ -9,26 +9,33 @@
92939 #include <linux/inet_diag.h>
92940 #include <linux/sock_diag.h>
92941
92942 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
92943 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
92944 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
92945 static DEFINE_MUTEX(sock_diag_table_mutex);
92946
92947 int sock_diag_check_cookie(void *sk, __u32 *cookie)
92948 {
92949 +#ifndef CONFIG_GRKERNSEC_HIDESYM
92950 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
92951 cookie[1] != INET_DIAG_NOCOOKIE) &&
92952 ((u32)(unsigned long)sk != cookie[0] ||
92953 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
92954 return -ESTALE;
92955 else
92956 +#endif
92957 return 0;
92958 }
92959 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
92960
92961 void sock_diag_save_cookie(void *sk, __u32 *cookie)
92962 {
92963 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92964 + cookie[0] = 0;
92965 + cookie[1] = 0;
92966 +#else
92967 cookie[0] = (u32)(unsigned long)sk;
92968 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
92969 +#endif
92970 }
92971 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
92972
92973 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
92974 mutex_lock(&sock_diag_table_mutex);
92975 if (sock_diag_handlers[hndl->family])
92976 err = -EBUSY;
92977 - else
92978 + else {
92979 + pax_open_kernel();
92980 sock_diag_handlers[hndl->family] = hndl;
92981 + pax_close_kernel();
92982 + }
92983 mutex_unlock(&sock_diag_table_mutex);
92984
92985 return err;
92986 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
92987
92988 mutex_lock(&sock_diag_table_mutex);
92989 BUG_ON(sock_diag_handlers[family] != hnld);
92990 + pax_open_kernel();
92991 sock_diag_handlers[family] = NULL;
92992 + pax_close_kernel();
92993 mutex_unlock(&sock_diag_table_mutex);
92994 }
92995 EXPORT_SYMBOL_GPL(sock_diag_unregister);
92996 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
92997 index cca4441..5e616de 100644
92998 --- a/net/core/sysctl_net_core.c
92999 +++ b/net/core/sysctl_net_core.c
93000 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
93001 {
93002 unsigned int orig_size, size;
93003 int ret, i;
93004 - struct ctl_table tmp = {
93005 + ctl_table_no_const tmp = {
93006 .data = &size,
93007 .maxlen = sizeof(size),
93008 .mode = table->mode
93009 @@ -199,7 +199,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
93010 void __user *buffer, size_t *lenp, loff_t *ppos)
93011 {
93012 char id[IFNAMSIZ];
93013 - struct ctl_table tbl = {
93014 + ctl_table_no_const tbl = {
93015 .data = id,
93016 .maxlen = IFNAMSIZ,
93017 };
93018 @@ -378,13 +378,12 @@ static struct ctl_table netns_core_table[] = {
93019
93020 static __net_init int sysctl_core_net_init(struct net *net)
93021 {
93022 - struct ctl_table *tbl;
93023 + ctl_table_no_const *tbl = NULL;
93024
93025 net->core.sysctl_somaxconn = SOMAXCONN;
93026
93027 - tbl = netns_core_table;
93028 if (!net_eq(net, &init_net)) {
93029 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
93030 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
93031 if (tbl == NULL)
93032 goto err_dup;
93033
93034 @@ -394,17 +393,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
93035 if (net->user_ns != &init_user_ns) {
93036 tbl[0].procname = NULL;
93037 }
93038 - }
93039 -
93040 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93041 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93042 + } else
93043 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
93044 if (net->core.sysctl_hdr == NULL)
93045 goto err_reg;
93046
93047 return 0;
93048
93049 err_reg:
93050 - if (tbl != netns_core_table)
93051 - kfree(tbl);
93052 + kfree(tbl);
93053 err_dup:
93054 return -ENOMEM;
93055 }
93056 @@ -419,7 +417,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
93057 kfree(tbl);
93058 }
93059
93060 -static __net_initdata struct pernet_operations sysctl_core_ops = {
93061 +static __net_initconst struct pernet_operations sysctl_core_ops = {
93062 .init = sysctl_core_net_init,
93063 .exit = sysctl_core_net_exit,
93064 };
93065 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
93066 index dd4d506..fb2fb87 100644
93067 --- a/net/decnet/af_decnet.c
93068 +++ b/net/decnet/af_decnet.c
93069 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
93070 .sysctl_rmem = sysctl_decnet_rmem,
93071 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
93072 .obj_size = sizeof(struct dn_sock),
93073 + .slab_flags = SLAB_USERCOPY,
93074 };
93075
93076 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
93077 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
93078 index 5325b54..a0d4d69 100644
93079 --- a/net/decnet/sysctl_net_decnet.c
93080 +++ b/net/decnet/sysctl_net_decnet.c
93081 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
93082
93083 if (len > *lenp) len = *lenp;
93084
93085 - if (copy_to_user(buffer, addr, len))
93086 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
93087 return -EFAULT;
93088
93089 *lenp = len;
93090 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
93091
93092 if (len > *lenp) len = *lenp;
93093
93094 - if (copy_to_user(buffer, devname, len))
93095 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
93096 return -EFAULT;
93097
93098 *lenp = len;
93099 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
93100 index ff41b4d6..6125050 100644
93101 --- a/net/ieee802154/6lowpan.c
93102 +++ b/net/ieee802154/6lowpan.c
93103 @@ -548,7 +548,7 @@ static int lowpan_header_create(struct sk_buff *skb,
93104 hc06_ptr += 3;
93105 } else {
93106 /* compress nothing */
93107 - memcpy(hc06_ptr, &hdr, 4);
93108 + memcpy(hc06_ptr, hdr, 4);
93109 /* replace the top byte with new ECN | DSCP format */
93110 *hc06_ptr = tmp;
93111 hc06_ptr += 4;
93112 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
93113 index cfeb85c..385989a 100644
93114 --- a/net/ipv4/af_inet.c
93115 +++ b/net/ipv4/af_inet.c
93116 @@ -1675,13 +1675,9 @@ static int __init inet_init(void)
93117
93118 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
93119
93120 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
93121 - if (!sysctl_local_reserved_ports)
93122 - goto out;
93123 -
93124 rc = proto_register(&tcp_prot, 1);
93125 if (rc)
93126 - goto out_free_reserved_ports;
93127 + goto out;
93128
93129 rc = proto_register(&udp_prot, 1);
93130 if (rc)
93131 @@ -1790,8 +1786,6 @@ out_unregister_udp_proto:
93132 proto_unregister(&udp_prot);
93133 out_unregister_tcp_proto:
93134 proto_unregister(&tcp_prot);
93135 -out_free_reserved_ports:
93136 - kfree(sysctl_local_reserved_ports);
93137 goto out;
93138 }
93139
93140 diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
93141 index b28e863..19e3637 100644
93142 --- a/net/ipv4/datagram.c
93143 +++ b/net/ipv4/datagram.c
93144 @@ -57,7 +57,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
93145 if (IS_ERR(rt)) {
93146 err = PTR_ERR(rt);
93147 if (err == -ENETUNREACH)
93148 - IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
93149 + IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
93150 goto out;
93151 }
93152
93153 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
93154 index a1b5bcb..62ec5c6 100644
93155 --- a/net/ipv4/devinet.c
93156 +++ b/net/ipv4/devinet.c
93157 @@ -1533,7 +1533,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
93158 idx = 0;
93159 head = &net->dev_index_head[h];
93160 rcu_read_lock();
93161 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93162 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93163 net->dev_base_seq;
93164 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93165 if (idx < s_idx)
93166 @@ -1844,7 +1844,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
93167 idx = 0;
93168 head = &net->dev_index_head[h];
93169 rcu_read_lock();
93170 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93171 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93172 net->dev_base_seq;
93173 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93174 if (idx < s_idx)
93175 @@ -2069,7 +2069,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
93176 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
93177 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
93178
93179 -static struct devinet_sysctl_table {
93180 +static const struct devinet_sysctl_table {
93181 struct ctl_table_header *sysctl_header;
93182 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
93183 } devinet_sysctl = {
93184 @@ -2191,7 +2191,7 @@ static __net_init int devinet_init_net(struct net *net)
93185 int err;
93186 struct ipv4_devconf *all, *dflt;
93187 #ifdef CONFIG_SYSCTL
93188 - struct ctl_table *tbl = ctl_forward_entry;
93189 + ctl_table_no_const *tbl = NULL;
93190 struct ctl_table_header *forw_hdr;
93191 #endif
93192
93193 @@ -2209,7 +2209,7 @@ static __net_init int devinet_init_net(struct net *net)
93194 goto err_alloc_dflt;
93195
93196 #ifdef CONFIG_SYSCTL
93197 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
93198 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
93199 if (tbl == NULL)
93200 goto err_alloc_ctl;
93201
93202 @@ -2229,7 +2229,10 @@ static __net_init int devinet_init_net(struct net *net)
93203 goto err_reg_dflt;
93204
93205 err = -ENOMEM;
93206 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93207 + if (!net_eq(net, &init_net))
93208 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93209 + else
93210 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
93211 if (forw_hdr == NULL)
93212 goto err_reg_ctl;
93213 net->ipv4.forw_hdr = forw_hdr;
93214 @@ -2245,8 +2248,7 @@ err_reg_ctl:
93215 err_reg_dflt:
93216 __devinet_sysctl_unregister(all);
93217 err_reg_all:
93218 - if (tbl != ctl_forward_entry)
93219 - kfree(tbl);
93220 + kfree(tbl);
93221 err_alloc_ctl:
93222 #endif
93223 if (dflt != &ipv4_devconf_dflt)
93224 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
93225 index b3f627a..b0f3e99 100644
93226 --- a/net/ipv4/fib_frontend.c
93227 +++ b/net/ipv4/fib_frontend.c
93228 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
93229 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93230 fib_sync_up(dev);
93231 #endif
93232 - atomic_inc(&net->ipv4.dev_addr_genid);
93233 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93234 rt_cache_flush(dev_net(dev));
93235 break;
93236 case NETDEV_DOWN:
93237 fib_del_ifaddr(ifa, NULL);
93238 - atomic_inc(&net->ipv4.dev_addr_genid);
93239 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93240 if (ifa->ifa_dev->ifa_list == NULL) {
93241 /* Last address was deleted from this interface.
93242 * Disable IP.
93243 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
93244 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93245 fib_sync_up(dev);
93246 #endif
93247 - atomic_inc(&net->ipv4.dev_addr_genid);
93248 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93249 rt_cache_flush(net);
93250 break;
93251 case NETDEV_DOWN:
93252 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
93253 index d5dbca5..6251d5f 100644
93254 --- a/net/ipv4/fib_semantics.c
93255 +++ b/net/ipv4/fib_semantics.c
93256 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
93257 nh->nh_saddr = inet_select_addr(nh->nh_dev,
93258 nh->nh_gw,
93259 nh->nh_parent->fib_scope);
93260 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
93261 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
93262
93263 return nh->nh_saddr;
93264 }
93265 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
93266 index 6acb541..9ea617d 100644
93267 --- a/net/ipv4/inet_connection_sock.c
93268 +++ b/net/ipv4/inet_connection_sock.c
93269 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
93270 .range = { 32768, 61000 },
93271 };
93272
93273 -unsigned long *sysctl_local_reserved_ports;
93274 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
93275 EXPORT_SYMBOL(sysctl_local_reserved_ports);
93276
93277 void inet_get_local_port_range(int *low, int *high)
93278 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
93279 index 96da9c7..b956690 100644
93280 --- a/net/ipv4/inet_hashtables.c
93281 +++ b/net/ipv4/inet_hashtables.c
93282 @@ -18,12 +18,15 @@
93283 #include <linux/sched.h>
93284 #include <linux/slab.h>
93285 #include <linux/wait.h>
93286 +#include <linux/security.h>
93287
93288 #include <net/inet_connection_sock.h>
93289 #include <net/inet_hashtables.h>
93290 #include <net/secure_seq.h>
93291 #include <net/ip.h>
93292
93293 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
93294 +
93295 /*
93296 * Allocate and initialize a new local port bind bucket.
93297 * The bindhash mutex for snum's hash chain must be held here.
93298 @@ -554,6 +557,8 @@ ok:
93299 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
93300 spin_unlock(&head->lock);
93301
93302 + gr_update_task_in_ip_table(current, inet_sk(sk));
93303 +
93304 if (tw) {
93305 inet_twsk_deschedule(tw, death_row);
93306 while (twrefcnt) {
93307 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
93308 index 33d5537..da337a4 100644
93309 --- a/net/ipv4/inetpeer.c
93310 +++ b/net/ipv4/inetpeer.c
93311 @@ -503,8 +503,8 @@ relookup:
93312 if (p) {
93313 p->daddr = *daddr;
93314 atomic_set(&p->refcnt, 1);
93315 - atomic_set(&p->rid, 0);
93316 - atomic_set(&p->ip_id_count,
93317 + atomic_set_unchecked(&p->rid, 0);
93318 + atomic_set_unchecked(&p->ip_id_count,
93319 (daddr->family == AF_INET) ?
93320 secure_ip_id(daddr->addr.a4) :
93321 secure_ipv6_id(daddr->addr.a6));
93322 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
93323 index b66910a..cfe416e 100644
93324 --- a/net/ipv4/ip_fragment.c
93325 +++ b/net/ipv4/ip_fragment.c
93326 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
93327 return 0;
93328
93329 start = qp->rid;
93330 - end = atomic_inc_return(&peer->rid);
93331 + end = atomic_inc_return_unchecked(&peer->rid);
93332 qp->rid = end;
93333
93334 rc = qp->q.fragments && (end - start) > max;
93335 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
93336
93337 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93338 {
93339 - struct ctl_table *table;
93340 + ctl_table_no_const *table = NULL;
93341 struct ctl_table_header *hdr;
93342
93343 - table = ip4_frags_ns_ctl_table;
93344 if (!net_eq(net, &init_net)) {
93345 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93346 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93347 if (table == NULL)
93348 goto err_alloc;
93349
93350 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93351 /* Don't export sysctls to unprivileged users */
93352 if (net->user_ns != &init_user_ns)
93353 table[0].procname = NULL;
93354 - }
93355 + hdr = register_net_sysctl(net, "net/ipv4", table);
93356 + } else
93357 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
93358
93359 - hdr = register_net_sysctl(net, "net/ipv4", table);
93360 if (hdr == NULL)
93361 goto err_reg;
93362
93363 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93364 return 0;
93365
93366 err_reg:
93367 - if (!net_eq(net, &init_net))
93368 - kfree(table);
93369 + kfree(table);
93370 err_alloc:
93371 return -ENOMEM;
93372 }
93373 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
93374 index d7aea4c..a8ee872 100644
93375 --- a/net/ipv4/ip_gre.c
93376 +++ b/net/ipv4/ip_gre.c
93377 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
93378 module_param(log_ecn_error, bool, 0644);
93379 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93380
93381 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
93382 +static struct rtnl_link_ops ipgre_link_ops;
93383 static int ipgre_tunnel_init(struct net_device *dev);
93384
93385 static int ipgre_net_id __read_mostly;
93386 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
93387 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
93388 };
93389
93390 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93391 +static struct rtnl_link_ops ipgre_link_ops = {
93392 .kind = "gre",
93393 .maxtype = IFLA_GRE_MAX,
93394 .policy = ipgre_policy,
93395 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93396 .fill_info = ipgre_fill_info,
93397 };
93398
93399 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
93400 +static struct rtnl_link_ops ipgre_tap_ops = {
93401 .kind = "gretap",
93402 .maxtype = IFLA_GRE_MAX,
93403 .policy = ipgre_policy,
93404 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
93405 index d9c4f11..02b82dbc 100644
93406 --- a/net/ipv4/ip_sockglue.c
93407 +++ b/net/ipv4/ip_sockglue.c
93408 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
93409 len = min_t(unsigned int, len, opt->optlen);
93410 if (put_user(len, optlen))
93411 return -EFAULT;
93412 - if (copy_to_user(optval, opt->__data, len))
93413 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
93414 + copy_to_user(optval, opt->__data, len))
93415 return -EFAULT;
93416 return 0;
93417 }
93418 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
93419 if (sk->sk_type != SOCK_STREAM)
93420 return -ENOPROTOOPT;
93421
93422 - msg.msg_control = optval;
93423 + msg.msg_control = (void __force_kernel *)optval;
93424 msg.msg_controllen = len;
93425 msg.msg_flags = flags;
93426
93427 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
93428 index 6e87f85..2c28e240 100644
93429 --- a/net/ipv4/ip_vti.c
93430 +++ b/net/ipv4/ip_vti.c
93431 @@ -44,7 +44,7 @@
93432 #include <net/net_namespace.h>
93433 #include <net/netns/generic.h>
93434
93435 -static struct rtnl_link_ops vti_link_ops __read_mostly;
93436 +static struct rtnl_link_ops vti_link_ops;
93437
93438 static int vti_net_id __read_mostly;
93439 static int vti_tunnel_init(struct net_device *dev);
93440 @@ -424,7 +424,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
93441 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
93442 };
93443
93444 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
93445 +static struct rtnl_link_ops vti_link_ops = {
93446 .kind = "vti",
93447 .maxtype = IFLA_VTI_MAX,
93448 .policy = vti_policy,
93449 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
93450 index efa1138..20dbba0 100644
93451 --- a/net/ipv4/ipconfig.c
93452 +++ b/net/ipv4/ipconfig.c
93453 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
93454
93455 mm_segment_t oldfs = get_fs();
93456 set_fs(get_ds());
93457 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
93458 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
93459 set_fs(oldfs);
93460 return res;
93461 }
93462 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
93463
93464 mm_segment_t oldfs = get_fs();
93465 set_fs(get_ds());
93466 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
93467 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
93468 set_fs(oldfs);
93469 return res;
93470 }
93471 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
93472
93473 mm_segment_t oldfs = get_fs();
93474 set_fs(get_ds());
93475 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
93476 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
93477 set_fs(oldfs);
93478 return res;
93479 }
93480 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
93481 index 7f80fb4..b0328f6 100644
93482 --- a/net/ipv4/ipip.c
93483 +++ b/net/ipv4/ipip.c
93484 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93485 static int ipip_net_id __read_mostly;
93486
93487 static int ipip_tunnel_init(struct net_device *dev);
93488 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
93489 +static struct rtnl_link_ops ipip_link_ops;
93490
93491 static int ipip_err(struct sk_buff *skb, u32 info)
93492 {
93493 @@ -408,7 +408,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
93494 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
93495 };
93496
93497 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
93498 +static struct rtnl_link_ops ipip_link_ops = {
93499 .kind = "ipip",
93500 .maxtype = IFLA_IPTUN_MAX,
93501 .policy = ipip_policy,
93502 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
93503 index 85a4f21..1beb1f5 100644
93504 --- a/net/ipv4/netfilter/arp_tables.c
93505 +++ b/net/ipv4/netfilter/arp_tables.c
93506 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
93507 #endif
93508
93509 static int get_info(struct net *net, void __user *user,
93510 - const int *len, int compat)
93511 + int len, int compat)
93512 {
93513 char name[XT_TABLE_MAXNAMELEN];
93514 struct xt_table *t;
93515 int ret;
93516
93517 - if (*len != sizeof(struct arpt_getinfo)) {
93518 - duprintf("length %u != %Zu\n", *len,
93519 + if (len != sizeof(struct arpt_getinfo)) {
93520 + duprintf("length %u != %Zu\n", len,
93521 sizeof(struct arpt_getinfo));
93522 return -EINVAL;
93523 }
93524 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
93525 info.size = private->size;
93526 strcpy(info.name, name);
93527
93528 - if (copy_to_user(user, &info, *len) != 0)
93529 + if (copy_to_user(user, &info, len) != 0)
93530 ret = -EFAULT;
93531 else
93532 ret = 0;
93533 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
93534
93535 switch (cmd) {
93536 case ARPT_SO_GET_INFO:
93537 - ret = get_info(sock_net(sk), user, len, 1);
93538 + ret = get_info(sock_net(sk), user, *len, 1);
93539 break;
93540 case ARPT_SO_GET_ENTRIES:
93541 ret = compat_get_entries(sock_net(sk), user, len);
93542 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
93543
93544 switch (cmd) {
93545 case ARPT_SO_GET_INFO:
93546 - ret = get_info(sock_net(sk), user, len, 0);
93547 + ret = get_info(sock_net(sk), user, *len, 0);
93548 break;
93549
93550 case ARPT_SO_GET_ENTRIES:
93551 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
93552 index d23118d..6ad7277 100644
93553 --- a/net/ipv4/netfilter/ip_tables.c
93554 +++ b/net/ipv4/netfilter/ip_tables.c
93555 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
93556 #endif
93557
93558 static int get_info(struct net *net, void __user *user,
93559 - const int *len, int compat)
93560 + int len, int compat)
93561 {
93562 char name[XT_TABLE_MAXNAMELEN];
93563 struct xt_table *t;
93564 int ret;
93565
93566 - if (*len != sizeof(struct ipt_getinfo)) {
93567 - duprintf("length %u != %zu\n", *len,
93568 + if (len != sizeof(struct ipt_getinfo)) {
93569 + duprintf("length %u != %zu\n", len,
93570 sizeof(struct ipt_getinfo));
93571 return -EINVAL;
93572 }
93573 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
93574 info.size = private->size;
93575 strcpy(info.name, name);
93576
93577 - if (copy_to_user(user, &info, *len) != 0)
93578 + if (copy_to_user(user, &info, len) != 0)
93579 ret = -EFAULT;
93580 else
93581 ret = 0;
93582 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93583
93584 switch (cmd) {
93585 case IPT_SO_GET_INFO:
93586 - ret = get_info(sock_net(sk), user, len, 1);
93587 + ret = get_info(sock_net(sk), user, *len, 1);
93588 break;
93589 case IPT_SO_GET_ENTRIES:
93590 ret = compat_get_entries(sock_net(sk), user, len);
93591 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93592
93593 switch (cmd) {
93594 case IPT_SO_GET_INFO:
93595 - ret = get_info(sock_net(sk), user, len, 0);
93596 + ret = get_info(sock_net(sk), user, *len, 0);
93597 break;
93598
93599 case IPT_SO_GET_ENTRIES:
93600 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
93601 index cbc2215..9cb993c 100644
93602 --- a/net/ipv4/netfilter/ipt_ULOG.c
93603 +++ b/net/ipv4/netfilter/ipt_ULOG.c
93604 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
93605 ub->qlen++;
93606
93607 pm = nlmsg_data(nlh);
93608 + memset(pm, 0, sizeof(*pm));
93609
93610 /* We might not have a timestamp, get one */
93611 if (skb->tstamp.tv64 == 0)
93612 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
93613 }
93614 else if (loginfo->prefix[0] != '\0')
93615 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
93616 - else
93617 - *(pm->prefix) = '\0';
93618
93619 if (in && in->hard_header_len > 0 &&
93620 skb->mac_header != skb->network_header &&
93621 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
93622
93623 if (in)
93624 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
93625 - else
93626 - pm->indev_name[0] = '\0';
93627
93628 if (out)
93629 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
93630 - else
93631 - pm->outdev_name[0] = '\0';
93632
93633 /* copy_len <= skb->len, so can't fail. */
93634 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
93635 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
93636 index d7d9882..d700c68 100644
93637 --- a/net/ipv4/ping.c
93638 +++ b/net/ipv4/ping.c
93639 @@ -55,7 +55,7 @@
93640
93641
93642 struct ping_table ping_table;
93643 -struct pingv6_ops pingv6_ops;
93644 +struct pingv6_ops *pingv6_ops;
93645 EXPORT_SYMBOL_GPL(pingv6_ops);
93646
93647 static u16 ping_port_rover;
93648 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
93649 return -ENODEV;
93650 }
93651 }
93652 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
93653 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
93654 scoped);
93655 rcu_read_unlock();
93656
93657 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93658 }
93659 #if IS_ENABLED(CONFIG_IPV6)
93660 } else if (skb->protocol == htons(ETH_P_IPV6)) {
93661 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
93662 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
93663 #endif
93664 }
93665
93666 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93667 info, (u8 *)icmph);
93668 #if IS_ENABLED(CONFIG_IPV6)
93669 } else if (family == AF_INET6) {
93670 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
93671 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
93672 info, (u8 *)icmph);
93673 #endif
93674 }
93675 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93676 return ip_recv_error(sk, msg, len);
93677 #if IS_ENABLED(CONFIG_IPV6)
93678 } else if (family == AF_INET6) {
93679 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
93680 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
93681 #endif
93682 }
93683 }
93684 @@ -874,11 +874,14 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93685
93686 /* Copy the address and add cmsg data. */
93687 if (family == AF_INET) {
93688 - sin = (struct sockaddr_in *) msg->msg_name;
93689 - sin->sin_family = AF_INET;
93690 - sin->sin_port = 0 /* skb->h.uh->source */;
93691 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93692 - memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93693 + struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
93694 +
93695 + if (sin) {
93696 + sin->sin_family = AF_INET;
93697 + sin->sin_port = 0 /* skb->h.uh->source */;
93698 + sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
93699 + memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
93700 + }
93701
93702 if (isk->cmsg_flags)
93703 ip_cmsg_recv(msg, skb);
93704 @@ -887,20 +890,23 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93705 } else if (family == AF_INET6) {
93706 struct ipv6_pinfo *np = inet6_sk(sk);
93707 struct ipv6hdr *ip6 = ipv6_hdr(skb);
93708 - sin6 = (struct sockaddr_in6 *) msg->msg_name;
93709 - sin6->sin6_family = AF_INET6;
93710 - sin6->sin6_port = 0;
93711 - sin6->sin6_addr = ip6->saddr;
93712 + struct sockaddr_in6 *sin6 =
93713 + (struct sockaddr_in6 *)msg->msg_name;
93714
93715 - sin6->sin6_flowinfo = 0;
93716 - if (np->sndflow)
93717 - sin6->sin6_flowinfo = ip6_flowinfo(ip6);
93718 -
93719 - sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr,
93720 - IP6CB(skb)->iif);
93721 + if (sin6) {
93722 + sin6->sin6_family = AF_INET6;
93723 + sin6->sin6_port = 0;
93724 + sin6->sin6_addr = ip6->saddr;
93725 + sin6->sin6_flowinfo = 0;
93726 + if (np->sndflow)
93727 + sin6->sin6_flowinfo = ip6_flowinfo(ip6);
93728 + sin6->sin6_scope_id =
93729 + ipv6_iface_scope_id(&sin6->sin6_addr,
93730 + IP6CB(skb)->iif);
93731 + }
93732
93733 if (inet6_sk(sk)->rxopt.all)
93734 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
93735 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
93736 #endif
93737 } else {
93738 BUG();
93739 @@ -1090,7 +1096,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
93740 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93741 0, sock_i_ino(sp),
93742 atomic_read(&sp->sk_refcnt), sp,
93743 - atomic_read(&sp->sk_drops), len);
93744 + atomic_read_unchecked(&sp->sk_drops), len);
93745 }
93746
93747 static int ping_v4_seq_show(struct seq_file *seq, void *v)
93748 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
93749 index 193db03..05ba36c 100644
93750 --- a/net/ipv4/raw.c
93751 +++ b/net/ipv4/raw.c
93752 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
93753 int raw_rcv(struct sock *sk, struct sk_buff *skb)
93754 {
93755 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
93756 - atomic_inc(&sk->sk_drops);
93757 + atomic_inc_unchecked(&sk->sk_drops);
93758 kfree_skb(skb);
93759 return NET_RX_DROP;
93760 }
93761 @@ -748,16 +748,20 @@ static int raw_init(struct sock *sk)
93762
93763 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
93764 {
93765 + struct icmp_filter filter;
93766 +
93767 if (optlen > sizeof(struct icmp_filter))
93768 optlen = sizeof(struct icmp_filter);
93769 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
93770 + if (copy_from_user(&filter, optval, optlen))
93771 return -EFAULT;
93772 + raw_sk(sk)->filter = filter;
93773 return 0;
93774 }
93775
93776 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
93777 {
93778 int len, ret = -EFAULT;
93779 + struct icmp_filter filter;
93780
93781 if (get_user(len, optlen))
93782 goto out;
93783 @@ -767,8 +771,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
93784 if (len > sizeof(struct icmp_filter))
93785 len = sizeof(struct icmp_filter);
93786 ret = -EFAULT;
93787 - if (put_user(len, optlen) ||
93788 - copy_to_user(optval, &raw_sk(sk)->filter, len))
93789 + filter = raw_sk(sk)->filter;
93790 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
93791 goto out;
93792 ret = 0;
93793 out: return ret;
93794 @@ -997,7 +1001,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
93795 0, 0L, 0,
93796 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
93797 0, sock_i_ino(sp),
93798 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
93799 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
93800 }
93801
93802 static int raw_seq_show(struct seq_file *seq, void *v)
93803 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
93804 index 6011615..f418576 100644
93805 --- a/net/ipv4/route.c
93806 +++ b/net/ipv4/route.c
93807 @@ -2613,34 +2613,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
93808 .maxlen = sizeof(int),
93809 .mode = 0200,
93810 .proc_handler = ipv4_sysctl_rtcache_flush,
93811 + .extra1 = &init_net,
93812 },
93813 { },
93814 };
93815
93816 static __net_init int sysctl_route_net_init(struct net *net)
93817 {
93818 - struct ctl_table *tbl;
93819 + ctl_table_no_const *tbl = NULL;
93820
93821 - tbl = ipv4_route_flush_table;
93822 if (!net_eq(net, &init_net)) {
93823 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93824 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93825 if (tbl == NULL)
93826 goto err_dup;
93827
93828 /* Don't export sysctls to unprivileged users */
93829 if (net->user_ns != &init_user_ns)
93830 tbl[0].procname = NULL;
93831 - }
93832 - tbl[0].extra1 = net;
93833 + tbl[0].extra1 = net;
93834 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93835 + } else
93836 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
93837
93838 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93839 if (net->ipv4.route_hdr == NULL)
93840 goto err_reg;
93841 return 0;
93842
93843 err_reg:
93844 - if (tbl != ipv4_route_flush_table)
93845 - kfree(tbl);
93846 + kfree(tbl);
93847 err_dup:
93848 return -ENOMEM;
93849 }
93850 @@ -2663,8 +2663,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
93851
93852 static __net_init int rt_genid_init(struct net *net)
93853 {
93854 - atomic_set(&net->ipv4.rt_genid, 0);
93855 - atomic_set(&net->fnhe_genid, 0);
93856 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
93857 + atomic_set_unchecked(&net->fnhe_genid, 0);
93858 get_random_bytes(&net->ipv4.dev_addr_genid,
93859 sizeof(net->ipv4.dev_addr_genid));
93860 return 0;
93861 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
93862 index 540279f..9855b16 100644
93863 --- a/net/ipv4/sysctl_net_ipv4.c
93864 +++ b/net/ipv4/sysctl_net_ipv4.c
93865 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
93866 {
93867 int ret;
93868 int range[2];
93869 - struct ctl_table tmp = {
93870 + ctl_table_no_const tmp = {
93871 .data = &range,
93872 .maxlen = sizeof(range),
93873 .mode = table->mode,
93874 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
93875 int ret;
93876 gid_t urange[2];
93877 kgid_t low, high;
93878 - struct ctl_table tmp = {
93879 + ctl_table_no_const tmp = {
93880 .data = &urange,
93881 .maxlen = sizeof(urange),
93882 .mode = table->mode,
93883 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
93884 void __user *buffer, size_t *lenp, loff_t *ppos)
93885 {
93886 char val[TCP_CA_NAME_MAX];
93887 - struct ctl_table tbl = {
93888 + ctl_table_no_const tbl = {
93889 .data = val,
93890 .maxlen = TCP_CA_NAME_MAX,
93891 };
93892 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
93893 void __user *buffer, size_t *lenp,
93894 loff_t *ppos)
93895 {
93896 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
93897 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
93898 int ret;
93899
93900 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93901 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
93902 void __user *buffer, size_t *lenp,
93903 loff_t *ppos)
93904 {
93905 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
93906 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
93907 int ret;
93908
93909 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
93910 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
93911 struct mem_cgroup *memcg;
93912 #endif
93913
93914 - struct ctl_table tmp = {
93915 + ctl_table_no_const tmp = {
93916 .data = &vec,
93917 .maxlen = sizeof(vec),
93918 .mode = ctl->mode,
93919 };
93920
93921 if (!write) {
93922 - ctl->data = &net->ipv4.sysctl_tcp_mem;
93923 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
93924 + ctl_table_no_const tcp_mem = *ctl;
93925 +
93926 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
93927 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
93928 }
93929
93930 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
93931 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
93932 void __user *buffer, size_t *lenp,
93933 loff_t *ppos)
93934 {
93935 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93936 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93937 struct tcp_fastopen_context *ctxt;
93938 int ret;
93939 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
93940 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
93941 },
93942 {
93943 .procname = "ip_local_reserved_ports",
93944 - .data = NULL, /* initialized in sysctl_ipv4_init */
93945 + .data = sysctl_local_reserved_ports,
93946 .maxlen = 65536,
93947 .mode = 0644,
93948 .proc_handler = proc_do_large_bitmap,
93949 @@ -864,11 +866,10 @@ static struct ctl_table ipv4_net_table[] = {
93950
93951 static __net_init int ipv4_sysctl_init_net(struct net *net)
93952 {
93953 - struct ctl_table *table;
93954 + ctl_table_no_const *table = NULL;
93955
93956 - table = ipv4_net_table;
93957 if (!net_eq(net, &init_net)) {
93958 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
93959 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
93960 if (table == NULL)
93961 goto err_alloc;
93962
93963 @@ -903,15 +904,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
93964
93965 tcp_init_mem(net);
93966
93967 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93968 + if (!net_eq(net, &init_net))
93969 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93970 + else
93971 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
93972 if (net->ipv4.ipv4_hdr == NULL)
93973 goto err_reg;
93974
93975 return 0;
93976
93977 err_reg:
93978 - if (!net_eq(net, &init_net))
93979 - kfree(table);
93980 + kfree(table);
93981 err_alloc:
93982 return -ENOMEM;
93983 }
93984 @@ -933,16 +936,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
93985 static __init int sysctl_ipv4_init(void)
93986 {
93987 struct ctl_table_header *hdr;
93988 - struct ctl_table *i;
93989 -
93990 - for (i = ipv4_table; i->procname; i++) {
93991 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
93992 - i->data = sysctl_local_reserved_ports;
93993 - break;
93994 - }
93995 - }
93996 - if (!i->procname)
93997 - return -EINVAL;
93998
93999 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
94000 if (hdr == NULL)
94001 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
94002 index 068c8fb..a755c52 100644
94003 --- a/net/ipv4/tcp_input.c
94004 +++ b/net/ipv4/tcp_input.c
94005 @@ -4435,7 +4435,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
94006 * simplifies code)
94007 */
94008 static void
94009 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94010 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94011 struct sk_buff *head, struct sk_buff *tail,
94012 u32 start, u32 end)
94013 {
94014 @@ -5520,6 +5520,7 @@ discard:
94015 tcp_paws_reject(&tp->rx_opt, 0))
94016 goto discard_and_undo;
94017
94018 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
94019 if (th->syn) {
94020 /* We see SYN without ACK. It is attempt of
94021 * simultaneous connect with crossed SYNs.
94022 @@ -5570,6 +5571,7 @@ discard:
94023 goto discard;
94024 #endif
94025 }
94026 +#endif
94027 /* "fifth, if neither of the SYN or RST bits is set then
94028 * drop the segment and return."
94029 */
94030 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
94031 goto discard;
94032
94033 if (th->syn) {
94034 - if (th->fin)
94035 + if (th->fin || th->urg || th->psh)
94036 goto discard;
94037 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
94038 return 1;
94039 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
94040 index b14266b..c5fe725 100644
94041 --- a/net/ipv4/tcp_ipv4.c
94042 +++ b/net/ipv4/tcp_ipv4.c
94043 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
94044 EXPORT_SYMBOL(sysctl_tcp_low_latency);
94045
94046
94047 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94048 +extern int grsec_enable_blackhole;
94049 +#endif
94050 +
94051 #ifdef CONFIG_TCP_MD5SIG
94052 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94053 __be32 daddr, __be32 saddr, const struct tcphdr *th);
94054 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
94055 return 0;
94056
94057 reset:
94058 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94059 + if (!grsec_enable_blackhole)
94060 +#endif
94061 tcp_v4_send_reset(rsk, skb);
94062 discard:
94063 kfree_skb(skb);
94064 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
94065 TCP_SKB_CB(skb)->sacked = 0;
94066
94067 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94068 - if (!sk)
94069 + if (!sk) {
94070 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94071 + ret = 1;
94072 +#endif
94073 goto no_tcp_socket;
94074 -
94075 + }
94076 process:
94077 - if (sk->sk_state == TCP_TIME_WAIT)
94078 + if (sk->sk_state == TCP_TIME_WAIT) {
94079 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94080 + ret = 2;
94081 +#endif
94082 goto do_time_wait;
94083 + }
94084
94085 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
94086 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94087 @@ -2033,6 +2047,10 @@ csum_error:
94088 bad_packet:
94089 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94090 } else {
94091 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94092 + if (!grsec_enable_blackhole || (ret == 1 &&
94093 + (skb->dev->flags & IFF_LOOPBACK)))
94094 +#endif
94095 tcp_v4_send_reset(NULL, skb);
94096 }
94097
94098 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
94099 index 58a3e69..7f0626e 100644
94100 --- a/net/ipv4/tcp_minisocks.c
94101 +++ b/net/ipv4/tcp_minisocks.c
94102 @@ -27,6 +27,10 @@
94103 #include <net/inet_common.h>
94104 #include <net/xfrm.h>
94105
94106 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94107 +extern int grsec_enable_blackhole;
94108 +#endif
94109 +
94110 int sysctl_tcp_syncookies __read_mostly = 1;
94111 EXPORT_SYMBOL(sysctl_tcp_syncookies);
94112
94113 @@ -711,7 +715,10 @@ embryonic_reset:
94114 * avoid becoming vulnerable to outside attack aiming at
94115 * resetting legit local connections.
94116 */
94117 - req->rsk_ops->send_reset(sk, skb);
94118 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94119 + if (!grsec_enable_blackhole)
94120 +#endif
94121 + req->rsk_ops->send_reset(sk, skb);
94122 } else if (fastopen) { /* received a valid RST pkt */
94123 reqsk_fastopen_remove(sk, req, true);
94124 tcp_reset(sk);
94125 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
94126 index 611beab..c4b6e1d 100644
94127 --- a/net/ipv4/tcp_probe.c
94128 +++ b/net/ipv4/tcp_probe.c
94129 @@ -245,7 +245,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
94130 if (cnt + width >= len)
94131 break;
94132
94133 - if (copy_to_user(buf + cnt, tbuf, width))
94134 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
94135 return -EFAULT;
94136 cnt += width;
94137 }
94138 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
94139 index 4b85e6f..22f9ac9 100644
94140 --- a/net/ipv4/tcp_timer.c
94141 +++ b/net/ipv4/tcp_timer.c
94142 @@ -22,6 +22,10 @@
94143 #include <linux/gfp.h>
94144 #include <net/tcp.h>
94145
94146 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94147 +extern int grsec_lastack_retries;
94148 +#endif
94149 +
94150 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
94151 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
94152 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
94153 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
94154 }
94155 }
94156
94157 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94158 + if ((sk->sk_state == TCP_LAST_ACK) &&
94159 + (grsec_lastack_retries > 0) &&
94160 + (grsec_lastack_retries < retry_until))
94161 + retry_until = grsec_lastack_retries;
94162 +#endif
94163 +
94164 if (retransmits_timed_out(sk, retry_until,
94165 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
94166 /* Has it gone just too far? */
94167 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
94168 index 0ca44df..b5e4b11 100644
94169 --- a/net/ipv4/udp.c
94170 +++ b/net/ipv4/udp.c
94171 @@ -87,6 +87,7 @@
94172 #include <linux/types.h>
94173 #include <linux/fcntl.h>
94174 #include <linux/module.h>
94175 +#include <linux/security.h>
94176 #include <linux/socket.h>
94177 #include <linux/sockios.h>
94178 #include <linux/igmp.h>
94179 @@ -112,6 +113,10 @@
94180 #include <net/busy_poll.h>
94181 #include "udp_impl.h"
94182
94183 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94184 +extern int grsec_enable_blackhole;
94185 +#endif
94186 +
94187 struct udp_table udp_table __read_mostly;
94188 EXPORT_SYMBOL(udp_table);
94189
94190 @@ -595,6 +600,9 @@ found:
94191 return s;
94192 }
94193
94194 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
94195 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
94196 +
94197 /*
94198 * This routine is called by the ICMP module when it gets some
94199 * sort of error condition. If err < 0 then the socket should
94200 @@ -892,9 +900,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94201 dport = usin->sin_port;
94202 if (dport == 0)
94203 return -EINVAL;
94204 +
94205 + err = gr_search_udp_sendmsg(sk, usin);
94206 + if (err)
94207 + return err;
94208 } else {
94209 if (sk->sk_state != TCP_ESTABLISHED)
94210 return -EDESTADDRREQ;
94211 +
94212 + err = gr_search_udp_sendmsg(sk, NULL);
94213 + if (err)
94214 + return err;
94215 +
94216 daddr = inet->inet_daddr;
94217 dport = inet->inet_dport;
94218 /* Open fast path for connected socket.
94219 @@ -1138,7 +1155,7 @@ static unsigned int first_packet_length(struct sock *sk)
94220 IS_UDPLITE(sk));
94221 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94222 IS_UDPLITE(sk));
94223 - atomic_inc(&sk->sk_drops);
94224 + atomic_inc_unchecked(&sk->sk_drops);
94225 __skb_unlink(skb, rcvq);
94226 __skb_queue_tail(&list_kill, skb);
94227 }
94228 @@ -1224,6 +1241,10 @@ try_again:
94229 if (!skb)
94230 goto out;
94231
94232 + err = gr_search_udp_recvmsg(sk, skb);
94233 + if (err)
94234 + goto out_free;
94235 +
94236 ulen = skb->len - sizeof(struct udphdr);
94237 copied = len;
94238 if (copied > ulen)
94239 @@ -1257,7 +1278,7 @@ try_again:
94240 if (unlikely(err)) {
94241 trace_kfree_skb(skb, udp_recvmsg);
94242 if (!peeked) {
94243 - atomic_inc(&sk->sk_drops);
94244 + atomic_inc_unchecked(&sk->sk_drops);
94245 UDP_INC_STATS_USER(sock_net(sk),
94246 UDP_MIB_INERRORS, is_udplite);
94247 }
94248 @@ -1544,7 +1565,7 @@ csum_error:
94249 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94250 drop:
94251 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94252 - atomic_inc(&sk->sk_drops);
94253 + atomic_inc_unchecked(&sk->sk_drops);
94254 kfree_skb(skb);
94255 return -1;
94256 }
94257 @@ -1563,7 +1584,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94258 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94259
94260 if (!skb1) {
94261 - atomic_inc(&sk->sk_drops);
94262 + atomic_inc_unchecked(&sk->sk_drops);
94263 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94264 IS_UDPLITE(sk));
94265 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94266 @@ -1735,6 +1756,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94267 goto csum_error;
94268
94269 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94270 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94271 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94272 +#endif
94273 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
94274
94275 /*
94276 @@ -2167,7 +2191,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
94277 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94278 0, sock_i_ino(sp),
94279 atomic_read(&sp->sk_refcnt), sp,
94280 - atomic_read(&sp->sk_drops), len);
94281 + atomic_read_unchecked(&sp->sk_drops), len);
94282 }
94283
94284 int udp4_seq_show(struct seq_file *seq, void *v)
94285 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
94286 index ccde542..eeb5ff7 100644
94287 --- a/net/ipv4/xfrm4_policy.c
94288 +++ b/net/ipv4/xfrm4_policy.c
94289 @@ -182,11 +182,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
94290 fl4->flowi4_tos = iph->tos;
94291 }
94292
94293 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
94294 +static int xfrm4_garbage_collect(struct dst_ops *ops)
94295 {
94296 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
94297
94298 - xfrm4_policy_afinfo.garbage_collect(net);
94299 + xfrm_garbage_collect_deferred(net);
94300 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
94301 }
94302
94303 @@ -265,19 +265,18 @@ static struct ctl_table xfrm4_policy_table[] = {
94304
94305 static int __net_init xfrm4_net_init(struct net *net)
94306 {
94307 - struct ctl_table *table;
94308 + ctl_table_no_const *table = NULL;
94309 struct ctl_table_header *hdr;
94310
94311 - table = xfrm4_policy_table;
94312 if (!net_eq(net, &init_net)) {
94313 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94314 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94315 if (!table)
94316 goto err_alloc;
94317
94318 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
94319 - }
94320 -
94321 - hdr = register_net_sysctl(net, "net/ipv4", table);
94322 + hdr = register_net_sysctl(net, "net/ipv4", table);
94323 + } else
94324 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
94325 if (!hdr)
94326 goto err_reg;
94327
94328 @@ -285,8 +284,7 @@ static int __net_init xfrm4_net_init(struct net *net)
94329 return 0;
94330
94331 err_reg:
94332 - if (!net_eq(net, &init_net))
94333 - kfree(table);
94334 + kfree(table);
94335 err_alloc:
94336 return -ENOMEM;
94337 }
94338 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
94339 index cd3fb30..b7dfef7 100644
94340 --- a/net/ipv6/addrconf.c
94341 +++ b/net/ipv6/addrconf.c
94342 @@ -586,7 +586,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
94343 idx = 0;
94344 head = &net->dev_index_head[h];
94345 rcu_read_lock();
94346 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
94347 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
94348 net->dev_base_seq;
94349 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94350 if (idx < s_idx)
94351 @@ -2364,7 +2364,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
94352 p.iph.ihl = 5;
94353 p.iph.protocol = IPPROTO_IPV6;
94354 p.iph.ttl = 64;
94355 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
94356 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
94357
94358 if (ops->ndo_do_ioctl) {
94359 mm_segment_t oldfs = get_fs();
94360 @@ -3977,7 +3977,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
94361 s_ip_idx = ip_idx = cb->args[2];
94362
94363 rcu_read_lock();
94364 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94365 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94366 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
94367 idx = 0;
94368 head = &net->dev_index_head[h];
94369 @@ -4603,7 +4603,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
94370 dst_free(&ifp->rt->dst);
94371 break;
94372 }
94373 - atomic_inc(&net->ipv6.dev_addr_genid);
94374 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
94375 rt_genid_bump_ipv6(net);
94376 }
94377
94378 @@ -4624,7 +4624,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
94379 int *valp = ctl->data;
94380 int val = *valp;
94381 loff_t pos = *ppos;
94382 - struct ctl_table lctl;
94383 + ctl_table_no_const lctl;
94384 int ret;
94385
94386 /*
94387 @@ -4709,7 +4709,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
94388 int *valp = ctl->data;
94389 int val = *valp;
94390 loff_t pos = *ppos;
94391 - struct ctl_table lctl;
94392 + ctl_table_no_const lctl;
94393 int ret;
94394
94395 /*
94396 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
94397 index 7c96100..bfd994a 100644
94398 --- a/net/ipv6/af_inet6.c
94399 +++ b/net/ipv6/af_inet6.c
94400 @@ -767,7 +767,7 @@ static int __net_init inet6_net_init(struct net *net)
94401
94402 net->ipv6.sysctl.bindv6only = 0;
94403 net->ipv6.sysctl.icmpv6_time = 1*HZ;
94404 - atomic_set(&net->ipv6.rt_genid, 0);
94405 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
94406
94407 err = ipv6_init_mibs(net);
94408 if (err)
94409 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
94410 index 48b6bd2..76d3458 100644
94411 --- a/net/ipv6/datagram.c
94412 +++ b/net/ipv6/datagram.c
94413 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
94414 0,
94415 sock_i_ino(sp),
94416 atomic_read(&sp->sk_refcnt), sp,
94417 - atomic_read(&sp->sk_drops));
94418 + atomic_read_unchecked(&sp->sk_drops));
94419 }
94420 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
94421 index eef8d94..cfa1852 100644
94422 --- a/net/ipv6/icmp.c
94423 +++ b/net/ipv6/icmp.c
94424 @@ -997,7 +997,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
94425
94426 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
94427 {
94428 - struct ctl_table *table;
94429 + ctl_table_no_const *table;
94430
94431 table = kmemdup(ipv6_icmp_table_template,
94432 sizeof(ipv6_icmp_table_template),
94433 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
94434 index bf4a9a0..e5f6ac5 100644
94435 --- a/net/ipv6/ip6_gre.c
94436 +++ b/net/ipv6/ip6_gre.c
94437 @@ -74,7 +74,7 @@ struct ip6gre_net {
94438 struct net_device *fb_tunnel_dev;
94439 };
94440
94441 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
94442 +static struct rtnl_link_ops ip6gre_link_ops;
94443 static int ip6gre_tunnel_init(struct net_device *dev);
94444 static void ip6gre_tunnel_setup(struct net_device *dev);
94445 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
94446 @@ -1286,7 +1286,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
94447 }
94448
94449
94450 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
94451 +static struct inet6_protocol ip6gre_protocol = {
94452 .handler = ip6gre_rcv,
94453 .err_handler = ip6gre_err,
94454 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
94455 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
94456 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
94457 };
94458
94459 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94460 +static struct rtnl_link_ops ip6gre_link_ops = {
94461 .kind = "ip6gre",
94462 .maxtype = IFLA_GRE_MAX,
94463 .policy = ip6gre_policy,
94464 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94465 .fill_info = ip6gre_fill_info,
94466 };
94467
94468 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
94469 +static struct rtnl_link_ops ip6gre_tap_ops = {
94470 .kind = "ip6gretap",
94471 .maxtype = IFLA_GRE_MAX,
94472 .policy = ip6gre_policy,
94473 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
94474 index 583b77e..99522b8 100644
94475 --- a/net/ipv6/ip6_tunnel.c
94476 +++ b/net/ipv6/ip6_tunnel.c
94477 @@ -89,7 +89,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
94478
94479 static int ip6_tnl_dev_init(struct net_device *dev);
94480 static void ip6_tnl_dev_setup(struct net_device *dev);
94481 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
94482 +static struct rtnl_link_ops ip6_link_ops;
94483
94484 static int ip6_tnl_net_id __read_mostly;
94485 struct ip6_tnl_net {
94486 @@ -1690,7 +1690,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
94487 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
94488 };
94489
94490 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
94491 +static struct rtnl_link_ops ip6_link_ops = {
94492 .kind = "ip6tnl",
94493 .maxtype = IFLA_IPTUN_MAX,
94494 .policy = ip6_tnl_policy,
94495 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
94496 index d1e2e8e..51c19ae 100644
94497 --- a/net/ipv6/ipv6_sockglue.c
94498 +++ b/net/ipv6/ipv6_sockglue.c
94499 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
94500 if (sk->sk_type != SOCK_STREAM)
94501 return -ENOPROTOOPT;
94502
94503 - msg.msg_control = optval;
94504 + msg.msg_control = (void __force_kernel *)optval;
94505 msg.msg_controllen = len;
94506 msg.msg_flags = flags;
94507
94508 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
94509 index 44400c2..8e11f52 100644
94510 --- a/net/ipv6/netfilter/ip6_tables.c
94511 +++ b/net/ipv6/netfilter/ip6_tables.c
94512 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
94513 #endif
94514
94515 static int get_info(struct net *net, void __user *user,
94516 - const int *len, int compat)
94517 + int len, int compat)
94518 {
94519 char name[XT_TABLE_MAXNAMELEN];
94520 struct xt_table *t;
94521 int ret;
94522
94523 - if (*len != sizeof(struct ip6t_getinfo)) {
94524 - duprintf("length %u != %zu\n", *len,
94525 + if (len != sizeof(struct ip6t_getinfo)) {
94526 + duprintf("length %u != %zu\n", len,
94527 sizeof(struct ip6t_getinfo));
94528 return -EINVAL;
94529 }
94530 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
94531 info.size = private->size;
94532 strcpy(info.name, name);
94533
94534 - if (copy_to_user(user, &info, *len) != 0)
94535 + if (copy_to_user(user, &info, len) != 0)
94536 ret = -EFAULT;
94537 else
94538 ret = 0;
94539 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94540
94541 switch (cmd) {
94542 case IP6T_SO_GET_INFO:
94543 - ret = get_info(sock_net(sk), user, len, 1);
94544 + ret = get_info(sock_net(sk), user, *len, 1);
94545 break;
94546 case IP6T_SO_GET_ENTRIES:
94547 ret = compat_get_entries(sock_net(sk), user, len);
94548 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94549
94550 switch (cmd) {
94551 case IP6T_SO_GET_INFO:
94552 - ret = get_info(sock_net(sk), user, len, 0);
94553 + ret = get_info(sock_net(sk), user, *len, 0);
94554 break;
94555
94556 case IP6T_SO_GET_ENTRIES:
94557 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
94558 index dffdc1a..ccc6678 100644
94559 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
94560 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
94561 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
94562
94563 static int nf_ct_frag6_sysctl_register(struct net *net)
94564 {
94565 - struct ctl_table *table;
94566 + ctl_table_no_const *table = NULL;
94567 struct ctl_table_header *hdr;
94568
94569 - table = nf_ct_frag6_sysctl_table;
94570 if (!net_eq(net, &init_net)) {
94571 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
94572 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
94573 GFP_KERNEL);
94574 if (table == NULL)
94575 goto err_alloc;
94576 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
94577 table[0].data = &net->nf_frag.frags.timeout;
94578 table[1].data = &net->nf_frag.frags.low_thresh;
94579 table[2].data = &net->nf_frag.frags.high_thresh;
94580 - }
94581 -
94582 - hdr = register_net_sysctl(net, "net/netfilter", table);
94583 + hdr = register_net_sysctl(net, "net/netfilter", table);
94584 + } else
94585 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
94586 if (hdr == NULL)
94587 goto err_reg;
94588
94589 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
94590 return 0;
94591
94592 err_reg:
94593 - if (!net_eq(net, &init_net))
94594 - kfree(table);
94595 + kfree(table);
94596 err_alloc:
94597 return -ENOMEM;
94598 }
94599 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
94600 index 827f795..7e28e82 100644
94601 --- a/net/ipv6/output_core.c
94602 +++ b/net/ipv6/output_core.c
94603 @@ -9,8 +9,8 @@
94604
94605 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
94606 {
94607 - static atomic_t ipv6_fragmentation_id;
94608 - int old, new;
94609 + static atomic_unchecked_t ipv6_fragmentation_id;
94610 + int id;
94611
94612 #if IS_ENABLED(CONFIG_IPV6)
94613 if (rt && !(rt->dst.flags & DST_NOPEER)) {
94614 @@ -26,13 +26,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
94615 }
94616 }
94617 #endif
94618 - do {
94619 - old = atomic_read(&ipv6_fragmentation_id);
94620 - new = old + 1;
94621 - if (!new)
94622 - new = 1;
94623 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
94624 - fhdr->identification = htonl(new);
94625 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
94626 + if (!id)
94627 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
94628 + fhdr->identification = htonl(id);
94629 }
94630 EXPORT_SYMBOL(ipv6_select_ident);
94631
94632 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
94633 index 18f19df..b46ada1 100644
94634 --- a/net/ipv6/ping.c
94635 +++ b/net/ipv6/ping.c
94636 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
94637 };
94638 #endif
94639
94640 +static struct pingv6_ops real_pingv6_ops = {
94641 + .ipv6_recv_error = ipv6_recv_error,
94642 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
94643 + .icmpv6_err_convert = icmpv6_err_convert,
94644 + .ipv6_icmp_error = ipv6_icmp_error,
94645 + .ipv6_chk_addr = ipv6_chk_addr,
94646 +};
94647 +
94648 +static struct pingv6_ops dummy_pingv6_ops = {
94649 + .ipv6_recv_error = dummy_ipv6_recv_error,
94650 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
94651 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
94652 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
94653 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
94654 +};
94655 +
94656 int __init pingv6_init(void)
94657 {
94658 #ifdef CONFIG_PROC_FS
94659 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
94660 if (ret)
94661 return ret;
94662 #endif
94663 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
94664 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
94665 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
94666 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
94667 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
94668 + pingv6_ops = &real_pingv6_ops;
94669 return inet6_register_protosw(&pingv6_protosw);
94670 }
94671
94672 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
94673 */
94674 void pingv6_exit(void)
94675 {
94676 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
94677 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
94678 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
94679 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
94680 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
94681 + pingv6_ops = &dummy_pingv6_ops;
94682 #ifdef CONFIG_PROC_FS
94683 unregister_pernet_subsys(&ping_v6_net_ops);
94684 #endif
94685 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
94686 index a4ed241..8bf6277 100644
94687 --- a/net/ipv6/raw.c
94688 +++ b/net/ipv6/raw.c
94689 @@ -385,7 +385,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
94690 {
94691 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
94692 skb_checksum_complete(skb)) {
94693 - atomic_inc(&sk->sk_drops);
94694 + atomic_inc_unchecked(&sk->sk_drops);
94695 kfree_skb(skb);
94696 return NET_RX_DROP;
94697 }
94698 @@ -413,7 +413,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94699 struct raw6_sock *rp = raw6_sk(sk);
94700
94701 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
94702 - atomic_inc(&sk->sk_drops);
94703 + atomic_inc_unchecked(&sk->sk_drops);
94704 kfree_skb(skb);
94705 return NET_RX_DROP;
94706 }
94707 @@ -437,7 +437,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94708
94709 if (inet->hdrincl) {
94710 if (skb_checksum_complete(skb)) {
94711 - atomic_inc(&sk->sk_drops);
94712 + atomic_inc_unchecked(&sk->sk_drops);
94713 kfree_skb(skb);
94714 return NET_RX_DROP;
94715 }
94716 @@ -609,7 +609,7 @@ out:
94717 return err;
94718 }
94719
94720 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
94721 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
94722 struct flowi6 *fl6, struct dst_entry **dstp,
94723 unsigned int flags)
94724 {
94725 @@ -922,12 +922,15 @@ do_confirm:
94726 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
94727 char __user *optval, int optlen)
94728 {
94729 + struct icmp6_filter filter;
94730 +
94731 switch (optname) {
94732 case ICMPV6_FILTER:
94733 if (optlen > sizeof(struct icmp6_filter))
94734 optlen = sizeof(struct icmp6_filter);
94735 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
94736 + if (copy_from_user(&filter, optval, optlen))
94737 return -EFAULT;
94738 + raw6_sk(sk)->filter = filter;
94739 return 0;
94740 default:
94741 return -ENOPROTOOPT;
94742 @@ -940,6 +943,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94743 char __user *optval, int __user *optlen)
94744 {
94745 int len;
94746 + struct icmp6_filter filter;
94747
94748 switch (optname) {
94749 case ICMPV6_FILTER:
94750 @@ -951,7 +955,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94751 len = sizeof(struct icmp6_filter);
94752 if (put_user(len, optlen))
94753 return -EFAULT;
94754 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
94755 + filter = raw6_sk(sk)->filter;
94756 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
94757 return -EFAULT;
94758 return 0;
94759 default:
94760 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
94761 index 1aeb473..bea761c 100644
94762 --- a/net/ipv6/reassembly.c
94763 +++ b/net/ipv6/reassembly.c
94764 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
94765
94766 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94767 {
94768 - struct ctl_table *table;
94769 + ctl_table_no_const *table = NULL;
94770 struct ctl_table_header *hdr;
94771
94772 - table = ip6_frags_ns_ctl_table;
94773 if (!net_eq(net, &init_net)) {
94774 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94775 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94776 if (table == NULL)
94777 goto err_alloc;
94778
94779 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94780 /* Don't export sysctls to unprivileged users */
94781 if (net->user_ns != &init_user_ns)
94782 table[0].procname = NULL;
94783 - }
94784 + hdr = register_net_sysctl(net, "net/ipv6", table);
94785 + } else
94786 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
94787
94788 - hdr = register_net_sysctl(net, "net/ipv6", table);
94789 if (hdr == NULL)
94790 goto err_reg;
94791
94792 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94793 return 0;
94794
94795 err_reg:
94796 - if (!net_eq(net, &init_net))
94797 - kfree(table);
94798 + kfree(table);
94799 err_alloc:
94800 return -ENOMEM;
94801 }
94802 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
94803 index 04e17b3..83502e9 100644
94804 --- a/net/ipv6/route.c
94805 +++ b/net/ipv6/route.c
94806 @@ -3006,7 +3006,7 @@ struct ctl_table ipv6_route_table_template[] = {
94807
94808 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
94809 {
94810 - struct ctl_table *table;
94811 + ctl_table_no_const *table;
94812
94813 table = kmemdup(ipv6_route_table_template,
94814 sizeof(ipv6_route_table_template),
94815 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
94816 index 1926945..30a1a57 100644
94817 --- a/net/ipv6/sit.c
94818 +++ b/net/ipv6/sit.c
94819 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
94820 static void ipip6_dev_free(struct net_device *dev);
94821 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
94822 __be32 *v4dst);
94823 -static struct rtnl_link_ops sit_link_ops __read_mostly;
94824 +static struct rtnl_link_ops sit_link_ops;
94825
94826 static int sit_net_id __read_mostly;
94827 struct sit_net {
94828 @@ -1594,7 +1594,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
94829 #endif
94830 };
94831
94832 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
94833 +static struct rtnl_link_ops sit_link_ops = {
94834 .kind = "sit",
94835 .maxtype = IFLA_IPTUN_MAX,
94836 .policy = ipip6_policy,
94837 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
94838 index 107b2f1..72741a9 100644
94839 --- a/net/ipv6/sysctl_net_ipv6.c
94840 +++ b/net/ipv6/sysctl_net_ipv6.c
94841 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
94842
94843 static int __net_init ipv6_sysctl_net_init(struct net *net)
94844 {
94845 - struct ctl_table *ipv6_table;
94846 + ctl_table_no_const *ipv6_table;
94847 struct ctl_table *ipv6_route_table;
94848 struct ctl_table *ipv6_icmp_table;
94849 int err;
94850 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
94851 index 5c71501..7e8d5d3 100644
94852 --- a/net/ipv6/tcp_ipv6.c
94853 +++ b/net/ipv6/tcp_ipv6.c
94854 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
94855 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
94856 }
94857
94858 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94859 +extern int grsec_enable_blackhole;
94860 +#endif
94861 +
94862 static void tcp_v6_hash(struct sock *sk)
94863 {
94864 if (sk->sk_state != TCP_CLOSE) {
94865 @@ -1397,6 +1401,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
94866 return 0;
94867
94868 reset:
94869 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94870 + if (!grsec_enable_blackhole)
94871 +#endif
94872 tcp_v6_send_reset(sk, skb);
94873 discard:
94874 if (opt_skb)
94875 @@ -1479,12 +1486,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
94876 TCP_SKB_CB(skb)->sacked = 0;
94877
94878 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94879 - if (!sk)
94880 + if (!sk) {
94881 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94882 + ret = 1;
94883 +#endif
94884 goto no_tcp_socket;
94885 + }
94886
94887 process:
94888 - if (sk->sk_state == TCP_TIME_WAIT)
94889 + if (sk->sk_state == TCP_TIME_WAIT) {
94890 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94891 + ret = 2;
94892 +#endif
94893 goto do_time_wait;
94894 + }
94895
94896 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
94897 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94898 @@ -1536,6 +1551,10 @@ csum_error:
94899 bad_packet:
94900 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94901 } else {
94902 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94903 + if (!grsec_enable_blackhole || (ret == 1 &&
94904 + (skb->dev->flags & IFF_LOOPBACK)))
94905 +#endif
94906 tcp_v6_send_reset(NULL, skb);
94907 }
94908
94909 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
94910 index 1878609..b48e1d4 100644
94911 --- a/net/ipv6/udp.c
94912 +++ b/net/ipv6/udp.c
94913 @@ -53,6 +53,10 @@
94914 #include <trace/events/skb.h>
94915 #include "udp_impl.h"
94916
94917 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94918 +extern int grsec_enable_blackhole;
94919 +#endif
94920 +
94921 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
94922 {
94923 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
94924 @@ -420,7 +424,7 @@ try_again:
94925 if (unlikely(err)) {
94926 trace_kfree_skb(skb, udpv6_recvmsg);
94927 if (!peeked) {
94928 - atomic_inc(&sk->sk_drops);
94929 + atomic_inc_unchecked(&sk->sk_drops);
94930 if (is_udp4)
94931 UDP_INC_STATS_USER(sock_net(sk),
94932 UDP_MIB_INERRORS,
94933 @@ -668,7 +672,7 @@ csum_error:
94934 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94935 drop:
94936 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94937 - atomic_inc(&sk->sk_drops);
94938 + atomic_inc_unchecked(&sk->sk_drops);
94939 kfree_skb(skb);
94940 return -1;
94941 }
94942 @@ -726,7 +730,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94943 if (likely(skb1 == NULL))
94944 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94945 if (!skb1) {
94946 - atomic_inc(&sk->sk_drops);
94947 + atomic_inc_unchecked(&sk->sk_drops);
94948 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94949 IS_UDPLITE(sk));
94950 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94951 @@ -866,6 +870,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94952 goto csum_error;
94953
94954 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94955 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94956 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94957 +#endif
94958 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
94959
94960 kfree_skb(skb);
94961 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
94962 index 08ed277..80e4bc8 100644
94963 --- a/net/ipv6/xfrm6_policy.c
94964 +++ b/net/ipv6/xfrm6_policy.c
94965 @@ -208,11 +208,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
94966 }
94967 }
94968
94969 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
94970 +static int xfrm6_garbage_collect(struct dst_ops *ops)
94971 {
94972 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
94973
94974 - xfrm6_policy_afinfo.garbage_collect(net);
94975 + xfrm_garbage_collect_deferred(net);
94976 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
94977 }
94978
94979 @@ -325,19 +325,19 @@ static struct ctl_table xfrm6_policy_table[] = {
94980
94981 static int __net_init xfrm6_net_init(struct net *net)
94982 {
94983 - struct ctl_table *table;
94984 + ctl_table_no_const *table = NULL;
94985 struct ctl_table_header *hdr;
94986
94987 - table = xfrm6_policy_table;
94988 if (!net_eq(net, &init_net)) {
94989 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94990 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94991 if (!table)
94992 goto err_alloc;
94993
94994 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
94995 - }
94996 + hdr = register_net_sysctl(net, "net/ipv6", table);
94997 + } else
94998 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
94999
95000 - hdr = register_net_sysctl(net, "net/ipv6", table);
95001 if (!hdr)
95002 goto err_reg;
95003
95004 @@ -345,8 +345,7 @@ static int __net_init xfrm6_net_init(struct net *net)
95005 return 0;
95006
95007 err_reg:
95008 - if (!net_eq(net, &init_net))
95009 - kfree(table);
95010 + kfree(table);
95011 err_alloc:
95012 return -ENOMEM;
95013 }
95014 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
95015 index 41ac7938..75e3bb1 100644
95016 --- a/net/irda/ircomm/ircomm_tty.c
95017 +++ b/net/irda/ircomm/ircomm_tty.c
95018 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95019 add_wait_queue(&port->open_wait, &wait);
95020
95021 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
95022 - __FILE__, __LINE__, tty->driver->name, port->count);
95023 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95024
95025 spin_lock_irqsave(&port->lock, flags);
95026 if (!tty_hung_up_p(filp))
95027 - port->count--;
95028 + atomic_dec(&port->count);
95029 port->blocked_open++;
95030 spin_unlock_irqrestore(&port->lock, flags);
95031
95032 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95033 }
95034
95035 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
95036 - __FILE__, __LINE__, tty->driver->name, port->count);
95037 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95038
95039 schedule();
95040 }
95041 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95042
95043 spin_lock_irqsave(&port->lock, flags);
95044 if (!tty_hung_up_p(filp))
95045 - port->count++;
95046 + atomic_inc(&port->count);
95047 port->blocked_open--;
95048 spin_unlock_irqrestore(&port->lock, flags);
95049
95050 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
95051 - __FILE__, __LINE__, tty->driver->name, port->count);
95052 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95053
95054 if (!retval)
95055 port->flags |= ASYNC_NORMAL_ACTIVE;
95056 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
95057
95058 /* ++ is not atomic, so this should be protected - Jean II */
95059 spin_lock_irqsave(&self->port.lock, flags);
95060 - self->port.count++;
95061 + atomic_inc(&self->port.count);
95062 spin_unlock_irqrestore(&self->port.lock, flags);
95063 tty_port_tty_set(&self->port, tty);
95064
95065 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
95066 - self->line, self->port.count);
95067 + self->line, atomic_read(&self->port.count));
95068
95069 /* Not really used by us, but lets do it anyway */
95070 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
95071 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
95072 tty_kref_put(port->tty);
95073 }
95074 port->tty = NULL;
95075 - port->count = 0;
95076 + atomic_set(&port->count, 0);
95077 spin_unlock_irqrestore(&port->lock, flags);
95078
95079 wake_up_interruptible(&port->open_wait);
95080 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
95081 seq_putc(m, '\n');
95082
95083 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
95084 - seq_printf(m, "Open count: %d\n", self->port.count);
95085 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
95086 seq_printf(m, "Max data size: %d\n", self->max_data_size);
95087 seq_printf(m, "Max header size: %d\n", self->max_header_size);
95088
95089 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
95090 index 168aff5..9d43132 100644
95091 --- a/net/iucv/af_iucv.c
95092 +++ b/net/iucv/af_iucv.c
95093 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
95094
95095 write_lock_bh(&iucv_sk_list.lock);
95096
95097 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
95098 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95099 while (__iucv_get_sock_by_name(name)) {
95100 sprintf(name, "%08x",
95101 - atomic_inc_return(&iucv_sk_list.autobind_name));
95102 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95103 }
95104
95105 write_unlock_bh(&iucv_sk_list.lock);
95106 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
95107 index cd5b8ec..f205e6b 100644
95108 --- a/net/iucv/iucv.c
95109 +++ b/net/iucv/iucv.c
95110 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
95111 return NOTIFY_OK;
95112 }
95113
95114 -static struct notifier_block __refdata iucv_cpu_notifier = {
95115 +static struct notifier_block iucv_cpu_notifier = {
95116 .notifier_call = iucv_cpu_notify,
95117 };
95118
95119 diff --git a/net/key/af_key.c b/net/key/af_key.c
95120 index 911ef03..58f9c96 100644
95121 --- a/net/key/af_key.c
95122 +++ b/net/key/af_key.c
95123 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
95124 static u32 get_acqseq(void)
95125 {
95126 u32 res;
95127 - static atomic_t acqseq;
95128 + static atomic_unchecked_t acqseq;
95129
95130 do {
95131 - res = atomic_inc_return(&acqseq);
95132 + res = atomic_inc_return_unchecked(&acqseq);
95133 } while (!res);
95134 return res;
95135 }
95136 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
95137 index 629dee7..4bdd2c8 100644
95138 --- a/net/mac80211/cfg.c
95139 +++ b/net/mac80211/cfg.c
95140 @@ -826,7 +826,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
95141 ret = ieee80211_vif_use_channel(sdata, chandef,
95142 IEEE80211_CHANCTX_EXCLUSIVE);
95143 }
95144 - } else if (local->open_count == local->monitors) {
95145 + } else if (local_read(&local->open_count) == local->monitors) {
95146 local->_oper_chandef = *chandef;
95147 ieee80211_hw_config(local, 0);
95148 }
95149 @@ -3125,7 +3125,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
95150 else
95151 local->probe_req_reg--;
95152
95153 - if (!local->open_count)
95154 + if (!local_read(&local->open_count))
95155 break;
95156
95157 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
95158 @@ -3588,8 +3588,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
95159 if (chanctx_conf) {
95160 *chandef = chanctx_conf->def;
95161 ret = 0;
95162 - } else if (local->open_count > 0 &&
95163 - local->open_count == local->monitors &&
95164 + } else if (local_read(&local->open_count) > 0 &&
95165 + local_read(&local->open_count) == local->monitors &&
95166 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
95167 if (local->use_chanctx)
95168 *chandef = local->monitor_chandef;
95169 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
95170 index 611abfc..8c2c7e4 100644
95171 --- a/net/mac80211/ieee80211_i.h
95172 +++ b/net/mac80211/ieee80211_i.h
95173 @@ -28,6 +28,7 @@
95174 #include <net/ieee80211_radiotap.h>
95175 #include <net/cfg80211.h>
95176 #include <net/mac80211.h>
95177 +#include <asm/local.h>
95178 #include "key.h"
95179 #include "sta_info.h"
95180 #include "debug.h"
95181 @@ -945,7 +946,7 @@ struct ieee80211_local {
95182 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
95183 spinlock_t queue_stop_reason_lock;
95184
95185 - int open_count;
95186 + local_t open_count;
95187 int monitors, cooked_mntrs;
95188 /* number of interfaces with corresponding FIF_ flags */
95189 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
95190 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
95191 index fcecd63..a404454 100644
95192 --- a/net/mac80211/iface.c
95193 +++ b/net/mac80211/iface.c
95194 @@ -519,7 +519,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95195 break;
95196 }
95197
95198 - if (local->open_count == 0) {
95199 + if (local_read(&local->open_count) == 0) {
95200 res = drv_start(local);
95201 if (res)
95202 goto err_del_bss;
95203 @@ -566,7 +566,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95204 res = drv_add_interface(local, sdata);
95205 if (res)
95206 goto err_stop;
95207 - } else if (local->monitors == 0 && local->open_count == 0) {
95208 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
95209 res = ieee80211_add_virtual_monitor(local);
95210 if (res)
95211 goto err_stop;
95212 @@ -675,7 +675,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95213 atomic_inc(&local->iff_promiscs);
95214
95215 if (coming_up)
95216 - local->open_count++;
95217 + local_inc(&local->open_count);
95218
95219 if (hw_reconf_flags)
95220 ieee80211_hw_config(local, hw_reconf_flags);
95221 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95222 err_del_interface:
95223 drv_remove_interface(local, sdata);
95224 err_stop:
95225 - if (!local->open_count)
95226 + if (!local_read(&local->open_count))
95227 drv_stop(local);
95228 err_del_bss:
95229 sdata->bss = NULL;
95230 @@ -852,7 +852,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95231 }
95232
95233 if (going_down)
95234 - local->open_count--;
95235 + local_dec(&local->open_count);
95236
95237 switch (sdata->vif.type) {
95238 case NL80211_IFTYPE_AP_VLAN:
95239 @@ -919,7 +919,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95240 }
95241 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
95242
95243 - if (local->open_count == 0)
95244 + if (local_read(&local->open_count) == 0)
95245 ieee80211_clear_tx_pending(local);
95246
95247 /*
95248 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95249
95250 ieee80211_recalc_ps(local, -1);
95251
95252 - if (local->open_count == 0) {
95253 + if (local_read(&local->open_count) == 0) {
95254 ieee80211_stop_device(local);
95255
95256 /* no reconfiguring after stop! */
95257 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95258 ieee80211_configure_filter(local);
95259 ieee80211_hw_config(local, hw_reconf_flags);
95260
95261 - if (local->monitors == local->open_count)
95262 + if (local->monitors == local_read(&local->open_count))
95263 ieee80211_add_virtual_monitor(local);
95264 }
95265
95266 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
95267 index 21d5d44..4fee18a 100644
95268 --- a/net/mac80211/main.c
95269 +++ b/net/mac80211/main.c
95270 @@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
95271 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
95272 IEEE80211_CONF_CHANGE_POWER);
95273
95274 - if (changed && local->open_count) {
95275 + if (changed && local_read(&local->open_count)) {
95276 ret = drv_config(local, changed);
95277 /*
95278 * Goal:
95279 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
95280 index 3401262..d5cd68d 100644
95281 --- a/net/mac80211/pm.c
95282 +++ b/net/mac80211/pm.c
95283 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95284 struct ieee80211_sub_if_data *sdata;
95285 struct sta_info *sta;
95286
95287 - if (!local->open_count)
95288 + if (!local_read(&local->open_count))
95289 goto suspend;
95290
95291 ieee80211_scan_cancel(local);
95292 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95293 cancel_work_sync(&local->dynamic_ps_enable_work);
95294 del_timer_sync(&local->dynamic_ps_timer);
95295
95296 - local->wowlan = wowlan && local->open_count;
95297 + local->wowlan = wowlan && local_read(&local->open_count);
95298 if (local->wowlan) {
95299 int err = drv_suspend(local, wowlan);
95300 if (err < 0) {
95301 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95302 WARN_ON(!list_empty(&local->chanctx_list));
95303
95304 /* stop hardware - this must stop RX */
95305 - if (local->open_count)
95306 + if (local_read(&local->open_count))
95307 ieee80211_stop_device(local);
95308
95309 suspend:
95310 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
95311 index e126605..73d2c39 100644
95312 --- a/net/mac80211/rate.c
95313 +++ b/net/mac80211/rate.c
95314 @@ -725,7 +725,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
95315
95316 ASSERT_RTNL();
95317
95318 - if (local->open_count)
95319 + if (local_read(&local->open_count))
95320 return -EBUSY;
95321
95322 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
95323 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
95324 index c97a065..ff61928 100644
95325 --- a/net/mac80211/rc80211_pid_debugfs.c
95326 +++ b/net/mac80211/rc80211_pid_debugfs.c
95327 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
95328
95329 spin_unlock_irqrestore(&events->lock, status);
95330
95331 - if (copy_to_user(buf, pb, p))
95332 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
95333 return -EFAULT;
95334
95335 return p;
95336 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
95337 index 69e4ef5..e8e4b92 100644
95338 --- a/net/mac80211/util.c
95339 +++ b/net/mac80211/util.c
95340 @@ -1470,7 +1470,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95341 }
95342 #endif
95343 /* everything else happens only if HW was up & running */
95344 - if (!local->open_count)
95345 + if (!local_read(&local->open_count))
95346 goto wake_up;
95347
95348 /*
95349 @@ -1695,7 +1695,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95350 local->in_reconfig = false;
95351 barrier();
95352
95353 - if (local->monitors == local->open_count && local->monitors > 0)
95354 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
95355 ieee80211_add_virtual_monitor(local);
95356
95357 /*
95358 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
95359 index 6e839b6..002a233 100644
95360 --- a/net/netfilter/Kconfig
95361 +++ b/net/netfilter/Kconfig
95362 @@ -950,6 +950,16 @@ config NETFILTER_XT_MATCH_ESP
95363
95364 To compile it as a module, choose M here. If unsure, say N.
95365
95366 +config NETFILTER_XT_MATCH_GRADM
95367 + tristate '"gradm" match support'
95368 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
95369 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
95370 + ---help---
95371 + The gradm match allows to match on grsecurity RBAC being enabled.
95372 + It is useful when iptables rules are applied early on bootup to
95373 + prevent connections to the machine (except from a trusted host)
95374 + while the RBAC system is disabled.
95375 +
95376 config NETFILTER_XT_MATCH_HASHLIMIT
95377 tristate '"hashlimit" match support'
95378 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
95379 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
95380 index c3a0a12..90b587f 100644
95381 --- a/net/netfilter/Makefile
95382 +++ b/net/netfilter/Makefile
95383 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
95384 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
95385 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
95386 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
95387 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
95388 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
95389 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
95390 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
95391 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
95392 index f2e30fb..f131862 100644
95393 --- a/net/netfilter/ipset/ip_set_core.c
95394 +++ b/net/netfilter/ipset/ip_set_core.c
95395 @@ -1819,7 +1819,7 @@ done:
95396 return ret;
95397 }
95398
95399 -static struct nf_sockopt_ops so_set __read_mostly = {
95400 +static struct nf_sockopt_ops so_set = {
95401 .pf = PF_INET,
95402 .get_optmin = SO_IP_SET,
95403 .get_optmax = SO_IP_SET + 1,
95404 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
95405 index 4c8e5c0..5a79b4d 100644
95406 --- a/net/netfilter/ipvs/ip_vs_conn.c
95407 +++ b/net/netfilter/ipvs/ip_vs_conn.c
95408 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
95409 /* Increase the refcnt counter of the dest */
95410 ip_vs_dest_hold(dest);
95411
95412 - conn_flags = atomic_read(&dest->conn_flags);
95413 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
95414 if (cp->protocol != IPPROTO_UDP)
95415 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
95416 flags = cp->flags;
95417 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
95418
95419 cp->control = NULL;
95420 atomic_set(&cp->n_control, 0);
95421 - atomic_set(&cp->in_pkts, 0);
95422 + atomic_set_unchecked(&cp->in_pkts, 0);
95423
95424 cp->packet_xmit = NULL;
95425 cp->app = NULL;
95426 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
95427
95428 /* Don't drop the entry if its number of incoming packets is not
95429 located in [0, 8] */
95430 - i = atomic_read(&cp->in_pkts);
95431 + i = atomic_read_unchecked(&cp->in_pkts);
95432 if (i > 8 || i < 0) return 0;
95433
95434 if (!todrop_rate[i]) return 0;
95435 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
95436 index 74fd00c..06e7ac7 100644
95437 --- a/net/netfilter/ipvs/ip_vs_core.c
95438 +++ b/net/netfilter/ipvs/ip_vs_core.c
95439 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
95440 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
95441 /* do not touch skb anymore */
95442
95443 - atomic_inc(&cp->in_pkts);
95444 + atomic_inc_unchecked(&cp->in_pkts);
95445 ip_vs_conn_put(cp);
95446 return ret;
95447 }
95448 @@ -1719,7 +1719,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
95449 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
95450 pkts = sysctl_sync_threshold(ipvs);
95451 else
95452 - pkts = atomic_add_return(1, &cp->in_pkts);
95453 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95454
95455 if (ipvs->sync_state & IP_VS_STATE_MASTER)
95456 ip_vs_sync_conn(net, cp, pkts);
95457 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
95458 index a3df9bd..895ae09 100644
95459 --- a/net/netfilter/ipvs/ip_vs_ctl.c
95460 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
95461 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
95462 */
95463 ip_vs_rs_hash(ipvs, dest);
95464 }
95465 - atomic_set(&dest->conn_flags, conn_flags);
95466 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
95467
95468 /* bind the service */
95469 old_svc = rcu_dereference_protected(dest->svc, 1);
95470 @@ -1641,7 +1641,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
95471 * align with netns init in ip_vs_control_net_init()
95472 */
95473
95474 -static struct ctl_table vs_vars[] = {
95475 +static ctl_table_no_const vs_vars[] __read_only = {
95476 {
95477 .procname = "amemthresh",
95478 .maxlen = sizeof(int),
95479 @@ -2062,7 +2062,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95480 " %-7s %-6d %-10d %-10d\n",
95481 &dest->addr.in6,
95482 ntohs(dest->port),
95483 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95484 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95485 atomic_read(&dest->weight),
95486 atomic_read(&dest->activeconns),
95487 atomic_read(&dest->inactconns));
95488 @@ -2073,7 +2073,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95489 "%-7s %-6d %-10d %-10d\n",
95490 ntohl(dest->addr.ip),
95491 ntohs(dest->port),
95492 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95493 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95494 atomic_read(&dest->weight),
95495 atomic_read(&dest->activeconns),
95496 atomic_read(&dest->inactconns));
95497 @@ -2551,7 +2551,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
95498
95499 entry.addr = dest->addr.ip;
95500 entry.port = dest->port;
95501 - entry.conn_flags = atomic_read(&dest->conn_flags);
95502 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
95503 entry.weight = atomic_read(&dest->weight);
95504 entry.u_threshold = dest->u_threshold;
95505 entry.l_threshold = dest->l_threshold;
95506 @@ -3094,7 +3094,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
95507 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
95508 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
95509 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
95510 - (atomic_read(&dest->conn_flags) &
95511 + (atomic_read_unchecked(&dest->conn_flags) &
95512 IP_VS_CONN_F_FWD_MASK)) ||
95513 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
95514 atomic_read(&dest->weight)) ||
95515 @@ -3684,7 +3684,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
95516 {
95517 int idx;
95518 struct netns_ipvs *ipvs = net_ipvs(net);
95519 - struct ctl_table *tbl;
95520 + ctl_table_no_const *tbl;
95521
95522 atomic_set(&ipvs->dropentry, 0);
95523 spin_lock_init(&ipvs->dropentry_lock);
95524 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
95525 index eff13c9..c1aab3e 100644
95526 --- a/net/netfilter/ipvs/ip_vs_lblc.c
95527 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
95528 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
95529 * IPVS LBLC sysctl table
95530 */
95531 #ifdef CONFIG_SYSCTL
95532 -static struct ctl_table vs_vars_table[] = {
95533 +static ctl_table_no_const vs_vars_table[] __read_only = {
95534 {
95535 .procname = "lblc_expiration",
95536 .data = NULL,
95537 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
95538 index 0b85500..8513fa5 100644
95539 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
95540 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
95541 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
95542 * IPVS LBLCR sysctl table
95543 */
95544
95545 -static struct ctl_table vs_vars_table[] = {
95546 +static ctl_table_no_const vs_vars_table[] __read_only = {
95547 {
95548 .procname = "lblcr_expiration",
95549 .data = NULL,
95550 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
95551 index f448471..995f131 100644
95552 --- a/net/netfilter/ipvs/ip_vs_sync.c
95553 +++ b/net/netfilter/ipvs/ip_vs_sync.c
95554 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
95555 cp = cp->control;
95556 if (cp) {
95557 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95558 - pkts = atomic_add_return(1, &cp->in_pkts);
95559 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95560 else
95561 pkts = sysctl_sync_threshold(ipvs);
95562 ip_vs_sync_conn(net, cp->control, pkts);
95563 @@ -771,7 +771,7 @@ control:
95564 if (!cp)
95565 return;
95566 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95567 - pkts = atomic_add_return(1, &cp->in_pkts);
95568 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95569 else
95570 pkts = sysctl_sync_threshold(ipvs);
95571 goto sloop;
95572 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
95573
95574 if (opt)
95575 memcpy(&cp->in_seq, opt, sizeof(*opt));
95576 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95577 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95578 cp->state = state;
95579 cp->old_state = cp->state;
95580 /*
95581 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
95582 index c47444e..b0961c6 100644
95583 --- a/net/netfilter/ipvs/ip_vs_xmit.c
95584 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
95585 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
95586 else
95587 rc = NF_ACCEPT;
95588 /* do not touch skb anymore */
95589 - atomic_inc(&cp->in_pkts);
95590 + atomic_inc_unchecked(&cp->in_pkts);
95591 goto out;
95592 }
95593
95594 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
95595 else
95596 rc = NF_ACCEPT;
95597 /* do not touch skb anymore */
95598 - atomic_inc(&cp->in_pkts);
95599 + atomic_inc_unchecked(&cp->in_pkts);
95600 goto out;
95601 }
95602
95603 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
95604 index 2d3030a..7ba1c0a 100644
95605 --- a/net/netfilter/nf_conntrack_acct.c
95606 +++ b/net/netfilter/nf_conntrack_acct.c
95607 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
95608 #ifdef CONFIG_SYSCTL
95609 static int nf_conntrack_acct_init_sysctl(struct net *net)
95610 {
95611 - struct ctl_table *table;
95612 + ctl_table_no_const *table;
95613
95614 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
95615 GFP_KERNEL);
95616 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
95617 index 5d892fe..d2fc9d8 100644
95618 --- a/net/netfilter/nf_conntrack_core.c
95619 +++ b/net/netfilter/nf_conntrack_core.c
95620 @@ -1600,6 +1600,10 @@ void nf_conntrack_init_end(void)
95621 #define DYING_NULLS_VAL ((1<<30)+1)
95622 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
95623
95624 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95625 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
95626 +#endif
95627 +
95628 int nf_conntrack_init_net(struct net *net)
95629 {
95630 int ret;
95631 @@ -1614,7 +1618,11 @@ int nf_conntrack_init_net(struct net *net)
95632 goto err_stat;
95633 }
95634
95635 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95636 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
95637 +#else
95638 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
95639 +#endif
95640 if (!net->ct.slabname) {
95641 ret = -ENOMEM;
95642 goto err_slabname;
95643 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
95644 index 1df1761..ce8b88a 100644
95645 --- a/net/netfilter/nf_conntrack_ecache.c
95646 +++ b/net/netfilter/nf_conntrack_ecache.c
95647 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
95648 #ifdef CONFIG_SYSCTL
95649 static int nf_conntrack_event_init_sysctl(struct net *net)
95650 {
95651 - struct ctl_table *table;
95652 + ctl_table_no_const *table;
95653
95654 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
95655 GFP_KERNEL);
95656 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
95657 index 974a2a4..52cc6ff 100644
95658 --- a/net/netfilter/nf_conntrack_helper.c
95659 +++ b/net/netfilter/nf_conntrack_helper.c
95660 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
95661
95662 static int nf_conntrack_helper_init_sysctl(struct net *net)
95663 {
95664 - struct ctl_table *table;
95665 + ctl_table_no_const *table;
95666
95667 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
95668 GFP_KERNEL);
95669 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
95670 index ce30041..3861b5d 100644
95671 --- a/net/netfilter/nf_conntrack_proto.c
95672 +++ b/net/netfilter/nf_conntrack_proto.c
95673 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
95674
95675 static void
95676 nf_ct_unregister_sysctl(struct ctl_table_header **header,
95677 - struct ctl_table **table,
95678 + ctl_table_no_const **table,
95679 unsigned int users)
95680 {
95681 if (users > 0)
95682 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
95683 index a99b6c3..cb372f9 100644
95684 --- a/net/netfilter/nf_conntrack_proto_dccp.c
95685 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
95686 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95687 const char *msg;
95688 u_int8_t state;
95689
95690 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95691 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95692 BUG_ON(dh == NULL);
95693
95694 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
95695 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95696 out_invalid:
95697 if (LOG_INVALID(net, IPPROTO_DCCP))
95698 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
95699 - NULL, msg);
95700 + NULL, "%s", msg);
95701 return false;
95702 }
95703
95704 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
95705 u_int8_t type, old_state, new_state;
95706 enum ct_dccp_roles role;
95707
95708 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95709 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95710 BUG_ON(dh == NULL);
95711 type = dh->dccph_type;
95712
95713 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95714 unsigned int cscov;
95715 const char *msg;
95716
95717 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95718 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95719 if (dh == NULL) {
95720 msg = "nf_ct_dccp: short packet ";
95721 goto out_invalid;
95722 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95723
95724 out_invalid:
95725 if (LOG_INVALID(net, IPPROTO_DCCP))
95726 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
95727 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
95728 return -NF_ACCEPT;
95729 }
95730
95731 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
95732 index f641751..d3c5b51 100644
95733 --- a/net/netfilter/nf_conntrack_standalone.c
95734 +++ b/net/netfilter/nf_conntrack_standalone.c
95735 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
95736
95737 static int nf_conntrack_standalone_init_sysctl(struct net *net)
95738 {
95739 - struct ctl_table *table;
95740 + ctl_table_no_const *table;
95741
95742 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
95743 GFP_KERNEL);
95744 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
95745 index 902fb0a..87f7fdb 100644
95746 --- a/net/netfilter/nf_conntrack_timestamp.c
95747 +++ b/net/netfilter/nf_conntrack_timestamp.c
95748 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
95749 #ifdef CONFIG_SYSCTL
95750 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
95751 {
95752 - struct ctl_table *table;
95753 + ctl_table_no_const *table;
95754
95755 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
95756 GFP_KERNEL);
95757 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
95758 index 85296d4..8becdec 100644
95759 --- a/net/netfilter/nf_log.c
95760 +++ b/net/netfilter/nf_log.c
95761 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
95762
95763 #ifdef CONFIG_SYSCTL
95764 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
95765 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
95766 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
95767
95768 static int nf_log_proc_dostring(struct ctl_table *table, int write,
95769 void __user *buffer, size_t *lenp, loff_t *ppos)
95770 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
95771 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
95772 mutex_unlock(&nf_log_mutex);
95773 } else {
95774 + ctl_table_no_const nf_log_table = *table;
95775 +
95776 mutex_lock(&nf_log_mutex);
95777 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
95778 lockdep_is_held(&nf_log_mutex));
95779 if (!logger)
95780 - table->data = "NONE";
95781 + nf_log_table.data = "NONE";
95782 else
95783 - table->data = logger->name;
95784 - r = proc_dostring(table, write, buffer, lenp, ppos);
95785 + nf_log_table.data = logger->name;
95786 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
95787 mutex_unlock(&nf_log_mutex);
95788 }
95789
95790 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
95791 index f042ae5..30ea486 100644
95792 --- a/net/netfilter/nf_sockopt.c
95793 +++ b/net/netfilter/nf_sockopt.c
95794 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
95795 }
95796 }
95797
95798 - list_add(&reg->list, &nf_sockopts);
95799 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
95800 out:
95801 mutex_unlock(&nf_sockopt_mutex);
95802 return ret;
95803 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
95804 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
95805 {
95806 mutex_lock(&nf_sockopt_mutex);
95807 - list_del(&reg->list);
95808 + pax_list_del((struct list_head *)&reg->list);
95809 mutex_unlock(&nf_sockopt_mutex);
95810 }
95811 EXPORT_SYMBOL(nf_unregister_sockopt);
95812 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
95813 index d92cc31..e46f350 100644
95814 --- a/net/netfilter/nfnetlink_log.c
95815 +++ b/net/netfilter/nfnetlink_log.c
95816 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
95817 struct nfnl_log_net {
95818 spinlock_t instances_lock;
95819 struct hlist_head instance_table[INSTANCE_BUCKETS];
95820 - atomic_t global_seq;
95821 + atomic_unchecked_t global_seq;
95822 };
95823
95824 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
95825 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
95826 /* global sequence number */
95827 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
95828 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
95829 - htonl(atomic_inc_return(&log->global_seq))))
95830 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
95831 goto nla_put_failure;
95832
95833 if (data_len) {
95834 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
95835 new file mode 100644
95836 index 0000000..c566332
95837 --- /dev/null
95838 +++ b/net/netfilter/xt_gradm.c
95839 @@ -0,0 +1,51 @@
95840 +/*
95841 + * gradm match for netfilter
95842 + * Copyright © Zbigniew Krzystolik, 2010
95843 + *
95844 + * This program is free software; you can redistribute it and/or modify
95845 + * it under the terms of the GNU General Public License; either version
95846 + * 2 or 3 as published by the Free Software Foundation.
95847 + */
95848 +#include <linux/module.h>
95849 +#include <linux/moduleparam.h>
95850 +#include <linux/skbuff.h>
95851 +#include <linux/netfilter/x_tables.h>
95852 +#include <linux/grsecurity.h>
95853 +#include <linux/netfilter/xt_gradm.h>
95854 +
95855 +static bool
95856 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
95857 +{
95858 + const struct xt_gradm_mtinfo *info = par->matchinfo;
95859 + bool retval = false;
95860 + if (gr_acl_is_enabled())
95861 + retval = true;
95862 + return retval ^ info->invflags;
95863 +}
95864 +
95865 +static struct xt_match gradm_mt_reg __read_mostly = {
95866 + .name = "gradm",
95867 + .revision = 0,
95868 + .family = NFPROTO_UNSPEC,
95869 + .match = gradm_mt,
95870 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
95871 + .me = THIS_MODULE,
95872 +};
95873 +
95874 +static int __init gradm_mt_init(void)
95875 +{
95876 + return xt_register_match(&gradm_mt_reg);
95877 +}
95878 +
95879 +static void __exit gradm_mt_exit(void)
95880 +{
95881 + xt_unregister_match(&gradm_mt_reg);
95882 +}
95883 +
95884 +module_init(gradm_mt_init);
95885 +module_exit(gradm_mt_exit);
95886 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
95887 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
95888 +MODULE_LICENSE("GPL");
95889 +MODULE_ALIAS("ipt_gradm");
95890 +MODULE_ALIAS("ip6t_gradm");
95891 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
95892 index 4fe4fb4..87a89e5 100644
95893 --- a/net/netfilter/xt_statistic.c
95894 +++ b/net/netfilter/xt_statistic.c
95895 @@ -19,7 +19,7 @@
95896 #include <linux/module.h>
95897
95898 struct xt_statistic_priv {
95899 - atomic_t count;
95900 + atomic_unchecked_t count;
95901 } ____cacheline_aligned_in_smp;
95902
95903 MODULE_LICENSE("GPL");
95904 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
95905 break;
95906 case XT_STATISTIC_MODE_NTH:
95907 do {
95908 - oval = atomic_read(&info->master->count);
95909 + oval = atomic_read_unchecked(&info->master->count);
95910 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
95911 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
95912 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
95913 if (nval == 0)
95914 ret = !ret;
95915 break;
95916 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
95917 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
95918 if (info->master == NULL)
95919 return -ENOMEM;
95920 - atomic_set(&info->master->count, info->u.nth.count);
95921 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
95922
95923 return 0;
95924 }
95925 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
95926 index 8df7f64..c5d6821 100644
95927 --- a/net/netlink/af_netlink.c
95928 +++ b/net/netlink/af_netlink.c
95929 @@ -249,7 +249,7 @@ static void netlink_overrun(struct sock *sk)
95930 sk->sk_error_report(sk);
95931 }
95932 }
95933 - atomic_inc(&sk->sk_drops);
95934 + atomic_inc_unchecked(&sk->sk_drops);
95935 }
95936
95937 static void netlink_rcv_wake(struct sock *sk)
95938 @@ -2942,7 +2942,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
95939 sk_wmem_alloc_get(s),
95940 nlk->cb_running,
95941 atomic_read(&s->sk_refcnt),
95942 - atomic_read(&s->sk_drops),
95943 + atomic_read_unchecked(&s->sk_drops),
95944 sock_i_ino(s)
95945 );
95946
95947 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
95948 index 0c741ce..f8c8ca7 100644
95949 --- a/net/netlink/genetlink.c
95950 +++ b/net/netlink/genetlink.c
95951 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
95952 goto errout;
95953 }
95954
95955 + pax_open_kernel();
95956 if (ops->dumpit)
95957 - ops->flags |= GENL_CMD_CAP_DUMP;
95958 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
95959 if (ops->doit)
95960 - ops->flags |= GENL_CMD_CAP_DO;
95961 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
95962 if (ops->policy)
95963 - ops->flags |= GENL_CMD_CAP_HASPOL;
95964 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
95965 + pax_close_kernel();
95966
95967 genl_lock_all();
95968 - list_add_tail(&ops->ops_list, &family->ops_list);
95969 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
95970 genl_unlock_all();
95971
95972 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
95973 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
95974 err = 0;
95975 errout:
95976 return err;
95977 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
95978 genl_lock_all();
95979 list_for_each_entry(rc, &family->ops_list, ops_list) {
95980 if (rc == ops) {
95981 - list_del(&ops->ops_list);
95982 + pax_list_del((struct list_head *)&ops->ops_list);
95983 genl_unlock_all();
95984 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
95985 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
95986 return 0;
95987 }
95988 }
95989 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
95990 index 698814b..7cfde4e 100644
95991 --- a/net/netrom/af_netrom.c
95992 +++ b/net/netrom/af_netrom.c
95993 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
95994 *uaddr_len = sizeof(struct full_sockaddr_ax25);
95995 } else {
95996 sax->fsa_ax25.sax25_family = AF_NETROM;
95997 - sax->fsa_ax25.sax25_ndigis = 0;
95998 sax->fsa_ax25.sax25_call = nr->source_addr;
95999 *uaddr_len = sizeof(struct sockaddr_ax25);
96000 }
96001 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
96002 index 2e8286b..b2659ee 100644
96003 --- a/net/packet/af_packet.c
96004 +++ b/net/packet/af_packet.c
96005 @@ -1692,7 +1692,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96006
96007 spin_lock(&sk->sk_receive_queue.lock);
96008 po->stats.stats1.tp_packets++;
96009 - skb->dropcount = atomic_read(&sk->sk_drops);
96010 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
96011 __skb_queue_tail(&sk->sk_receive_queue, skb);
96012 spin_unlock(&sk->sk_receive_queue.lock);
96013 sk->sk_data_ready(sk, skb->len);
96014 @@ -1701,7 +1701,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96015 drop_n_acct:
96016 spin_lock(&sk->sk_receive_queue.lock);
96017 po->stats.stats1.tp_drops++;
96018 - atomic_inc(&sk->sk_drops);
96019 + atomic_inc_unchecked(&sk->sk_drops);
96020 spin_unlock(&sk->sk_receive_queue.lock);
96021
96022 drop_n_restore:
96023 @@ -3250,7 +3250,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96024 case PACKET_HDRLEN:
96025 if (len > sizeof(int))
96026 len = sizeof(int);
96027 - if (copy_from_user(&val, optval, len))
96028 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
96029 return -EFAULT;
96030 switch (val) {
96031 case TPACKET_V1:
96032 @@ -3293,7 +3293,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96033 len = lv;
96034 if (put_user(len, optlen))
96035 return -EFAULT;
96036 - if (copy_to_user(optval, data, len))
96037 + if (len > sizeof(st) || copy_to_user(optval, data, len))
96038 return -EFAULT;
96039 return 0;
96040 }
96041 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
96042 index e774117..900b8b7 100644
96043 --- a/net/phonet/pep.c
96044 +++ b/net/phonet/pep.c
96045 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96046
96047 case PNS_PEP_CTRL_REQ:
96048 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
96049 - atomic_inc(&sk->sk_drops);
96050 + atomic_inc_unchecked(&sk->sk_drops);
96051 break;
96052 }
96053 __skb_pull(skb, 4);
96054 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96055 }
96056
96057 if (pn->rx_credits == 0) {
96058 - atomic_inc(&sk->sk_drops);
96059 + atomic_inc_unchecked(&sk->sk_drops);
96060 err = -ENOBUFS;
96061 break;
96062 }
96063 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
96064 }
96065
96066 if (pn->rx_credits == 0) {
96067 - atomic_inc(&sk->sk_drops);
96068 + atomic_inc_unchecked(&sk->sk_drops);
96069 err = NET_RX_DROP;
96070 break;
96071 }
96072 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
96073 index 77e38f7..f4ef5c3 100644
96074 --- a/net/phonet/socket.c
96075 +++ b/net/phonet/socket.c
96076 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
96077 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
96078 sock_i_ino(sk),
96079 atomic_read(&sk->sk_refcnt), sk,
96080 - atomic_read(&sk->sk_drops), &len);
96081 + atomic_read_unchecked(&sk->sk_drops), &len);
96082 }
96083 seq_printf(seq, "%*s\n", 127 - len, "");
96084 return 0;
96085 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
96086 index c02a8c4..3c5b600 100644
96087 --- a/net/phonet/sysctl.c
96088 +++ b/net/phonet/sysctl.c
96089 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
96090 {
96091 int ret;
96092 int range[2] = {local_port_range[0], local_port_range[1]};
96093 - struct ctl_table tmp = {
96094 + ctl_table_no_const tmp = {
96095 .data = &range,
96096 .maxlen = sizeof(range),
96097 .mode = table->mode,
96098 diff --git a/net/rds/cong.c b/net/rds/cong.c
96099 index e5b65ac..f3b6fb7 100644
96100 --- a/net/rds/cong.c
96101 +++ b/net/rds/cong.c
96102 @@ -78,7 +78,7 @@
96103 * finds that the saved generation number is smaller than the global generation
96104 * number, it wakes up the process.
96105 */
96106 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
96107 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
96108
96109 /*
96110 * Congestion monitoring
96111 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
96112 rdsdebug("waking map %p for %pI4\n",
96113 map, &map->m_addr);
96114 rds_stats_inc(s_cong_update_received);
96115 - atomic_inc(&rds_cong_generation);
96116 + atomic_inc_unchecked(&rds_cong_generation);
96117 if (waitqueue_active(&map->m_waitq))
96118 wake_up(&map->m_waitq);
96119 if (waitqueue_active(&rds_poll_waitq))
96120 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
96121
96122 int rds_cong_updated_since(unsigned long *recent)
96123 {
96124 - unsigned long gen = atomic_read(&rds_cong_generation);
96125 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
96126
96127 if (likely(*recent == gen))
96128 return 0;
96129 diff --git a/net/rds/ib.h b/net/rds/ib.h
96130 index 7280ab8..e04f4ea 100644
96131 --- a/net/rds/ib.h
96132 +++ b/net/rds/ib.h
96133 @@ -128,7 +128,7 @@ struct rds_ib_connection {
96134 /* sending acks */
96135 unsigned long i_ack_flags;
96136 #ifdef KERNEL_HAS_ATOMIC64
96137 - atomic64_t i_ack_next; /* next ACK to send */
96138 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96139 #else
96140 spinlock_t i_ack_lock; /* protect i_ack_next */
96141 u64 i_ack_next; /* next ACK to send */
96142 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
96143 index 31b74f5..dc1fbfa 100644
96144 --- a/net/rds/ib_cm.c
96145 +++ b/net/rds/ib_cm.c
96146 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
96147 /* Clear the ACK state */
96148 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96149 #ifdef KERNEL_HAS_ATOMIC64
96150 - atomic64_set(&ic->i_ack_next, 0);
96151 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96152 #else
96153 ic->i_ack_next = 0;
96154 #endif
96155 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
96156 index 8eb9501..0c386ff 100644
96157 --- a/net/rds/ib_recv.c
96158 +++ b/net/rds/ib_recv.c
96159 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96160 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
96161 int ack_required)
96162 {
96163 - atomic64_set(&ic->i_ack_next, seq);
96164 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96165 if (ack_required) {
96166 smp_mb__before_clear_bit();
96167 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96168 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96169 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96170 smp_mb__after_clear_bit();
96171
96172 - return atomic64_read(&ic->i_ack_next);
96173 + return atomic64_read_unchecked(&ic->i_ack_next);
96174 }
96175 #endif
96176
96177 diff --git a/net/rds/iw.h b/net/rds/iw.h
96178 index 04ce3b1..48119a6 100644
96179 --- a/net/rds/iw.h
96180 +++ b/net/rds/iw.h
96181 @@ -134,7 +134,7 @@ struct rds_iw_connection {
96182 /* sending acks */
96183 unsigned long i_ack_flags;
96184 #ifdef KERNEL_HAS_ATOMIC64
96185 - atomic64_t i_ack_next; /* next ACK to send */
96186 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96187 #else
96188 spinlock_t i_ack_lock; /* protect i_ack_next */
96189 u64 i_ack_next; /* next ACK to send */
96190 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
96191 index a91e1db..cf3053f 100644
96192 --- a/net/rds/iw_cm.c
96193 +++ b/net/rds/iw_cm.c
96194 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
96195 /* Clear the ACK state */
96196 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96197 #ifdef KERNEL_HAS_ATOMIC64
96198 - atomic64_set(&ic->i_ack_next, 0);
96199 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96200 #else
96201 ic->i_ack_next = 0;
96202 #endif
96203 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
96204 index 4503335..db566b4 100644
96205 --- a/net/rds/iw_recv.c
96206 +++ b/net/rds/iw_recv.c
96207 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96208 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
96209 int ack_required)
96210 {
96211 - atomic64_set(&ic->i_ack_next, seq);
96212 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96213 if (ack_required) {
96214 smp_mb__before_clear_bit();
96215 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96216 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96217 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96218 smp_mb__after_clear_bit();
96219
96220 - return atomic64_read(&ic->i_ack_next);
96221 + return atomic64_read_unchecked(&ic->i_ack_next);
96222 }
96223 #endif
96224
96225 diff --git a/net/rds/rds.h b/net/rds/rds.h
96226 index ec1d731..90a3a8d 100644
96227 --- a/net/rds/rds.h
96228 +++ b/net/rds/rds.h
96229 @@ -449,7 +449,7 @@ struct rds_transport {
96230 void (*sync_mr)(void *trans_private, int direction);
96231 void (*free_mr)(void *trans_private, int invalidate);
96232 void (*flush_mrs)(void);
96233 -};
96234 +} __do_const;
96235
96236 struct rds_sock {
96237 struct sock rs_sk;
96238 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
96239 index edac9ef..16bcb98 100644
96240 --- a/net/rds/tcp.c
96241 +++ b/net/rds/tcp.c
96242 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
96243 int val = 1;
96244
96245 set_fs(KERNEL_DS);
96246 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
96247 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
96248 sizeof(val));
96249 set_fs(oldfs);
96250 }
96251 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
96252 index 81cf5a4..b5826ff 100644
96253 --- a/net/rds/tcp_send.c
96254 +++ b/net/rds/tcp_send.c
96255 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
96256
96257 oldfs = get_fs();
96258 set_fs(KERNEL_DS);
96259 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
96260 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
96261 sizeof(val));
96262 set_fs(oldfs);
96263 }
96264 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
96265 index e61aa60..f07cc89 100644
96266 --- a/net/rxrpc/af_rxrpc.c
96267 +++ b/net/rxrpc/af_rxrpc.c
96268 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
96269 __be32 rxrpc_epoch;
96270
96271 /* current debugging ID */
96272 -atomic_t rxrpc_debug_id;
96273 +atomic_unchecked_t rxrpc_debug_id;
96274
96275 /* count of skbs currently in use */
96276 atomic_t rxrpc_n_skbs;
96277 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
96278 index e4d9cbc..b229649 100644
96279 --- a/net/rxrpc/ar-ack.c
96280 +++ b/net/rxrpc/ar-ack.c
96281 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96282
96283 _enter("{%d,%d,%d,%d},",
96284 call->acks_hard, call->acks_unacked,
96285 - atomic_read(&call->sequence),
96286 + atomic_read_unchecked(&call->sequence),
96287 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
96288
96289 stop = 0;
96290 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96291
96292 /* each Tx packet has a new serial number */
96293 sp->hdr.serial =
96294 - htonl(atomic_inc_return(&call->conn->serial));
96295 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
96296
96297 hdr = (struct rxrpc_header *) txb->head;
96298 hdr->serial = sp->hdr.serial;
96299 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
96300 */
96301 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
96302 {
96303 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
96304 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
96305 }
96306
96307 /*
96308 @@ -629,7 +629,7 @@ process_further:
96309
96310 latest = ntohl(sp->hdr.serial);
96311 hard = ntohl(ack.firstPacket);
96312 - tx = atomic_read(&call->sequence);
96313 + tx = atomic_read_unchecked(&call->sequence);
96314
96315 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96316 latest,
96317 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
96318 goto maybe_reschedule;
96319
96320 send_ACK_with_skew:
96321 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
96322 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
96323 ntohl(ack.serial));
96324 send_ACK:
96325 mtu = call->conn->trans->peer->if_mtu;
96326 @@ -1173,7 +1173,7 @@ send_ACK:
96327 ackinfo.rxMTU = htonl(5692);
96328 ackinfo.jumbo_max = htonl(4);
96329
96330 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96331 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96332 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96333 ntohl(hdr.serial),
96334 ntohs(ack.maxSkew),
96335 @@ -1191,7 +1191,7 @@ send_ACK:
96336 send_message:
96337 _debug("send message");
96338
96339 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96340 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96341 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
96342 send_message_2:
96343
96344 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
96345 index a3bbb36..3341fb9 100644
96346 --- a/net/rxrpc/ar-call.c
96347 +++ b/net/rxrpc/ar-call.c
96348 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
96349 spin_lock_init(&call->lock);
96350 rwlock_init(&call->state_lock);
96351 atomic_set(&call->usage, 1);
96352 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
96353 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96354 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
96355
96356 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
96357 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
96358 index 4106ca9..a338d7a 100644
96359 --- a/net/rxrpc/ar-connection.c
96360 +++ b/net/rxrpc/ar-connection.c
96361 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
96362 rwlock_init(&conn->lock);
96363 spin_lock_init(&conn->state_lock);
96364 atomic_set(&conn->usage, 1);
96365 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
96366 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96367 conn->avail_calls = RXRPC_MAXCALLS;
96368 conn->size_align = 4;
96369 conn->header_size = sizeof(struct rxrpc_header);
96370 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
96371 index e7ed43a..6afa140 100644
96372 --- a/net/rxrpc/ar-connevent.c
96373 +++ b/net/rxrpc/ar-connevent.c
96374 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
96375
96376 len = iov[0].iov_len + iov[1].iov_len;
96377
96378 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
96379 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96380 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
96381
96382 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
96383 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
96384 index 529572f..c758ca7 100644
96385 --- a/net/rxrpc/ar-input.c
96386 +++ b/net/rxrpc/ar-input.c
96387 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
96388 /* track the latest serial number on this connection for ACK packet
96389 * information */
96390 serial = ntohl(sp->hdr.serial);
96391 - hi_serial = atomic_read(&call->conn->hi_serial);
96392 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
96393 while (serial > hi_serial)
96394 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
96395 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
96396 serial);
96397
96398 /* request ACK generation for any ACK or DATA packet that requests
96399 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
96400 index a693aca..81e7293 100644
96401 --- a/net/rxrpc/ar-internal.h
96402 +++ b/net/rxrpc/ar-internal.h
96403 @@ -272,8 +272,8 @@ struct rxrpc_connection {
96404 int error; /* error code for local abort */
96405 int debug_id; /* debug ID for printks */
96406 unsigned int call_counter; /* call ID counter */
96407 - atomic_t serial; /* packet serial number counter */
96408 - atomic_t hi_serial; /* highest serial number received */
96409 + atomic_unchecked_t serial; /* packet serial number counter */
96410 + atomic_unchecked_t hi_serial; /* highest serial number received */
96411 u8 avail_calls; /* number of calls available */
96412 u8 size_align; /* data size alignment (for security) */
96413 u8 header_size; /* rxrpc + security header size */
96414 @@ -346,7 +346,7 @@ struct rxrpc_call {
96415 spinlock_t lock;
96416 rwlock_t state_lock; /* lock for state transition */
96417 atomic_t usage;
96418 - atomic_t sequence; /* Tx data packet sequence counter */
96419 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
96420 u32 abort_code; /* local/remote abort code */
96421 enum { /* current state of call */
96422 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
96423 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
96424 */
96425 extern atomic_t rxrpc_n_skbs;
96426 extern __be32 rxrpc_epoch;
96427 -extern atomic_t rxrpc_debug_id;
96428 +extern atomic_unchecked_t rxrpc_debug_id;
96429 extern struct workqueue_struct *rxrpc_workqueue;
96430
96431 /*
96432 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
96433 index 87f7135..74d3703 100644
96434 --- a/net/rxrpc/ar-local.c
96435 +++ b/net/rxrpc/ar-local.c
96436 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
96437 spin_lock_init(&local->lock);
96438 rwlock_init(&local->services_lock);
96439 atomic_set(&local->usage, 1);
96440 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
96441 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96442 memcpy(&local->srx, srx, sizeof(*srx));
96443 }
96444
96445 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
96446 index e1ac183..b43e10e 100644
96447 --- a/net/rxrpc/ar-output.c
96448 +++ b/net/rxrpc/ar-output.c
96449 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
96450 sp->hdr.cid = call->cid;
96451 sp->hdr.callNumber = call->call_id;
96452 sp->hdr.seq =
96453 - htonl(atomic_inc_return(&call->sequence));
96454 + htonl(atomic_inc_return_unchecked(&call->sequence));
96455 sp->hdr.serial =
96456 - htonl(atomic_inc_return(&conn->serial));
96457 + htonl(atomic_inc_return_unchecked(&conn->serial));
96458 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
96459 sp->hdr.userStatus = 0;
96460 sp->hdr.securityIndex = conn->security_ix;
96461 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
96462 index bebaa43..2644591 100644
96463 --- a/net/rxrpc/ar-peer.c
96464 +++ b/net/rxrpc/ar-peer.c
96465 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
96466 INIT_LIST_HEAD(&peer->error_targets);
96467 spin_lock_init(&peer->lock);
96468 atomic_set(&peer->usage, 1);
96469 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
96470 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96471 memcpy(&peer->srx, srx, sizeof(*srx));
96472
96473 rxrpc_assess_MTU_size(peer);
96474 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
96475 index 38047f7..9f48511 100644
96476 --- a/net/rxrpc/ar-proc.c
96477 +++ b/net/rxrpc/ar-proc.c
96478 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
96479 atomic_read(&conn->usage),
96480 rxrpc_conn_states[conn->state],
96481 key_serial(conn->key),
96482 - atomic_read(&conn->serial),
96483 - atomic_read(&conn->hi_serial));
96484 + atomic_read_unchecked(&conn->serial),
96485 + atomic_read_unchecked(&conn->hi_serial));
96486
96487 return 0;
96488 }
96489 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
96490 index 92df566..87ec1bf 100644
96491 --- a/net/rxrpc/ar-transport.c
96492 +++ b/net/rxrpc/ar-transport.c
96493 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
96494 spin_lock_init(&trans->client_lock);
96495 rwlock_init(&trans->conn_lock);
96496 atomic_set(&trans->usage, 1);
96497 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
96498 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96499
96500 if (peer->srx.transport.family == AF_INET) {
96501 switch (peer->srx.transport_type) {
96502 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
96503 index f226709..0e735a8 100644
96504 --- a/net/rxrpc/rxkad.c
96505 +++ b/net/rxrpc/rxkad.c
96506 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
96507
96508 len = iov[0].iov_len + iov[1].iov_len;
96509
96510 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
96511 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96512 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
96513
96514 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
96515 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
96516
96517 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
96518
96519 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
96520 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96521 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
96522
96523 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
96524 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
96525 index e7b2d4f..bb1efd0 100644
96526 --- a/net/sctp/ipv6.c
96527 +++ b/net/sctp/ipv6.c
96528 @@ -962,7 +962,7 @@ static const struct inet6_protocol sctpv6_protocol = {
96529 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
96530 };
96531
96532 -static struct sctp_af sctp_af_inet6 = {
96533 +static struct sctp_af sctp_af_inet6 __read_only = {
96534 .sa_family = AF_INET6,
96535 .sctp_xmit = sctp_v6_xmit,
96536 .setsockopt = ipv6_setsockopt,
96537 @@ -994,7 +994,7 @@ static struct sctp_af sctp_af_inet6 = {
96538 #endif
96539 };
96540
96541 -static struct sctp_pf sctp_pf_inet6 = {
96542 +static struct sctp_pf sctp_pf_inet6 __read_only = {
96543 .event_msgname = sctp_inet6_event_msgname,
96544 .skb_msgname = sctp_inet6_skb_msgname,
96545 .af_supported = sctp_inet6_af_supported,
96546 @@ -1019,7 +1019,7 @@ void sctp_v6_pf_init(void)
96547
96548 void sctp_v6_pf_exit(void)
96549 {
96550 - list_del(&sctp_af_inet6.list);
96551 + pax_list_del(&sctp_af_inet6.list);
96552 }
96553
96554 /* Initialize IPv6 support and register with socket layer. */
96555 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
96556 index 5e17092..19be1d4 100644
96557 --- a/net/sctp/protocol.c
96558 +++ b/net/sctp/protocol.c
96559 @@ -832,8 +832,10 @@ int sctp_register_af(struct sctp_af *af)
96560 return 0;
96561 }
96562
96563 + pax_open_kernel();
96564 INIT_LIST_HEAD(&af->list);
96565 - list_add_tail(&af->list, &sctp_address_families);
96566 + pax_close_kernel();
96567 + pax_list_add_tail(&af->list, &sctp_address_families);
96568 return 1;
96569 }
96570
96571 @@ -963,7 +965,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
96572
96573 static struct sctp_af sctp_af_inet;
96574
96575 -static struct sctp_pf sctp_pf_inet = {
96576 +static struct sctp_pf sctp_pf_inet __read_only = {
96577 .event_msgname = sctp_inet_event_msgname,
96578 .skb_msgname = sctp_inet_skb_msgname,
96579 .af_supported = sctp_inet_af_supported,
96580 @@ -1034,7 +1036,7 @@ static const struct net_protocol sctp_protocol = {
96581 };
96582
96583 /* IPv4 address related functions. */
96584 -static struct sctp_af sctp_af_inet = {
96585 +static struct sctp_af sctp_af_inet __read_only = {
96586 .sa_family = AF_INET,
96587 .sctp_xmit = sctp_v4_xmit,
96588 .setsockopt = ip_setsockopt,
96589 @@ -1119,7 +1121,7 @@ static void sctp_v4_pf_init(void)
96590
96591 static void sctp_v4_pf_exit(void)
96592 {
96593 - list_del(&sctp_af_inet.list);
96594 + pax_list_del(&sctp_af_inet.list);
96595 }
96596
96597 static int sctp_v4_protosw_init(void)
96598 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
96599 index 1a6eef3..17e898f 100644
96600 --- a/net/sctp/sm_sideeffect.c
96601 +++ b/net/sctp/sm_sideeffect.c
96602 @@ -440,7 +440,7 @@ static void sctp_generate_sack_event(unsigned long data)
96603 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
96604 }
96605
96606 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96607 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96608 NULL,
96609 sctp_generate_t1_cookie_event,
96610 sctp_generate_t1_init_event,
96611 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
96612 index 911b71b..90ade0a 100644
96613 --- a/net/sctp/socket.c
96614 +++ b/net/sctp/socket.c
96615 @@ -2153,11 +2153,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
96616 {
96617 struct sctp_association *asoc;
96618 struct sctp_ulpevent *event;
96619 + struct sctp_event_subscribe subscribe;
96620
96621 if (optlen > sizeof(struct sctp_event_subscribe))
96622 return -EINVAL;
96623 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
96624 + if (copy_from_user(&subscribe, optval, optlen))
96625 return -EFAULT;
96626 + sctp_sk(sk)->subscribe = subscribe;
96627
96628 /*
96629 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
96630 @@ -4213,13 +4215,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
96631 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96632 int __user *optlen)
96633 {
96634 + struct sctp_event_subscribe subscribe;
96635 +
96636 if (len <= 0)
96637 return -EINVAL;
96638 if (len > sizeof(struct sctp_event_subscribe))
96639 len = sizeof(struct sctp_event_subscribe);
96640 if (put_user(len, optlen))
96641 return -EFAULT;
96642 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
96643 + subscribe = sctp_sk(sk)->subscribe;
96644 + if (copy_to_user(optval, &subscribe, len))
96645 return -EFAULT;
96646 return 0;
96647 }
96648 @@ -4237,6 +4242,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96649 */
96650 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
96651 {
96652 + __u32 autoclose;
96653 +
96654 /* Applicable to UDP-style socket only */
96655 if (sctp_style(sk, TCP))
96656 return -EOPNOTSUPP;
96657 @@ -4245,7 +4252,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
96658 len = sizeof(int);
96659 if (put_user(len, optlen))
96660 return -EFAULT;
96661 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
96662 + autoclose = sctp_sk(sk)->autoclose;
96663 + if (copy_to_user(optval, &autoclose, sizeof(int)))
96664 return -EFAULT;
96665 return 0;
96666 }
96667 @@ -4617,12 +4625,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
96668 */
96669 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
96670 {
96671 + struct sctp_initmsg initmsg;
96672 +
96673 if (len < sizeof(struct sctp_initmsg))
96674 return -EINVAL;
96675 len = sizeof(struct sctp_initmsg);
96676 if (put_user(len, optlen))
96677 return -EFAULT;
96678 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
96679 + initmsg = sctp_sk(sk)->initmsg;
96680 + if (copy_to_user(optval, &initmsg, len))
96681 return -EFAULT;
96682 return 0;
96683 }
96684 @@ -4663,6 +4674,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
96685 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
96686 if (space_left < addrlen)
96687 return -ENOMEM;
96688 + if (addrlen > sizeof(temp) || addrlen < 0)
96689 + return -EFAULT;
96690 if (copy_to_user(to, &temp, addrlen))
96691 return -EFAULT;
96692 to += addrlen;
96693 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
96694 index 6b36561..4f21064 100644
96695 --- a/net/sctp/sysctl.c
96696 +++ b/net/sctp/sysctl.c
96697 @@ -301,7 +301,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96698 {
96699 struct net *net = current->nsproxy->net_ns;
96700 char tmp[8];
96701 - struct ctl_table tbl;
96702 + ctl_table_no_const tbl;
96703 int ret;
96704 int changed = 0;
96705 char *none = "none";
96706 @@ -344,7 +344,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96707
96708 int sctp_sysctl_net_register(struct net *net)
96709 {
96710 - struct ctl_table *table;
96711 + ctl_table_no_const *table;
96712 int i;
96713
96714 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
96715 diff --git a/net/socket.c b/net/socket.c
96716 index c226ace..561e8f7 100644
96717 --- a/net/socket.c
96718 +++ b/net/socket.c
96719 @@ -88,6 +88,7 @@
96720 #include <linux/magic.h>
96721 #include <linux/slab.h>
96722 #include <linux/xattr.h>
96723 +#include <linux/in.h>
96724
96725 #include <asm/uaccess.h>
96726 #include <asm/unistd.h>
96727 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
96728 unsigned int sysctl_net_busy_poll __read_mostly;
96729 #endif
96730
96731 +#include <linux/grsock.h>
96732 +
96733 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
96734 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
96735 unsigned long nr_segs, loff_t pos);
96736 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
96737 */
96738
96739 static DEFINE_SPINLOCK(net_family_lock);
96740 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96741 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96742
96743 /*
96744 * Statistics counters of the socket lists
96745 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
96746 &sockfs_dentry_operations, SOCKFS_MAGIC);
96747 }
96748
96749 -static struct vfsmount *sock_mnt __read_mostly;
96750 +struct vfsmount *sock_mnt __read_mostly;
96751
96752 static struct file_system_type sock_fs_type = {
96753 .name = "sockfs",
96754 @@ -1254,6 +1257,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96755 return -EAFNOSUPPORT;
96756 if (type < 0 || type >= SOCK_MAX)
96757 return -EINVAL;
96758 + if (protocol < 0)
96759 + return -EINVAL;
96760
96761 /* Compatibility.
96762
96763 @@ -1274,6 +1279,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96764 if (err)
96765 return err;
96766
96767 + if(!kern && !gr_search_socket(family, type, protocol)) {
96768 + if (rcu_access_pointer(net_families[family]) == NULL)
96769 + return -EAFNOSUPPORT;
96770 + else
96771 + return -EACCES;
96772 + }
96773 +
96774 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
96775 + if (rcu_access_pointer(net_families[family]) == NULL)
96776 + return -EAFNOSUPPORT;
96777 + else
96778 + return -EACCES;
96779 + }
96780 +
96781 /*
96782 * Allocate the socket and allow the family to set things up. if
96783 * the protocol is 0, the family is instructed to select an appropriate
96784 @@ -1512,6 +1531,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96785 if (sock) {
96786 err = move_addr_to_kernel(umyaddr, addrlen, &address);
96787 if (err >= 0) {
96788 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
96789 + err = -EACCES;
96790 + goto error;
96791 + }
96792 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
96793 + if (err)
96794 + goto error;
96795 +
96796 err = security_socket_bind(sock,
96797 (struct sockaddr *)&address,
96798 addrlen);
96799 @@ -1520,6 +1547,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96800 (struct sockaddr *)
96801 &address, addrlen);
96802 }
96803 +error:
96804 fput_light(sock->file, fput_needed);
96805 }
96806 return err;
96807 @@ -1543,10 +1571,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
96808 if ((unsigned int)backlog > somaxconn)
96809 backlog = somaxconn;
96810
96811 + if (gr_handle_sock_server_other(sock->sk)) {
96812 + err = -EPERM;
96813 + goto error;
96814 + }
96815 +
96816 + err = gr_search_listen(sock);
96817 + if (err)
96818 + goto error;
96819 +
96820 err = security_socket_listen(sock, backlog);
96821 if (!err)
96822 err = sock->ops->listen(sock, backlog);
96823
96824 +error:
96825 fput_light(sock->file, fput_needed);
96826 }
96827 return err;
96828 @@ -1590,6 +1628,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96829 newsock->type = sock->type;
96830 newsock->ops = sock->ops;
96831
96832 + if (gr_handle_sock_server_other(sock->sk)) {
96833 + err = -EPERM;
96834 + sock_release(newsock);
96835 + goto out_put;
96836 + }
96837 +
96838 + err = gr_search_accept(sock);
96839 + if (err) {
96840 + sock_release(newsock);
96841 + goto out_put;
96842 + }
96843 +
96844 /*
96845 * We don't need try_module_get here, as the listening socket (sock)
96846 * has the protocol module (sock->ops->owner) held.
96847 @@ -1635,6 +1685,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96848 fd_install(newfd, newfile);
96849 err = newfd;
96850
96851 + gr_attach_curr_ip(newsock->sk);
96852 +
96853 out_put:
96854 fput_light(sock->file, fput_needed);
96855 out:
96856 @@ -1667,6 +1719,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96857 int, addrlen)
96858 {
96859 struct socket *sock;
96860 + struct sockaddr *sck;
96861 struct sockaddr_storage address;
96862 int err, fput_needed;
96863
96864 @@ -1677,6 +1730,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96865 if (err < 0)
96866 goto out_put;
96867
96868 + sck = (struct sockaddr *)&address;
96869 +
96870 + if (gr_handle_sock_client(sck)) {
96871 + err = -EACCES;
96872 + goto out_put;
96873 + }
96874 +
96875 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
96876 + if (err)
96877 + goto out_put;
96878 +
96879 err =
96880 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
96881 if (err)
96882 @@ -1758,6 +1822,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
96883 * the protocol.
96884 */
96885
96886 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
96887 +
96888 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
96889 unsigned int, flags, struct sockaddr __user *, addr,
96890 int, addr_len)
96891 @@ -1824,7 +1890,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
96892 struct socket *sock;
96893 struct iovec iov;
96894 struct msghdr msg;
96895 - struct sockaddr_storage address;
96896 + struct sockaddr_storage address = { };
96897 int err, err2;
96898 int fput_needed;
96899
96900 @@ -2044,7 +2110,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96901 * checking falls down on this.
96902 */
96903 if (copy_from_user(ctl_buf,
96904 - (void __user __force *)msg_sys->msg_control,
96905 + (void __force_user *)msg_sys->msg_control,
96906 ctl_len))
96907 goto out_freectl;
96908 msg_sys->msg_control = ctl_buf;
96909 @@ -2195,7 +2261,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96910 int err, total_len, len;
96911
96912 /* kernel mode address */
96913 - struct sockaddr_storage addr;
96914 + struct sockaddr_storage addr = { };
96915
96916 /* user mode address pointers */
96917 struct sockaddr __user *uaddr;
96918 @@ -2226,7 +2292,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96919 * kernel msghdr to use the kernel address space)
96920 */
96921
96922 - uaddr = (__force void __user *)msg_sys->msg_name;
96923 + uaddr = (void __force_user *)msg_sys->msg_name;
96924 uaddr_len = COMPAT_NAMELEN(msg);
96925 if (MSG_CMSG_COMPAT & flags) {
96926 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
96927 @@ -2981,7 +3047,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
96928 old_fs = get_fs();
96929 set_fs(KERNEL_DS);
96930 err = dev_ioctl(net, cmd,
96931 - (struct ifreq __user __force *) &kifr);
96932 + (struct ifreq __force_user *) &kifr);
96933 set_fs(old_fs);
96934
96935 return err;
96936 @@ -3090,7 +3156,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
96937
96938 old_fs = get_fs();
96939 set_fs(KERNEL_DS);
96940 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
96941 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
96942 set_fs(old_fs);
96943
96944 if (cmd == SIOCGIFMAP && !err) {
96945 @@ -3195,7 +3261,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
96946 ret |= get_user(rtdev, &(ur4->rt_dev));
96947 if (rtdev) {
96948 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
96949 - r4.rt_dev = (char __user __force *)devname;
96950 + r4.rt_dev = (char __force_user *)devname;
96951 devname[15] = 0;
96952 } else
96953 r4.rt_dev = NULL;
96954 @@ -3421,8 +3487,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
96955 int __user *uoptlen;
96956 int err;
96957
96958 - uoptval = (char __user __force *) optval;
96959 - uoptlen = (int __user __force *) optlen;
96960 + uoptval = (char __force_user *) optval;
96961 + uoptlen = (int __force_user *) optlen;
96962
96963 set_fs(KERNEL_DS);
96964 if (level == SOL_SOCKET)
96965 @@ -3442,7 +3508,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
96966 char __user *uoptval;
96967 int err;
96968
96969 - uoptval = (char __user __force *) optval;
96970 + uoptval = (char __force_user *) optval;
96971
96972 set_fs(KERNEL_DS);
96973 if (level == SOL_SOCKET)
96974 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
96975 index 09fb638..2e6a5c5 100644
96976 --- a/net/sunrpc/auth_gss/svcauth_gss.c
96977 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
96978 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96979 uint64_t *handle)
96980 {
96981 struct rsc rsci, *rscp = NULL;
96982 - static atomic64_t ctxhctr;
96983 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96984 long long ctxh;
96985 struct gss_api_mech *gm = NULL;
96986 time_t expiry;
96987 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96988 status = -ENOMEM;
96989 /* the handle needs to be just a unique id,
96990 * use a static counter */
96991 - ctxh = atomic64_inc_return(&ctxhctr);
96992 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96993
96994 /* make a copy for the caller */
96995 *handle = ctxh;
96996 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96997 index 7747960..36d1518 100644
96998 --- a/net/sunrpc/clnt.c
96999 +++ b/net/sunrpc/clnt.c
97000 @@ -656,14 +656,16 @@ EXPORT_SYMBOL_GPL(rpc_shutdown_client);
97001 /*
97002 * Free an RPC client
97003 */
97004 -static void
97005 +static struct rpc_clnt *
97006 rpc_free_client(struct rpc_clnt *clnt)
97007 {
97008 + struct rpc_clnt *parent = NULL;
97009 +
97010 dprintk_rcu("RPC: destroying %s client for %s\n",
97011 clnt->cl_program->name,
97012 rcu_dereference(clnt->cl_xprt)->servername);
97013 if (clnt->cl_parent != clnt)
97014 - rpc_release_client(clnt->cl_parent);
97015 + parent = clnt->cl_parent;
97016 rpc_clnt_remove_pipedir(clnt);
97017 rpc_unregister_client(clnt);
97018 rpc_free_iostats(clnt->cl_metrics);
97019 @@ -672,18 +674,17 @@ rpc_free_client(struct rpc_clnt *clnt)
97020 rpciod_down();
97021 rpc_free_clid(clnt);
97022 kfree(clnt);
97023 + return parent;
97024 }
97025
97026 /*
97027 * Free an RPC client
97028 */
97029 -static void
97030 +static struct rpc_clnt *
97031 rpc_free_auth(struct rpc_clnt *clnt)
97032 {
97033 - if (clnt->cl_auth == NULL) {
97034 - rpc_free_client(clnt);
97035 - return;
97036 - }
97037 + if (clnt->cl_auth == NULL)
97038 + return rpc_free_client(clnt);
97039
97040 /*
97041 * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
97042 @@ -694,7 +695,8 @@ rpc_free_auth(struct rpc_clnt *clnt)
97043 rpcauth_release(clnt->cl_auth);
97044 clnt->cl_auth = NULL;
97045 if (atomic_dec_and_test(&clnt->cl_count))
97046 - rpc_free_client(clnt);
97047 + return rpc_free_client(clnt);
97048 + return NULL;
97049 }
97050
97051 /*
97052 @@ -705,10 +707,13 @@ rpc_release_client(struct rpc_clnt *clnt)
97053 {
97054 dprintk("RPC: rpc_release_client(%p)\n", clnt);
97055
97056 - if (list_empty(&clnt->cl_tasks))
97057 - wake_up(&destroy_wait);
97058 - if (atomic_dec_and_test(&clnt->cl_count))
97059 - rpc_free_auth(clnt);
97060 + do {
97061 + if (list_empty(&clnt->cl_tasks))
97062 + wake_up(&destroy_wait);
97063 + if (!atomic_dec_and_test(&clnt->cl_count))
97064 + break;
97065 + clnt = rpc_free_auth(clnt);
97066 + } while (clnt != NULL);
97067 }
97068 EXPORT_SYMBOL_GPL(rpc_release_client);
97069
97070 @@ -1314,7 +1319,9 @@ call_start(struct rpc_task *task)
97071 (RPC_IS_ASYNC(task) ? "async" : "sync"));
97072
97073 /* Increment call count */
97074 - task->tk_msg.rpc_proc->p_count++;
97075 + pax_open_kernel();
97076 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
97077 + pax_close_kernel();
97078 clnt->cl_stats->rpccnt++;
97079 task->tk_action = call_reserve;
97080 }
97081 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
97082 index ff3cc4b..7612a9e 100644
97083 --- a/net/sunrpc/sched.c
97084 +++ b/net/sunrpc/sched.c
97085 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
97086 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
97087 static void rpc_task_set_debuginfo(struct rpc_task *task)
97088 {
97089 - static atomic_t rpc_pid;
97090 + static atomic_unchecked_t rpc_pid;
97091
97092 - task->tk_pid = atomic_inc_return(&rpc_pid);
97093 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
97094 }
97095 #else
97096 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
97097 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
97098 index b974571..678ed90 100644
97099 --- a/net/sunrpc/svc.c
97100 +++ b/net/sunrpc/svc.c
97101 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
97102 svc_putnl(resv, RPC_SUCCESS);
97103
97104 /* Bump per-procedure stats counter */
97105 - procp->pc_count++;
97106 + pax_open_kernel();
97107 + (*(unsigned int *)&procp->pc_count)++;
97108 + pax_close_kernel();
97109
97110 /* Initialize storage for argp and resp */
97111 memset(rqstp->rq_argp, 0, procp->pc_argsize);
97112 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
97113 index 621ca7b..59421dd 100644
97114 --- a/net/sunrpc/svcauth_unix.c
97115 +++ b/net/sunrpc/svcauth_unix.c
97116 @@ -414,7 +414,7 @@ struct unix_gid {
97117 struct group_info *gi;
97118 };
97119
97120 -static int unix_gid_hash(kuid_t uid)
97121 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
97122 {
97123 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
97124 }
97125 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
97126 (*bpp)[-1] = '\n';
97127 }
97128
97129 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97130 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97131
97132 static int unix_gid_parse(struct cache_detail *cd,
97133 char *mesg, int mlen)
97134 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
97135 index c1b6270..05089c1 100644
97136 --- a/net/sunrpc/xprtrdma/svc_rdma.c
97137 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
97138 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
97139 static unsigned int min_max_inline = 4096;
97140 static unsigned int max_max_inline = 65536;
97141
97142 -atomic_t rdma_stat_recv;
97143 -atomic_t rdma_stat_read;
97144 -atomic_t rdma_stat_write;
97145 -atomic_t rdma_stat_sq_starve;
97146 -atomic_t rdma_stat_rq_starve;
97147 -atomic_t rdma_stat_rq_poll;
97148 -atomic_t rdma_stat_rq_prod;
97149 -atomic_t rdma_stat_sq_poll;
97150 -atomic_t rdma_stat_sq_prod;
97151 +atomic_unchecked_t rdma_stat_recv;
97152 +atomic_unchecked_t rdma_stat_read;
97153 +atomic_unchecked_t rdma_stat_write;
97154 +atomic_unchecked_t rdma_stat_sq_starve;
97155 +atomic_unchecked_t rdma_stat_rq_starve;
97156 +atomic_unchecked_t rdma_stat_rq_poll;
97157 +atomic_unchecked_t rdma_stat_rq_prod;
97158 +atomic_unchecked_t rdma_stat_sq_poll;
97159 +atomic_unchecked_t rdma_stat_sq_prod;
97160
97161 /* Temporary NFS request map and context caches */
97162 struct kmem_cache *svc_rdma_map_cachep;
97163 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
97164 len -= *ppos;
97165 if (len > *lenp)
97166 len = *lenp;
97167 - if (len && copy_to_user(buffer, str_buf, len))
97168 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
97169 return -EFAULT;
97170 *lenp = len;
97171 *ppos += len;
97172 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
97173 {
97174 .procname = "rdma_stat_read",
97175 .data = &rdma_stat_read,
97176 - .maxlen = sizeof(atomic_t),
97177 + .maxlen = sizeof(atomic_unchecked_t),
97178 .mode = 0644,
97179 .proc_handler = read_reset_stat,
97180 },
97181 {
97182 .procname = "rdma_stat_recv",
97183 .data = &rdma_stat_recv,
97184 - .maxlen = sizeof(atomic_t),
97185 + .maxlen = sizeof(atomic_unchecked_t),
97186 .mode = 0644,
97187 .proc_handler = read_reset_stat,
97188 },
97189 {
97190 .procname = "rdma_stat_write",
97191 .data = &rdma_stat_write,
97192 - .maxlen = sizeof(atomic_t),
97193 + .maxlen = sizeof(atomic_unchecked_t),
97194 .mode = 0644,
97195 .proc_handler = read_reset_stat,
97196 },
97197 {
97198 .procname = "rdma_stat_sq_starve",
97199 .data = &rdma_stat_sq_starve,
97200 - .maxlen = sizeof(atomic_t),
97201 + .maxlen = sizeof(atomic_unchecked_t),
97202 .mode = 0644,
97203 .proc_handler = read_reset_stat,
97204 },
97205 {
97206 .procname = "rdma_stat_rq_starve",
97207 .data = &rdma_stat_rq_starve,
97208 - .maxlen = sizeof(atomic_t),
97209 + .maxlen = sizeof(atomic_unchecked_t),
97210 .mode = 0644,
97211 .proc_handler = read_reset_stat,
97212 },
97213 {
97214 .procname = "rdma_stat_rq_poll",
97215 .data = &rdma_stat_rq_poll,
97216 - .maxlen = sizeof(atomic_t),
97217 + .maxlen = sizeof(atomic_unchecked_t),
97218 .mode = 0644,
97219 .proc_handler = read_reset_stat,
97220 },
97221 {
97222 .procname = "rdma_stat_rq_prod",
97223 .data = &rdma_stat_rq_prod,
97224 - .maxlen = sizeof(atomic_t),
97225 + .maxlen = sizeof(atomic_unchecked_t),
97226 .mode = 0644,
97227 .proc_handler = read_reset_stat,
97228 },
97229 {
97230 .procname = "rdma_stat_sq_poll",
97231 .data = &rdma_stat_sq_poll,
97232 - .maxlen = sizeof(atomic_t),
97233 + .maxlen = sizeof(atomic_unchecked_t),
97234 .mode = 0644,
97235 .proc_handler = read_reset_stat,
97236 },
97237 {
97238 .procname = "rdma_stat_sq_prod",
97239 .data = &rdma_stat_sq_prod,
97240 - .maxlen = sizeof(atomic_t),
97241 + .maxlen = sizeof(atomic_unchecked_t),
97242 .mode = 0644,
97243 .proc_handler = read_reset_stat,
97244 },
97245 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97246 index 0ce7552..d074459 100644
97247 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97248 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97249 @@ -501,7 +501,7 @@ next_sge:
97250 svc_rdma_put_context(ctxt, 0);
97251 goto out;
97252 }
97253 - atomic_inc(&rdma_stat_read);
97254 + atomic_inc_unchecked(&rdma_stat_read);
97255
97256 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
97257 chl_map->ch[ch_no].count -= read_wr.num_sge;
97258 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97259 dto_q);
97260 list_del_init(&ctxt->dto_q);
97261 } else {
97262 - atomic_inc(&rdma_stat_rq_starve);
97263 + atomic_inc_unchecked(&rdma_stat_rq_starve);
97264 clear_bit(XPT_DATA, &xprt->xpt_flags);
97265 ctxt = NULL;
97266 }
97267 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97268 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
97269 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
97270 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
97271 - atomic_inc(&rdma_stat_recv);
97272 + atomic_inc_unchecked(&rdma_stat_recv);
97273
97274 /* Build up the XDR from the receive buffers. */
97275 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
97276 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97277 index c1d124d..acfc59e 100644
97278 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97279 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97280 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
97281 write_wr.wr.rdma.remote_addr = to;
97282
97283 /* Post It */
97284 - atomic_inc(&rdma_stat_write);
97285 + atomic_inc_unchecked(&rdma_stat_write);
97286 if (svc_rdma_send(xprt, &write_wr))
97287 goto err;
97288 return 0;
97289 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97290 index 62e4f9b..dd3f2d7 100644
97291 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
97292 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97293 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97294 return;
97295
97296 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
97297 - atomic_inc(&rdma_stat_rq_poll);
97298 + atomic_inc_unchecked(&rdma_stat_rq_poll);
97299
97300 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
97301 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
97302 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97303 }
97304
97305 if (ctxt)
97306 - atomic_inc(&rdma_stat_rq_prod);
97307 + atomic_inc_unchecked(&rdma_stat_rq_prod);
97308
97309 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
97310 /*
97311 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97312 return;
97313
97314 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
97315 - atomic_inc(&rdma_stat_sq_poll);
97316 + atomic_inc_unchecked(&rdma_stat_sq_poll);
97317 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
97318 if (wc.status != IB_WC_SUCCESS)
97319 /* Close the transport */
97320 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97321 }
97322
97323 if (ctxt)
97324 - atomic_inc(&rdma_stat_sq_prod);
97325 + atomic_inc_unchecked(&rdma_stat_sq_prod);
97326 }
97327
97328 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
97329 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
97330 spin_lock_bh(&xprt->sc_lock);
97331 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
97332 spin_unlock_bh(&xprt->sc_lock);
97333 - atomic_inc(&rdma_stat_sq_starve);
97334 + atomic_inc_unchecked(&rdma_stat_sq_starve);
97335
97336 /* See if we can opportunistically reap SQ WR to make room */
97337 sq_cq_reap(xprt);
97338 diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
97339 index ee03d35..b752e1d 100644
97340 --- a/net/sunrpc/xprtsock.c
97341 +++ b/net/sunrpc/xprtsock.c
97342 @@ -393,8 +393,10 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
97343 return kernel_sendmsg(sock, &msg, NULL, 0, 0);
97344 }
97345
97346 -static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
97347 +static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy)
97348 {
97349 + ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
97350 + int offset, size_t size, int flags);
97351 struct page **ppage;
97352 unsigned int remainder;
97353 int err, sent = 0;
97354 @@ -403,6 +405,9 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
97355 base += xdr->page_base;
97356 ppage = xdr->pages + (base >> PAGE_SHIFT);
97357 base &= ~PAGE_MASK;
97358 + do_sendpage = sock->ops->sendpage;
97359 + if (!zerocopy)
97360 + do_sendpage = sock_no_sendpage;
97361 for(;;) {
97362 unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
97363 int flags = XS_SENDMSG_FLAGS;
97364 @@ -410,7 +415,7 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
97365 remainder -= len;
97366 if (remainder != 0 || more)
97367 flags |= MSG_MORE;
97368 - err = sock->ops->sendpage(sock, *ppage, base, len, flags);
97369 + err = do_sendpage(sock, *ppage, base, len, flags);
97370 if (remainder == 0 || err != len)
97371 break;
97372 sent += err;
97373 @@ -431,9 +436,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
97374 * @addrlen: UDP only -- length of destination address
97375 * @xdr: buffer containing this request
97376 * @base: starting position in the buffer
97377 + * @zerocopy: true if it is safe to use sendpage()
97378 *
97379 */
97380 -static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
97381 +static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy)
97382 {
97383 unsigned int remainder = xdr->len - base;
97384 int err, sent = 0;
97385 @@ -461,7 +467,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
97386 if (base < xdr->page_len) {
97387 unsigned int len = xdr->page_len - base;
97388 remainder -= len;
97389 - err = xs_send_pagedata(sock, xdr, base, remainder != 0);
97390 + err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy);
97391 if (remainder == 0 || err != len)
97392 goto out;
97393 sent += err;
97394 @@ -564,7 +570,7 @@ static int xs_local_send_request(struct rpc_task *task)
97395 req->rq_svec->iov_base, req->rq_svec->iov_len);
97396
97397 status = xs_sendpages(transport->sock, NULL, 0,
97398 - xdr, req->rq_bytes_sent);
97399 + xdr, req->rq_bytes_sent, true);
97400 dprintk("RPC: %s(%u) = %d\n",
97401 __func__, xdr->len - req->rq_bytes_sent, status);
97402 if (likely(status >= 0)) {
97403 @@ -620,7 +626,7 @@ static int xs_udp_send_request(struct rpc_task *task)
97404 status = xs_sendpages(transport->sock,
97405 xs_addr(xprt),
97406 xprt->addrlen, xdr,
97407 - req->rq_bytes_sent);
97408 + req->rq_bytes_sent, true);
97409
97410 dprintk("RPC: xs_udp_send_request(%u) = %d\n",
97411 xdr->len - req->rq_bytes_sent, status);
97412 @@ -693,6 +699,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
97413 struct rpc_xprt *xprt = req->rq_xprt;
97414 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
97415 struct xdr_buf *xdr = &req->rq_snd_buf;
97416 + bool zerocopy = true;
97417 int status;
97418
97419 xs_encode_stream_record_marker(&req->rq_snd_buf);
97420 @@ -700,13 +707,20 @@ static int xs_tcp_send_request(struct rpc_task *task)
97421 xs_pktdump("packet data:",
97422 req->rq_svec->iov_base,
97423 req->rq_svec->iov_len);
97424 + /* Don't use zero copy if this is a resend. If the RPC call
97425 + * completes while the socket holds a reference to the pages,
97426 + * then we may end up resending corrupted data.
97427 + */
97428 + if (task->tk_flags & RPC_TASK_SENT)
97429 + zerocopy = false;
97430
97431 /* Continue transmitting the packet/record. We must be careful
97432 * to cope with writespace callbacks arriving _after_ we have
97433 * called sendmsg(). */
97434 while (1) {
97435 status = xs_sendpages(transport->sock,
97436 - NULL, 0, xdr, req->rq_bytes_sent);
97437 + NULL, 0, xdr, req->rq_bytes_sent,
97438 + zerocopy);
97439
97440 dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
97441 xdr->len - req->rq_bytes_sent, status);
97442 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
97443 index e7000be..e3b0ba7 100644
97444 --- a/net/sysctl_net.c
97445 +++ b/net/sysctl_net.c
97446 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
97447 kgid_t root_gid = make_kgid(net->user_ns, 0);
97448
97449 /* Allow network administrator to have same access as root. */
97450 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
97451 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
97452 uid_eq(root_uid, current_euid())) {
97453 int mode = (table->mode >> 6) & 7;
97454 return (mode << 6) | (mode << 3) | mode;
97455 diff --git a/net/tipc/link.c b/net/tipc/link.c
97456 index 0cc3d90..cc42021 100644
97457 --- a/net/tipc/link.c
97458 +++ b/net/tipc/link.c
97459 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
97460 struct tipc_msg fragm_hdr;
97461 struct sk_buff *buf, *buf_chain, *prev;
97462 u32 fragm_crs, fragm_rest, hsz, sect_rest;
97463 - const unchar *sect_crs;
97464 + const unchar __user *sect_crs;
97465 int curr_sect;
97466 u32 fragm_no;
97467 int res = 0;
97468 @@ -1207,7 +1207,7 @@ again:
97469
97470 if (!sect_rest) {
97471 sect_rest = msg_sect[++curr_sect].iov_len;
97472 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
97473 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
97474 }
97475
97476 if (sect_rest < fragm_rest)
97477 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
97478 index ced60e2..54eab6c 100644
97479 --- a/net/tipc/msg.c
97480 +++ b/net/tipc/msg.c
97481 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
97482 skb_copy_to_linear_data(*buf, hdr, hsz);
97483 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
97484 skb_copy_to_linear_data_offset(*buf, pos,
97485 - msg_sect[cnt].iov_base,
97486 + (const void __force_kernel *)msg_sect[cnt].iov_base,
97487 msg_sect[cnt].iov_len);
97488 pos += msg_sect[cnt].iov_len;
97489 }
97490 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
97491 index d38bb45..4fd6ac6 100644
97492 --- a/net/tipc/subscr.c
97493 +++ b/net/tipc/subscr.c
97494 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
97495 struct kvec msg_sect;
97496 int ret;
97497
97498 - msg_sect.iov_base = (void *)&sub->evt;
97499 + msg_sect.iov_base = (void __force_user *)&sub->evt;
97500 msg_sect.iov_len = sizeof(struct tipc_event);
97501
97502 sub->evt.event = htohl(event, sub->swap);
97503 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
97504 index c1f403b..b246d87 100644
97505 --- a/net/unix/af_unix.c
97506 +++ b/net/unix/af_unix.c
97507 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
97508 err = -ECONNREFUSED;
97509 if (!S_ISSOCK(inode->i_mode))
97510 goto put_fail;
97511 +
97512 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
97513 + err = -EACCES;
97514 + goto put_fail;
97515 + }
97516 +
97517 u = unix_find_socket_byinode(inode);
97518 if (!u)
97519 goto put_fail;
97520 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
97521 if (u) {
97522 struct dentry *dentry;
97523 dentry = unix_sk(u)->path.dentry;
97524 +
97525 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
97526 + err = -EPERM;
97527 + sock_put(u);
97528 + goto fail;
97529 + }
97530 +
97531 if (dentry)
97532 touch_atime(&unix_sk(u)->path);
97533 } else
97534 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
97535 */
97536 err = security_path_mknod(&path, dentry, mode, 0);
97537 if (!err) {
97538 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
97539 + err = -EACCES;
97540 + goto out;
97541 + }
97542 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
97543 if (!err) {
97544 res->mnt = mntget(path.mnt);
97545 res->dentry = dget(dentry);
97546 + gr_handle_create(dentry, path.mnt);
97547 }
97548 }
97549 +out:
97550 done_path_create(&path, dentry);
97551 return err;
97552 }
97553 @@ -2333,9 +2352,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97554 seq_puts(seq, "Num RefCount Protocol Flags Type St "
97555 "Inode Path\n");
97556 else {
97557 - struct sock *s = v;
97558 + struct sock *s = v, *peer;
97559 struct unix_sock *u = unix_sk(s);
97560 unix_state_lock(s);
97561 + peer = unix_peer(s);
97562 + unix_state_unlock(s);
97563 +
97564 + unix_state_double_lock(s, peer);
97565
97566 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
97567 s,
97568 @@ -2362,8 +2385,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97569 }
97570 for ( ; i < len; i++)
97571 seq_putc(seq, u->addr->name->sun_path[i]);
97572 - }
97573 - unix_state_unlock(s);
97574 + } else if (peer)
97575 + seq_printf(seq, " P%lu", sock_i_ino(peer));
97576 +
97577 + unix_state_double_unlock(s, peer);
97578 seq_putc(seq, '\n');
97579 }
97580
97581 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
97582 index b3d5150..ff3a837 100644
97583 --- a/net/unix/sysctl_net_unix.c
97584 +++ b/net/unix/sysctl_net_unix.c
97585 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
97586
97587 int __net_init unix_sysctl_register(struct net *net)
97588 {
97589 - struct ctl_table *table;
97590 + ctl_table_no_const *table;
97591
97592 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
97593 if (table == NULL)
97594 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
97595 index c8717c1..08539f5 100644
97596 --- a/net/wireless/wext-core.c
97597 +++ b/net/wireless/wext-core.c
97598 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97599 */
97600
97601 /* Support for very large requests */
97602 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
97603 - (user_length > descr->max_tokens)) {
97604 + if (user_length > descr->max_tokens) {
97605 /* Allow userspace to GET more than max so
97606 * we can support any size GET requests.
97607 * There is still a limit : -ENOMEM.
97608 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97609 }
97610 }
97611
97612 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
97613 - /*
97614 - * If this is a GET, but not NOMAX, it means that the extra
97615 - * data is not bounded by userspace, but by max_tokens. Thus
97616 - * set the length to max_tokens. This matches the extra data
97617 - * allocation.
97618 - * The driver should fill it with the number of tokens it
97619 - * provided, and it may check iwp->length rather than having
97620 - * knowledge of max_tokens. If the driver doesn't change the
97621 - * iwp->length, this ioctl just copies back max_token tokens
97622 - * filled with zeroes. Hopefully the driver isn't claiming
97623 - * them to be valid data.
97624 - */
97625 - iwp->length = descr->max_tokens;
97626 - }
97627 -
97628 err = handler(dev, info, (union iwreq_data *) iwp, extra);
97629
97630 iwp->length += essid_compat;
97631 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
97632 index 76e1873..4a12664 100644
97633 --- a/net/xfrm/xfrm_policy.c
97634 +++ b/net/xfrm/xfrm_policy.c
97635 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
97636 {
97637 policy->walk.dead = 1;
97638
97639 - atomic_inc(&policy->genid);
97640 + atomic_inc_unchecked(&policy->genid);
97641
97642 if (del_timer(&policy->polq.hold_timer))
97643 xfrm_pol_put(policy);
97644 @@ -660,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
97645 hlist_add_head(&policy->bydst, chain);
97646 xfrm_pol_hold(policy);
97647 net->xfrm.policy_count[dir]++;
97648 - atomic_inc(&flow_cache_genid);
97649 + atomic_inc_unchecked(&flow_cache_genid);
97650
97651 /* After previous checking, family can either be AF_INET or AF_INET6 */
97652 if (policy->family == AF_INET)
97653 @@ -1636,7 +1636,7 @@ free_dst:
97654 goto out;
97655 }
97656
97657 -static int inline
97658 +static inline int
97659 xfrm_dst_alloc_copy(void **target, const void *src, int size)
97660 {
97661 if (!*target) {
97662 @@ -1648,7 +1648,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
97663 return 0;
97664 }
97665
97666 -static int inline
97667 +static inline int
97668 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97669 {
97670 #ifdef CONFIG_XFRM_SUB_POLICY
97671 @@ -1660,7 +1660,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97672 #endif
97673 }
97674
97675 -static int inline
97676 +static inline int
97677 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
97678 {
97679 #ifdef CONFIG_XFRM_SUB_POLICY
97680 @@ -1754,7 +1754,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
97681
97682 xdst->num_pols = num_pols;
97683 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
97684 - xdst->policy_genid = atomic_read(&pols[0]->genid);
97685 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
97686
97687 return xdst;
97688 }
97689 @@ -2575,11 +2575,12 @@ void xfrm_garbage_collect(struct net *net)
97690 }
97691 EXPORT_SYMBOL(xfrm_garbage_collect);
97692
97693 -static void xfrm_garbage_collect_deferred(struct net *net)
97694 +void xfrm_garbage_collect_deferred(struct net *net)
97695 {
97696 flow_cache_flush_deferred();
97697 __xfrm_garbage_collect(net);
97698 }
97699 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
97700
97701 static void xfrm_init_pmtu(struct dst_entry *dst)
97702 {
97703 @@ -2629,7 +2630,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
97704 if (xdst->xfrm_genid != dst->xfrm->genid)
97705 return 0;
97706 if (xdst->num_pols > 0 &&
97707 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
97708 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
97709 return 0;
97710
97711 mtu = dst_mtu(dst->child);
97712 @@ -2717,8 +2718,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
97713 dst_ops->link_failure = xfrm_link_failure;
97714 if (likely(dst_ops->neigh_lookup == NULL))
97715 dst_ops->neigh_lookup = xfrm_neigh_lookup;
97716 - if (likely(afinfo->garbage_collect == NULL))
97717 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
97718 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
97719 }
97720 spin_unlock(&xfrm_policy_afinfo_lock);
97721 @@ -2772,7 +2771,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
97722 dst_ops->check = NULL;
97723 dst_ops->negative_advice = NULL;
97724 dst_ops->link_failure = NULL;
97725 - afinfo->garbage_collect = NULL;
97726 }
97727 return err;
97728 }
97729 @@ -3155,7 +3153,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
97730 sizeof(pol->xfrm_vec[i].saddr));
97731 pol->xfrm_vec[i].encap_family = mp->new_family;
97732 /* flush bundles */
97733 - atomic_inc(&pol->genid);
97734 + atomic_inc_unchecked(&pol->genid);
97735 }
97736 }
97737
97738 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
97739 index b9c3f9e..4767526 100644
97740 --- a/net/xfrm/xfrm_state.c
97741 +++ b/net/xfrm/xfrm_state.c
97742 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
97743
97744 if (unlikely(afinfo == NULL))
97745 return -EAFNOSUPPORT;
97746 - typemap = afinfo->type_map;
97747 + typemap = (const struct xfrm_type **)afinfo->type_map;
97748 spin_lock_bh(&xfrm_type_lock);
97749
97750 - if (likely(typemap[type->proto] == NULL))
97751 + if (likely(typemap[type->proto] == NULL)) {
97752 + pax_open_kernel();
97753 typemap[type->proto] = type;
97754 - else
97755 + pax_close_kernel();
97756 + } else
97757 err = -EEXIST;
97758 spin_unlock_bh(&xfrm_type_lock);
97759 xfrm_state_put_afinfo(afinfo);
97760 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
97761
97762 if (unlikely(afinfo == NULL))
97763 return -EAFNOSUPPORT;
97764 - typemap = afinfo->type_map;
97765 + typemap = (const struct xfrm_type **)afinfo->type_map;
97766 spin_lock_bh(&xfrm_type_lock);
97767
97768 if (unlikely(typemap[type->proto] != type))
97769 err = -ENOENT;
97770 - else
97771 + else {
97772 + pax_open_kernel();
97773 typemap[type->proto] = NULL;
97774 + pax_close_kernel();
97775 + }
97776 spin_unlock_bh(&xfrm_type_lock);
97777 xfrm_state_put_afinfo(afinfo);
97778 return err;
97779 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
97780 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
97781 {
97782 struct xfrm_state_afinfo *afinfo;
97783 - const struct xfrm_type **typemap;
97784 const struct xfrm_type *type;
97785 int modload_attempted = 0;
97786
97787 @@ -219,9 +223,8 @@ retry:
97788 afinfo = xfrm_state_get_afinfo(family);
97789 if (unlikely(afinfo == NULL))
97790 return NULL;
97791 - typemap = afinfo->type_map;
97792
97793 - type = typemap[proto];
97794 + type = afinfo->type_map[proto];
97795 if (unlikely(type && !try_module_get(type->owner)))
97796 type = NULL;
97797 if (!type && !modload_attempted) {
97798 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97799 return -EAFNOSUPPORT;
97800
97801 err = -EEXIST;
97802 - modemap = afinfo->mode_map;
97803 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97804 spin_lock_bh(&xfrm_mode_lock);
97805 if (modemap[mode->encap])
97806 goto out;
97807 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97808 if (!try_module_get(afinfo->owner))
97809 goto out;
97810
97811 - mode->afinfo = afinfo;
97812 + pax_open_kernel();
97813 + *(const void **)&mode->afinfo = afinfo;
97814 modemap[mode->encap] = mode;
97815 + pax_close_kernel();
97816 err = 0;
97817
97818 out:
97819 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97820 return -EAFNOSUPPORT;
97821
97822 err = -ENOENT;
97823 - modemap = afinfo->mode_map;
97824 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97825 spin_lock_bh(&xfrm_mode_lock);
97826 if (likely(modemap[mode->encap] == mode)) {
97827 + pax_open_kernel();
97828 modemap[mode->encap] = NULL;
97829 + pax_close_kernel();
97830 module_put(mode->afinfo->owner);
97831 err = 0;
97832 }
97833 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97834 u32 xfrm_get_acqseq(void)
97835 {
97836 u32 res;
97837 - static atomic_t acqseq;
97838 + static atomic_unchecked_t acqseq;
97839
97840 do {
97841 - res = atomic_inc_return(&acqseq);
97842 + res = atomic_inc_return_unchecked(&acqseq);
97843 } while (!res);
97844
97845 return res;
97846 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97847 index 05a6e3d..6716ec9 100644
97848 --- a/net/xfrm/xfrm_sysctl.c
97849 +++ b/net/xfrm/xfrm_sysctl.c
97850 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97851
97852 int __net_init xfrm_sysctl_init(struct net *net)
97853 {
97854 - struct ctl_table *table;
97855 + ctl_table_no_const *table;
97856
97857 __xfrm_sysctl_init(net);
97858
97859 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97860 index d5d859c..781cbcb 100644
97861 --- a/scripts/Makefile.build
97862 +++ b/scripts/Makefile.build
97863 @@ -111,7 +111,7 @@ endif
97864 endif
97865
97866 # Do not include host rules unless needed
97867 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97868 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97869 include scripts/Makefile.host
97870 endif
97871
97872 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97873 index 686cb0d..9d653bf 100644
97874 --- a/scripts/Makefile.clean
97875 +++ b/scripts/Makefile.clean
97876 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97877 __clean-files := $(extra-y) $(always) \
97878 $(targets) $(clean-files) \
97879 $(host-progs) \
97880 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97881 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97882 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97883
97884 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97885
97886 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97887 index 1ac414f..38575f7 100644
97888 --- a/scripts/Makefile.host
97889 +++ b/scripts/Makefile.host
97890 @@ -31,6 +31,8 @@
97891 # Note: Shared libraries consisting of C++ files are not supported
97892
97893 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97894 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97895 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97896
97897 # C code
97898 # Executables compiled from a single .c file
97899 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97900 # Shared libaries (only .c supported)
97901 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97902 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97903 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97904 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97905 # Remove .so files from "xxx-objs"
97906 host-cobjs := $(filter-out %.so,$(host-cobjs))
97907 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97908
97909 -#Object (.o) files used by the shared libaries
97910 +# Object (.o) files used by the shared libaries
97911 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97912 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97913
97914 # output directory for programs/.o files
97915 # hostprogs-y := tools/build may have been specified. Retrieve directory
97916 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97917 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97918 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97919 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97920 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97921 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97922 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97923 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97924
97925 obj-dirs += $(host-objdirs)
97926 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97927 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97928 $(call if_changed_dep,host-cshobjs)
97929
97930 +# Compile .c file, create position independent .o file
97931 +# host-cxxshobjs -> .o
97932 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97933 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97934 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97935 + $(call if_changed_dep,host-cxxshobjs)
97936 +
97937 # Link a shared library, based on position independent .o files
97938 # *.o -> .so shared library (host-cshlib)
97939 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97940 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97941 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97942 $(call if_changed,host-cshlib)
97943
97944 +# Link a shared library, based on position independent .o files
97945 +# *.o -> .so shared library (host-cxxshlib)
97946 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97947 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97948 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97949 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97950 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97951 + $(call if_changed,host-cxxshlib)
97952 +
97953 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97954 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97955 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97956
97957 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97958 index 078fe1d..fbdb363 100644
97959 --- a/scripts/basic/fixdep.c
97960 +++ b/scripts/basic/fixdep.c
97961 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97962 /*
97963 * Lookup a value in the configuration string.
97964 */
97965 -static int is_defined_config(const char *name, int len, unsigned int hash)
97966 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97967 {
97968 struct item *aux;
97969
97970 @@ -211,10 +211,10 @@ static void clear_config(void)
97971 /*
97972 * Record the use of a CONFIG_* word.
97973 */
97974 -static void use_config(const char *m, int slen)
97975 +static void use_config(const char *m, unsigned int slen)
97976 {
97977 unsigned int hash = strhash(m, slen);
97978 - int c, i;
97979 + unsigned int c, i;
97980
97981 if (is_defined_config(m, slen, hash))
97982 return;
97983 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97984
97985 static void parse_config_file(const char *map, size_t len)
97986 {
97987 - const int *end = (const int *) (map + len);
97988 + const unsigned int *end = (const unsigned int *) (map + len);
97989 /* start at +1, so that p can never be < map */
97990 - const int *m = (const int *) map + 1;
97991 + const unsigned int *m = (const unsigned int *) map + 1;
97992 const char *p, *q;
97993
97994 for (; m < end; m++) {
97995 @@ -435,7 +435,7 @@ static void print_deps(void)
97996 static void traps(void)
97997 {
97998 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97999 - int *p = (int *)test;
98000 + unsigned int *p = (unsigned int *)test;
98001
98002 if (*p != INT_CONF) {
98003 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
98004 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
98005 new file mode 100644
98006 index 0000000..5e0222d
98007 --- /dev/null
98008 +++ b/scripts/gcc-plugin.sh
98009 @@ -0,0 +1,17 @@
98010 +#!/bin/bash
98011 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
98012 +#include "gcc-plugin.h"
98013 +#include "tree.h"
98014 +#include "tm.h"
98015 +#include "rtl.h"
98016 +#ifdef ENABLE_BUILD_WITH_CXX
98017 +#warning $2
98018 +#else
98019 +#warning $1
98020 +#endif
98021 +EOF`
98022 +if [ $? -eq 0 ]
98023 +then
98024 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
98025 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
98026 +fi
98027 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
98028 index 5de5660..d3deb89 100644
98029 --- a/scripts/headers_install.sh
98030 +++ b/scripts/headers_install.sh
98031 @@ -32,6 +32,7 @@ do
98032 FILE="$(basename "$i")"
98033 sed -r \
98034 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
98035 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
98036 -e 's/__attribute_const__([ \t]|$)/\1/g' \
98037 -e 's@^#include <linux/compiler.h>@@' \
98038 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
98039 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
98040 index 32b10f5..64eeb30 100644
98041 --- a/scripts/link-vmlinux.sh
98042 +++ b/scripts/link-vmlinux.sh
98043 @@ -82,7 +82,9 @@ kallsyms()
98044 kallsymopt="${kallsymopt} --all-symbols"
98045 fi
98046
98047 - kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
98048 + if [ -z "${CONFIG_X86_32}" ] || [ -z "${CONFIG_PAX_KERNEXEC}" ]; then
98049 + kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
98050 + fi
98051
98052 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
98053 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
98054 @@ -160,7 +162,7 @@ else
98055 fi;
98056
98057 # final build of init/
98058 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
98059 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
98060
98061 kallsymso=""
98062 kallsyms_vmlinux=""
98063 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
98064 index 2370863..212fbca 100644
98065 --- a/scripts/mod/file2alias.c
98066 +++ b/scripts/mod/file2alias.c
98067 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
98068 unsigned long size, unsigned long id_size,
98069 void *symval)
98070 {
98071 - int i;
98072 + unsigned int i;
98073
98074 if (size % id_size || size < id_size) {
98075 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
98076 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
98077 /* USB is special because the bcdDevice can be matched against a numeric range */
98078 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
98079 static void do_usb_entry(void *symval,
98080 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
98081 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
98082 unsigned char range_lo, unsigned char range_hi,
98083 unsigned char max, struct module *mod)
98084 {
98085 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
98086 {
98087 unsigned int devlo, devhi;
98088 unsigned char chi, clo, max;
98089 - int ndigits;
98090 + unsigned int ndigits;
98091
98092 DEF_FIELD(symval, usb_device_id, match_flags);
98093 DEF_FIELD(symval, usb_device_id, idVendor);
98094 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
98095 for (i = 0; i < count; i++) {
98096 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
98097 char acpi_id[sizeof(*id)];
98098 - int j;
98099 + unsigned int j;
98100
98101 buf_printf(&mod->dev_table_buf,
98102 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
98103 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98104
98105 for (j = 0; j < PNP_MAX_DEVICES; j++) {
98106 const char *id = (char *)(*devs)[j].id;
98107 - int i2, j2;
98108 + unsigned int i2, j2;
98109 int dup = 0;
98110
98111 if (!id[0])
98112 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98113 /* add an individual alias for every device entry */
98114 if (!dup) {
98115 char acpi_id[PNP_ID_LEN];
98116 - int k;
98117 + unsigned int k;
98118
98119 buf_printf(&mod->dev_table_buf,
98120 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
98121 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
98122 static int do_dmi_entry(const char *filename, void *symval,
98123 char *alias)
98124 {
98125 - int i, j;
98126 + unsigned int i, j;
98127 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
98128 sprintf(alias, "dmi*");
98129
98130 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
98131 index 8247979..815ec76 100644
98132 --- a/scripts/mod/modpost.c
98133 +++ b/scripts/mod/modpost.c
98134 @@ -931,6 +931,7 @@ enum mismatch {
98135 ANY_INIT_TO_ANY_EXIT,
98136 ANY_EXIT_TO_ANY_INIT,
98137 EXPORT_TO_INIT_EXIT,
98138 + DATA_TO_TEXT
98139 };
98140
98141 struct sectioncheck {
98142 @@ -1017,6 +1018,12 @@ const struct sectioncheck sectioncheck[] = {
98143 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
98144 .mismatch = EXPORT_TO_INIT_EXIT,
98145 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
98146 +},
98147 +/* Do not reference code from writable data */
98148 +{
98149 + .fromsec = { DATA_SECTIONS, NULL },
98150 + .tosec = { TEXT_SECTIONS, NULL },
98151 + .mismatch = DATA_TO_TEXT
98152 }
98153 };
98154
98155 @@ -1137,10 +1144,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
98156 continue;
98157 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
98158 continue;
98159 - if (sym->st_value == addr)
98160 - return sym;
98161 /* Find a symbol nearby - addr are maybe negative */
98162 d = sym->st_value - addr;
98163 + if (d == 0)
98164 + return sym;
98165 if (d < 0)
98166 d = addr - sym->st_value;
98167 if (d < distance) {
98168 @@ -1418,6 +1425,14 @@ static void report_sec_mismatch(const char *modname,
98169 tosym, prl_to, prl_to, tosym);
98170 free(prl_to);
98171 break;
98172 + case DATA_TO_TEXT:
98173 +#if 0
98174 + fprintf(stderr,
98175 + "The %s %s:%s references\n"
98176 + "the %s %s:%s%s\n",
98177 + from, fromsec, fromsym, to, tosec, tosym, to_p);
98178 +#endif
98179 + break;
98180 }
98181 fprintf(stderr, "\n");
98182 }
98183 @@ -1652,7 +1667,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
98184 static void check_sec_ref(struct module *mod, const char *modname,
98185 struct elf_info *elf)
98186 {
98187 - int i;
98188 + unsigned int i;
98189 Elf_Shdr *sechdrs = elf->sechdrs;
98190
98191 /* Walk through all sections */
98192 @@ -1771,7 +1786,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
98193 va_end(ap);
98194 }
98195
98196 -void buf_write(struct buffer *buf, const char *s, int len)
98197 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
98198 {
98199 if (buf->size - buf->pos < len) {
98200 buf->size += len + SZ;
98201 @@ -1990,7 +2005,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
98202 if (fstat(fileno(file), &st) < 0)
98203 goto close_write;
98204
98205 - if (st.st_size != b->pos)
98206 + if (st.st_size != (off_t)b->pos)
98207 goto close_write;
98208
98209 tmp = NOFAIL(malloc(b->pos));
98210 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
98211 index 51207e4..f7d603d 100644
98212 --- a/scripts/mod/modpost.h
98213 +++ b/scripts/mod/modpost.h
98214 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
98215
98216 struct buffer {
98217 char *p;
98218 - int pos;
98219 - int size;
98220 + unsigned int pos;
98221 + unsigned int size;
98222 };
98223
98224 void __attribute__((format(printf, 2, 3)))
98225 buf_printf(struct buffer *buf, const char *fmt, ...);
98226
98227 void
98228 -buf_write(struct buffer *buf, const char *s, int len);
98229 +buf_write(struct buffer *buf, const char *s, unsigned int len);
98230
98231 struct module {
98232 struct module *next;
98233 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
98234 index 9dfcd6d..099068e 100644
98235 --- a/scripts/mod/sumversion.c
98236 +++ b/scripts/mod/sumversion.c
98237 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
98238 goto out;
98239 }
98240
98241 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
98242 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
98243 warn("writing sum in %s failed: %s\n",
98244 filename, strerror(errno));
98245 goto out;
98246 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
98247 index 0865b3e..7235dd4 100644
98248 --- a/scripts/module-common.lds
98249 +++ b/scripts/module-common.lds
98250 @@ -6,6 +6,10 @@
98251 SECTIONS {
98252 /DISCARD/ : { *(.discard) }
98253
98254 + .rodata : {
98255 + *(.rodata) *(.rodata.*)
98256 + *(.data..read_only)
98257 + }
98258 __ksymtab : { *(SORT(___ksymtab+*)) }
98259 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
98260 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
98261 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
98262 index 90e521f..e9eaf8f 100644
98263 --- a/scripts/package/builddeb
98264 +++ b/scripts/package/builddeb
98265 @@ -281,6 +281,7 @@ fi
98266 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
98267 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
98268 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
98269 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
98270 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
98271 mkdir -p "$destdir"
98272 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
98273 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
98274 index 68bb4ef..2f419e1 100644
98275 --- a/scripts/pnmtologo.c
98276 +++ b/scripts/pnmtologo.c
98277 @@ -244,14 +244,14 @@ static void write_header(void)
98278 fprintf(out, " * Linux logo %s\n", logoname);
98279 fputs(" */\n\n", out);
98280 fputs("#include <linux/linux_logo.h>\n\n", out);
98281 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
98282 + fprintf(out, "static unsigned char %s_data[] = {\n",
98283 logoname);
98284 }
98285
98286 static void write_footer(void)
98287 {
98288 fputs("\n};\n\n", out);
98289 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
98290 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
98291 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
98292 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
98293 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
98294 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
98295 fputs("\n};\n\n", out);
98296
98297 /* write logo clut */
98298 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
98299 + fprintf(out, "static unsigned char %s_clut[] = {\n",
98300 logoname);
98301 write_hex_cnt = 0;
98302 for (i = 0; i < logo_clutsize; i++) {
98303 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
98304 index f5eb43d..1814de8 100644
98305 --- a/scripts/sortextable.h
98306 +++ b/scripts/sortextable.h
98307 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
98308 const char *secstrtab;
98309 const char *strtab;
98310 char *extab_image;
98311 - int extab_index = 0;
98312 - int i;
98313 - int idx;
98314 + unsigned int extab_index = 0;
98315 + unsigned int i;
98316 + unsigned int idx;
98317
98318 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
98319 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
98320 diff --git a/security/Kconfig b/security/Kconfig
98321 index e9c6ac7..031a726 100644
98322 --- a/security/Kconfig
98323 +++ b/security/Kconfig
98324 @@ -4,6 +4,960 @@
98325
98326 menu "Security options"
98327
98328 +menu "Grsecurity"
98329 +
98330 + config ARCH_TRACK_EXEC_LIMIT
98331 + bool
98332 +
98333 + config PAX_KERNEXEC_PLUGIN
98334 + bool
98335 +
98336 + config PAX_PER_CPU_PGD
98337 + bool
98338 +
98339 + config TASK_SIZE_MAX_SHIFT
98340 + int
98341 + depends on X86_64
98342 + default 47 if !PAX_PER_CPU_PGD
98343 + default 42 if PAX_PER_CPU_PGD
98344 +
98345 + config PAX_ENABLE_PAE
98346 + bool
98347 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
98348 +
98349 + config PAX_USERCOPY_SLABS
98350 + bool
98351 +
98352 +config GRKERNSEC
98353 + bool "Grsecurity"
98354 + select CRYPTO
98355 + select CRYPTO_SHA256
98356 + select PROC_FS
98357 + select STOP_MACHINE
98358 + select TTY
98359 + select DEBUG_LIST
98360 + help
98361 + If you say Y here, you will be able to configure many features
98362 + that will enhance the security of your system. It is highly
98363 + recommended that you say Y here and read through the help
98364 + for each option so that you fully understand the features and
98365 + can evaluate their usefulness for your machine.
98366 +
98367 +choice
98368 + prompt "Configuration Method"
98369 + depends on GRKERNSEC
98370 + default GRKERNSEC_CONFIG_CUSTOM
98371 + help
98372 +
98373 +config GRKERNSEC_CONFIG_AUTO
98374 + bool "Automatic"
98375 + help
98376 + If you choose this configuration method, you'll be able to answer a small
98377 + number of simple questions about how you plan to use this kernel.
98378 + The settings of grsecurity and PaX will be automatically configured for
98379 + the highest commonly-used settings within the provided constraints.
98380 +
98381 + If you require additional configuration, custom changes can still be made
98382 + from the "custom configuration" menu.
98383 +
98384 +config GRKERNSEC_CONFIG_CUSTOM
98385 + bool "Custom"
98386 + help
98387 + If you choose this configuration method, you'll be able to configure all
98388 + grsecurity and PaX settings manually. Via this method, no options are
98389 + automatically enabled.
98390 +
98391 +endchoice
98392 +
98393 +choice
98394 + prompt "Usage Type"
98395 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98396 + default GRKERNSEC_CONFIG_SERVER
98397 + help
98398 +
98399 +config GRKERNSEC_CONFIG_SERVER
98400 + bool "Server"
98401 + help
98402 + Choose this option if you plan to use this kernel on a server.
98403 +
98404 +config GRKERNSEC_CONFIG_DESKTOP
98405 + bool "Desktop"
98406 + help
98407 + Choose this option if you plan to use this kernel on a desktop.
98408 +
98409 +endchoice
98410 +
98411 +choice
98412 + prompt "Virtualization Type"
98413 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
98414 + default GRKERNSEC_CONFIG_VIRT_NONE
98415 + help
98416 +
98417 +config GRKERNSEC_CONFIG_VIRT_NONE
98418 + bool "None"
98419 + help
98420 + Choose this option if this kernel will be run on bare metal.
98421 +
98422 +config GRKERNSEC_CONFIG_VIRT_GUEST
98423 + bool "Guest"
98424 + help
98425 + Choose this option if this kernel will be run as a VM guest.
98426 +
98427 +config GRKERNSEC_CONFIG_VIRT_HOST
98428 + bool "Host"
98429 + help
98430 + Choose this option if this kernel will be run as a VM host.
98431 +
98432 +endchoice
98433 +
98434 +choice
98435 + prompt "Virtualization Hardware"
98436 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98437 + help
98438 +
98439 +config GRKERNSEC_CONFIG_VIRT_EPT
98440 + bool "EPT/RVI Processor Support"
98441 + depends on X86
98442 + help
98443 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
98444 + hardware virtualization. This allows for additional kernel hardening protections
98445 + to operate without additional performance impact.
98446 +
98447 + To see if your Intel processor supports EPT, see:
98448 + http://ark.intel.com/Products/VirtualizationTechnology
98449 + (Most Core i3/5/7 support EPT)
98450 +
98451 + To see if your AMD processor supports RVI, see:
98452 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
98453 +
98454 +config GRKERNSEC_CONFIG_VIRT_SOFT
98455 + bool "First-gen/No Hardware Virtualization"
98456 + help
98457 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
98458 + support hardware virtualization or doesn't support the EPT/RVI extensions.
98459 +
98460 +endchoice
98461 +
98462 +choice
98463 + prompt "Virtualization Software"
98464 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98465 + help
98466 +
98467 +config GRKERNSEC_CONFIG_VIRT_XEN
98468 + bool "Xen"
98469 + help
98470 + Choose this option if this kernel is running as a Xen guest or host.
98471 +
98472 +config GRKERNSEC_CONFIG_VIRT_VMWARE
98473 + bool "VMWare"
98474 + help
98475 + Choose this option if this kernel is running as a VMWare guest or host.
98476 +
98477 +config GRKERNSEC_CONFIG_VIRT_KVM
98478 + bool "KVM"
98479 + help
98480 + Choose this option if this kernel is running as a KVM guest or host.
98481 +
98482 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
98483 + bool "VirtualBox"
98484 + help
98485 + Choose this option if this kernel is running as a VirtualBox guest or host.
98486 +
98487 +endchoice
98488 +
98489 +choice
98490 + prompt "Required Priorities"
98491 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98492 + default GRKERNSEC_CONFIG_PRIORITY_PERF
98493 + help
98494 +
98495 +config GRKERNSEC_CONFIG_PRIORITY_PERF
98496 + bool "Performance"
98497 + help
98498 + Choose this option if performance is of highest priority for this deployment
98499 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
98500 + clearing of structures intended for userland, and freed memory sanitizing will
98501 + be disabled.
98502 +
98503 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
98504 + bool "Security"
98505 + help
98506 + Choose this option if security is of highest priority for this deployment of
98507 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
98508 + for userland, and freed memory sanitizing will be enabled for this kernel.
98509 + In a worst-case scenario, these features can introduce a 20% performance hit
98510 + (UDEREF on x64 contributing half of this hit).
98511 +
98512 +endchoice
98513 +
98514 +menu "Default Special Groups"
98515 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98516 +
98517 +config GRKERNSEC_PROC_GID
98518 + int "GID exempted from /proc restrictions"
98519 + default 1001
98520 + help
98521 + Setting this GID determines which group will be exempted from
98522 + grsecurity's /proc restrictions, allowing users of the specified
98523 + group to view network statistics and the existence of other users'
98524 + processes on the system. This GID may also be chosen at boot time
98525 + via "grsec_proc_gid=" on the kernel commandline.
98526 +
98527 +config GRKERNSEC_TPE_UNTRUSTED_GID
98528 + int "GID for TPE-untrusted users"
98529 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
98530 + default 1005
98531 + help
98532 + Setting this GID determines which group untrusted users should
98533 + be added to. These users will be placed under grsecurity's Trusted Path
98534 + Execution mechanism, preventing them from executing their own binaries.
98535 + The users will only be able to execute binaries in directories owned and
98536 + writable only by the root user. If the sysctl option is enabled, a sysctl
98537 + option with name "tpe_gid" is created.
98538 +
98539 +config GRKERNSEC_TPE_TRUSTED_GID
98540 + int "GID for TPE-trusted users"
98541 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
98542 + default 1005
98543 + help
98544 + Setting this GID determines what group TPE restrictions will be
98545 + *disabled* for. If the sysctl option is enabled, a sysctl option
98546 + with name "tpe_gid" is created.
98547 +
98548 +config GRKERNSEC_SYMLINKOWN_GID
98549 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
98550 + depends on GRKERNSEC_CONFIG_SERVER
98551 + default 1006
98552 + help
98553 + Setting this GID determines what group kernel-enforced
98554 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
98555 + is enabled, a sysctl option with name "symlinkown_gid" is created.
98556 +
98557 +
98558 +endmenu
98559 +
98560 +menu "Customize Configuration"
98561 +depends on GRKERNSEC
98562 +
98563 +menu "PaX"
98564 +
98565 +config PAX
98566 + bool "Enable various PaX features"
98567 + default y if GRKERNSEC_CONFIG_AUTO
98568 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
98569 + help
98570 + This allows you to enable various PaX features. PaX adds
98571 + intrusion prevention mechanisms to the kernel that reduce
98572 + the risks posed by exploitable memory corruption bugs.
98573 +
98574 +menu "PaX Control"
98575 + depends on PAX
98576 +
98577 +config PAX_SOFTMODE
98578 + bool 'Support soft mode'
98579 + help
98580 + Enabling this option will allow you to run PaX in soft mode, that
98581 + is, PaX features will not be enforced by default, only on executables
98582 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
98583 + support as they are the only way to mark executables for soft mode use.
98584 +
98585 + Soft mode can be activated by using the "pax_softmode=1" kernel command
98586 + line option on boot. Furthermore you can control various PaX features
98587 + at runtime via the entries in /proc/sys/kernel/pax.
98588 +
98589 +config PAX_EI_PAX
98590 + bool 'Use legacy ELF header marking'
98591 + default y if GRKERNSEC_CONFIG_AUTO
98592 + help
98593 + Enabling this option will allow you to control PaX features on
98594 + a per executable basis via the 'chpax' utility available at
98595 + http://pax.grsecurity.net/. The control flags will be read from
98596 + an otherwise reserved part of the ELF header. This marking has
98597 + numerous drawbacks (no support for soft-mode, toolchain does not
98598 + know about the non-standard use of the ELF header) therefore it
98599 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
98600 + support.
98601 +
98602 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
98603 + support as well, they will override the legacy EI_PAX marks.
98604 +
98605 + If you enable none of the marking options then all applications
98606 + will run with PaX enabled on them by default.
98607 +
98608 +config PAX_PT_PAX_FLAGS
98609 + bool 'Use ELF program header marking'
98610 + default y if GRKERNSEC_CONFIG_AUTO
98611 + help
98612 + Enabling this option will allow you to control PaX features on
98613 + a per executable basis via the 'paxctl' utility available at
98614 + http://pax.grsecurity.net/. The control flags will be read from
98615 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
98616 + has the benefits of supporting both soft mode and being fully
98617 + integrated into the toolchain (the binutils patch is available
98618 + from http://pax.grsecurity.net).
98619 +
98620 + Note that if you enable the legacy EI_PAX marking support as well,
98621 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
98622 +
98623 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98624 + must make sure that the marks are the same if a binary has both marks.
98625 +
98626 + If you enable none of the marking options then all applications
98627 + will run with PaX enabled on them by default.
98628 +
98629 +config PAX_XATTR_PAX_FLAGS
98630 + bool 'Use filesystem extended attributes marking'
98631 + default y if GRKERNSEC_CONFIG_AUTO
98632 + select CIFS_XATTR if CIFS
98633 + select EXT2_FS_XATTR if EXT2_FS
98634 + select EXT3_FS_XATTR if EXT3_FS
98635 + select EXT4_FS_XATTR if EXT4_FS
98636 + select JFFS2_FS_XATTR if JFFS2_FS
98637 + select REISERFS_FS_XATTR if REISERFS_FS
98638 + select SQUASHFS_XATTR if SQUASHFS
98639 + select TMPFS_XATTR if TMPFS
98640 + select UBIFS_FS_XATTR if UBIFS_FS
98641 + help
98642 + Enabling this option will allow you to control PaX features on
98643 + a per executable basis via the 'setfattr' utility. The control
98644 + flags will be read from the user.pax.flags extended attribute of
98645 + the file. This marking has the benefit of supporting binary-only
98646 + applications that self-check themselves (e.g., skype) and would
98647 + not tolerate chpax/paxctl changes. The main drawback is that
98648 + extended attributes are not supported by some filesystems (e.g.,
98649 + isofs, udf, vfat) so copying files through such filesystems will
98650 + lose the extended attributes and these PaX markings.
98651 +
98652 + Note that if you enable the legacy EI_PAX marking support as well,
98653 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
98654 +
98655 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98656 + must make sure that the marks are the same if a binary has both marks.
98657 +
98658 + If you enable none of the marking options then all applications
98659 + will run with PaX enabled on them by default.
98660 +
98661 +choice
98662 + prompt 'MAC system integration'
98663 + default PAX_HAVE_ACL_FLAGS
98664 + help
98665 + Mandatory Access Control systems have the option of controlling
98666 + PaX flags on a per executable basis, choose the method supported
98667 + by your particular system.
98668 +
98669 + - "none": if your MAC system does not interact with PaX,
98670 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
98671 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
98672 +
98673 + NOTE: this option is for developers/integrators only.
98674 +
98675 + config PAX_NO_ACL_FLAGS
98676 + bool 'none'
98677 +
98678 + config PAX_HAVE_ACL_FLAGS
98679 + bool 'direct'
98680 +
98681 + config PAX_HOOK_ACL_FLAGS
98682 + bool 'hook'
98683 +endchoice
98684 +
98685 +endmenu
98686 +
98687 +menu "Non-executable pages"
98688 + depends on PAX
98689 +
98690 +config PAX_NOEXEC
98691 + bool "Enforce non-executable pages"
98692 + default y if GRKERNSEC_CONFIG_AUTO
98693 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
98694 + help
98695 + By design some architectures do not allow for protecting memory
98696 + pages against execution or even if they do, Linux does not make
98697 + use of this feature. In practice this means that if a page is
98698 + readable (such as the stack or heap) it is also executable.
98699 +
98700 + There is a well known exploit technique that makes use of this
98701 + fact and a common programming mistake where an attacker can
98702 + introduce code of his choice somewhere in the attacked program's
98703 + memory (typically the stack or the heap) and then execute it.
98704 +
98705 + If the attacked program was running with different (typically
98706 + higher) privileges than that of the attacker, then he can elevate
98707 + his own privilege level (e.g. get a root shell, write to files for
98708 + which he does not have write access to, etc).
98709 +
98710 + Enabling this option will let you choose from various features
98711 + that prevent the injection and execution of 'foreign' code in
98712 + a program.
98713 +
98714 + This will also break programs that rely on the old behaviour and
98715 + expect that dynamically allocated memory via the malloc() family
98716 + of functions is executable (which it is not). Notable examples
98717 + are the XFree86 4.x server, the java runtime and wine.
98718 +
98719 +config PAX_PAGEEXEC
98720 + bool "Paging based non-executable pages"
98721 + default y if GRKERNSEC_CONFIG_AUTO
98722 + 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)
98723 + select ARCH_TRACK_EXEC_LIMIT if X86_32
98724 + help
98725 + This implementation is based on the paging feature of the CPU.
98726 + On i386 without hardware non-executable bit support there is a
98727 + variable but usually low performance impact, however on Intel's
98728 + P4 core based CPUs it is very high so you should not enable this
98729 + for kernels meant to be used on such CPUs.
98730 +
98731 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
98732 + with hardware non-executable bit support there is no performance
98733 + impact, on ppc the impact is negligible.
98734 +
98735 + Note that several architectures require various emulations due to
98736 + badly designed userland ABIs, this will cause a performance impact
98737 + but will disappear as soon as userland is fixed. For example, ppc
98738 + userland MUST have been built with secure-plt by a recent toolchain.
98739 +
98740 +config PAX_SEGMEXEC
98741 + bool "Segmentation based non-executable pages"
98742 + default y if GRKERNSEC_CONFIG_AUTO
98743 + depends on PAX_NOEXEC && X86_32
98744 + help
98745 + This implementation is based on the segmentation feature of the
98746 + CPU and has a very small performance impact, however applications
98747 + will be limited to a 1.5 GB address space instead of the normal
98748 + 3 GB.
98749 +
98750 +config PAX_EMUTRAMP
98751 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
98752 + default y if PARISC
98753 + help
98754 + There are some programs and libraries that for one reason or
98755 + another attempt to execute special small code snippets from
98756 + non-executable memory pages. Most notable examples are the
98757 + signal handler return code generated by the kernel itself and
98758 + the GCC trampolines.
98759 +
98760 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
98761 + such programs will no longer work under your kernel.
98762 +
98763 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
98764 + utilities to enable trampoline emulation for the affected programs
98765 + yet still have the protection provided by the non-executable pages.
98766 +
98767 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
98768 + your system will not even boot.
98769 +
98770 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
98771 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
98772 + for the affected files.
98773 +
98774 + NOTE: enabling this feature *may* open up a loophole in the
98775 + protection provided by non-executable pages that an attacker
98776 + could abuse. Therefore the best solution is to not have any
98777 + files on your system that would require this option. This can
98778 + be achieved by not using libc5 (which relies on the kernel
98779 + signal handler return code) and not using or rewriting programs
98780 + that make use of the nested function implementation of GCC.
98781 + Skilled users can just fix GCC itself so that it implements
98782 + nested function calls in a way that does not interfere with PaX.
98783 +
98784 +config PAX_EMUSIGRT
98785 + bool "Automatically emulate sigreturn trampolines"
98786 + depends on PAX_EMUTRAMP && PARISC
98787 + default y
98788 + help
98789 + Enabling this option will have the kernel automatically detect
98790 + and emulate signal return trampolines executing on the stack
98791 + that would otherwise lead to task termination.
98792 +
98793 + This solution is intended as a temporary one for users with
98794 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98795 + Modula-3 runtime, etc) or executables linked to such, basically
98796 + everything that does not specify its own SA_RESTORER function in
98797 + normal executable memory like glibc 2.1+ does.
98798 +
98799 + On parisc you MUST enable this option, otherwise your system will
98800 + not even boot.
98801 +
98802 + NOTE: this feature cannot be disabled on a per executable basis
98803 + and since it *does* open up a loophole in the protection provided
98804 + by non-executable pages, the best solution is to not have any
98805 + files on your system that would require this option.
98806 +
98807 +config PAX_MPROTECT
98808 + bool "Restrict mprotect()"
98809 + default y if GRKERNSEC_CONFIG_AUTO
98810 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98811 + help
98812 + Enabling this option will prevent programs from
98813 + - changing the executable status of memory pages that were
98814 + not originally created as executable,
98815 + - making read-only executable pages writable again,
98816 + - creating executable pages from anonymous memory,
98817 + - making read-only-after-relocations (RELRO) data pages writable again.
98818 +
98819 + You should say Y here to complete the protection provided by
98820 + the enforcement of non-executable pages.
98821 +
98822 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98823 + this feature on a per file basis.
98824 +
98825 +config PAX_MPROTECT_COMPAT
98826 + bool "Use legacy/compat protection demoting (read help)"
98827 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98828 + depends on PAX_MPROTECT
98829 + help
98830 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98831 + by sending the proper error code to the application. For some broken
98832 + userland, this can cause problems with Python or other applications. The
98833 + current implementation however allows for applications like clamav to
98834 + detect if JIT compilation/execution is allowed and to fall back gracefully
98835 + to an interpreter-based mode if it does not. While we encourage everyone
98836 + to use the current implementation as-is and push upstream to fix broken
98837 + userland (note that the RWX logging option can assist with this), in some
98838 + environments this may not be possible. Having to disable MPROTECT
98839 + completely on certain binaries reduces the security benefit of PaX,
98840 + so this option is provided for those environments to revert to the old
98841 + behavior.
98842 +
98843 +config PAX_ELFRELOCS
98844 + bool "Allow ELF text relocations (read help)"
98845 + depends on PAX_MPROTECT
98846 + default n
98847 + help
98848 + Non-executable pages and mprotect() restrictions are effective
98849 + in preventing the introduction of new executable code into an
98850 + attacked task's address space. There remain only two venues
98851 + for this kind of attack: if the attacker can execute already
98852 + existing code in the attacked task then he can either have it
98853 + create and mmap() a file containing his code or have it mmap()
98854 + an already existing ELF library that does not have position
98855 + independent code in it and use mprotect() on it to make it
98856 + writable and copy his code there. While protecting against
98857 + the former approach is beyond PaX, the latter can be prevented
98858 + by having only PIC ELF libraries on one's system (which do not
98859 + need to relocate their code). If you are sure this is your case,
98860 + as is the case with all modern Linux distributions, then leave
98861 + this option disabled. You should say 'n' here.
98862 +
98863 +config PAX_ETEXECRELOCS
98864 + bool "Allow ELF ET_EXEC text relocations"
98865 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98866 + select PAX_ELFRELOCS
98867 + default y
98868 + help
98869 + On some architectures there are incorrectly created applications
98870 + that require text relocations and would not work without enabling
98871 + this option. If you are an alpha, ia64 or parisc user, you should
98872 + enable this option and disable it once you have made sure that
98873 + none of your applications need it.
98874 +
98875 +config PAX_EMUPLT
98876 + bool "Automatically emulate ELF PLT"
98877 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98878 + default y
98879 + help
98880 + Enabling this option will have the kernel automatically detect
98881 + and emulate the Procedure Linkage Table entries in ELF files.
98882 + On some architectures such entries are in writable memory, and
98883 + become non-executable leading to task termination. Therefore
98884 + it is mandatory that you enable this option on alpha, parisc,
98885 + sparc and sparc64, otherwise your system would not even boot.
98886 +
98887 + NOTE: this feature *does* open up a loophole in the protection
98888 + provided by the non-executable pages, therefore the proper
98889 + solution is to modify the toolchain to produce a PLT that does
98890 + not need to be writable.
98891 +
98892 +config PAX_DLRESOLVE
98893 + bool 'Emulate old glibc resolver stub'
98894 + depends on PAX_EMUPLT && SPARC
98895 + default n
98896 + help
98897 + This option is needed if userland has an old glibc (before 2.4)
98898 + that puts a 'save' instruction into the runtime generated resolver
98899 + stub that needs special emulation.
98900 +
98901 +config PAX_KERNEXEC
98902 + bool "Enforce non-executable kernel pages"
98903 + 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))
98904 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98905 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98906 + select PAX_KERNEXEC_PLUGIN if X86_64
98907 + help
98908 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98909 + that is, enabling this option will make it harder to inject
98910 + and execute 'foreign' code in kernel memory itself.
98911 +
98912 +choice
98913 + prompt "Return Address Instrumentation Method"
98914 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98915 + depends on PAX_KERNEXEC_PLUGIN
98916 + help
98917 + Select the method used to instrument function pointer dereferences.
98918 + Note that binary modules cannot be instrumented by this approach.
98919 +
98920 + Note that the implementation requires a gcc with plugin support,
98921 + i.e., gcc 4.5 or newer. You may need to install the supporting
98922 + headers explicitly in addition to the normal gcc package.
98923 +
98924 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98925 + bool "bts"
98926 + help
98927 + This method is compatible with binary only modules but has
98928 + a higher runtime overhead.
98929 +
98930 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98931 + bool "or"
98932 + depends on !PARAVIRT
98933 + help
98934 + This method is incompatible with binary only modules but has
98935 + a lower runtime overhead.
98936 +endchoice
98937 +
98938 +config PAX_KERNEXEC_PLUGIN_METHOD
98939 + string
98940 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98941 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98942 + default ""
98943 +
98944 +config PAX_KERNEXEC_MODULE_TEXT
98945 + int "Minimum amount of memory reserved for module code"
98946 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98947 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98948 + depends on PAX_KERNEXEC && X86_32
98949 + help
98950 + Due to implementation details the kernel must reserve a fixed
98951 + amount of memory for runtime allocated code (such as modules)
98952 + at compile time that cannot be changed at runtime. Here you
98953 + can specify the minimum amount in MB that will be reserved.
98954 + Due to the same implementation details this size will always
98955 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98956 + the actually available memory for runtime allocated code will
98957 + usually be more than this minimum.
98958 +
98959 + The default 4 MB should be enough for most users but if you have
98960 + an excessive number of modules (e.g., most distribution configs
98961 + compile many drivers as modules) or use huge modules such as
98962 + nvidia's kernel driver, you will need to adjust this amount.
98963 + A good rule of thumb is to look at your currently loaded kernel
98964 + modules and add up their sizes.
98965 +
98966 +endmenu
98967 +
98968 +menu "Address Space Layout Randomization"
98969 + depends on PAX
98970 +
98971 +config PAX_ASLR
98972 + bool "Address Space Layout Randomization"
98973 + default y if GRKERNSEC_CONFIG_AUTO
98974 + help
98975 + Many if not most exploit techniques rely on the knowledge of
98976 + certain addresses in the attacked program. The following options
98977 + will allow the kernel to apply a certain amount of randomization
98978 + to specific parts of the program thereby forcing an attacker to
98979 + guess them in most cases. Any failed guess will most likely crash
98980 + the attacked program which allows the kernel to detect such attempts
98981 + and react on them. PaX itself provides no reaction mechanisms,
98982 + instead it is strongly encouraged that you make use of Nergal's
98983 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98984 + (http://www.grsecurity.net/) built-in crash detection features or
98985 + develop one yourself.
98986 +
98987 + By saying Y here you can choose to randomize the following areas:
98988 + - top of the task's kernel stack
98989 + - top of the task's userland stack
98990 + - base address for mmap() requests that do not specify one
98991 + (this includes all libraries)
98992 + - base address of the main executable
98993 +
98994 + It is strongly recommended to say Y here as address space layout
98995 + randomization has negligible impact on performance yet it provides
98996 + a very effective protection.
98997 +
98998 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98999 + this feature on a per file basis.
99000 +
99001 +config PAX_RANDKSTACK
99002 + bool "Randomize kernel stack base"
99003 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
99004 + depends on X86_TSC && X86
99005 + help
99006 + By saying Y here the kernel will randomize every task's kernel
99007 + stack on every system call. This will not only force an attacker
99008 + to guess it but also prevent him from making use of possible
99009 + leaked information about it.
99010 +
99011 + Since the kernel stack is a rather scarce resource, randomization
99012 + may cause unexpected stack overflows, therefore you should very
99013 + carefully test your system. Note that once enabled in the kernel
99014 + configuration, this feature cannot be disabled on a per file basis.
99015 +
99016 +config PAX_RANDUSTACK
99017 + bool "Randomize user stack base"
99018 + default y if GRKERNSEC_CONFIG_AUTO
99019 + depends on PAX_ASLR
99020 + help
99021 + By saying Y here the kernel will randomize every task's userland
99022 + stack. The randomization is done in two steps where the second
99023 + one may apply a big amount of shift to the top of the stack and
99024 + cause problems for programs that want to use lots of memory (more
99025 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
99026 + For this reason the second step can be controlled by 'chpax' or
99027 + 'paxctl' on a per file basis.
99028 +
99029 +config PAX_RANDMMAP
99030 + bool "Randomize mmap() base"
99031 + default y if GRKERNSEC_CONFIG_AUTO
99032 + depends on PAX_ASLR
99033 + help
99034 + By saying Y here the kernel will use a randomized base address for
99035 + mmap() requests that do not specify one themselves. As a result
99036 + all dynamically loaded libraries will appear at random addresses
99037 + and therefore be harder to exploit by a technique where an attacker
99038 + attempts to execute library code for his purposes (e.g. spawn a
99039 + shell from an exploited program that is running at an elevated
99040 + privilege level).
99041 +
99042 + Furthermore, if a program is relinked as a dynamic ELF file, its
99043 + base address will be randomized as well, completing the full
99044 + randomization of the address space layout. Attacking such programs
99045 + becomes a guess game. You can find an example of doing this at
99046 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
99047 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
99048 +
99049 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
99050 + feature on a per file basis.
99051 +
99052 +endmenu
99053 +
99054 +menu "Miscellaneous hardening features"
99055 +
99056 +config PAX_MEMORY_SANITIZE
99057 + bool "Sanitize all freed memory"
99058 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99059 + depends on !HIBERNATION
99060 + help
99061 + By saying Y here the kernel will erase memory pages and slab objects
99062 + as soon as they are freed. This in turn reduces the lifetime of data
99063 + stored in them, making it less likely that sensitive information such
99064 + as passwords, cryptographic secrets, etc stay in memory for too long.
99065 +
99066 + This is especially useful for programs whose runtime is short, long
99067 + lived processes and the kernel itself benefit from this as long as
99068 + they ensure timely freeing of memory that may hold sensitive
99069 + information.
99070 +
99071 + A nice side effect of the sanitization of slab objects is the
99072 + reduction of possible info leaks caused by padding bytes within the
99073 + leaky structures. Use-after-free bugs for structures containing
99074 + pointers can also be detected as dereferencing the sanitized pointer
99075 + will generate an access violation.
99076 +
99077 + The tradeoff is performance impact, on a single CPU system kernel
99078 + compilation sees a 3% slowdown, other systems and workloads may vary
99079 + and you are advised to test this feature on your expected workload
99080 + before deploying it.
99081 +
99082 + To reduce the performance penalty by sanitizing pages only, albeit
99083 + limiting the effectiveness of this feature at the same time, slab
99084 + sanitization can be disabled with the kernel commandline parameter
99085 + "pax_sanitize_slab=0".
99086 +
99087 + Note that this feature does not protect data stored in live pages,
99088 + e.g., process memory swapped to disk may stay there for a long time.
99089 +
99090 +config PAX_MEMORY_STACKLEAK
99091 + bool "Sanitize kernel stack"
99092 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99093 + depends on X86
99094 + help
99095 + By saying Y here the kernel will erase the kernel stack before it
99096 + returns from a system call. This in turn reduces the information
99097 + that a kernel stack leak bug can reveal.
99098 +
99099 + Note that such a bug can still leak information that was put on
99100 + the stack by the current system call (the one eventually triggering
99101 + the bug) but traces of earlier system calls on the kernel stack
99102 + cannot leak anymore.
99103 +
99104 + The tradeoff is performance impact: on a single CPU system kernel
99105 + compilation sees a 1% slowdown, other systems and workloads may vary
99106 + and you are advised to test this feature on your expected workload
99107 + before deploying it.
99108 +
99109 + Note that the full feature requires a gcc with plugin support,
99110 + i.e., gcc 4.5 or newer. You may need to install the supporting
99111 + headers explicitly in addition to the normal gcc package. Using
99112 + older gcc versions means that functions with large enough stack
99113 + frames may leave uninitialized memory behind that may be exposed
99114 + to a later syscall leaking the stack.
99115 +
99116 +config PAX_MEMORY_STRUCTLEAK
99117 + bool "Forcibly initialize local variables copied to userland"
99118 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99119 + help
99120 + By saying Y here the kernel will zero initialize some local
99121 + variables that are going to be copied to userland. This in
99122 + turn prevents unintended information leakage from the kernel
99123 + stack should later code forget to explicitly set all parts of
99124 + the copied variable.
99125 +
99126 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
99127 + at a much smaller coverage.
99128 +
99129 + Note that the implementation requires a gcc with plugin support,
99130 + i.e., gcc 4.5 or newer. You may need to install the supporting
99131 + headers explicitly in addition to the normal gcc package.
99132 +
99133 +config PAX_MEMORY_UDEREF
99134 + bool "Prevent invalid userland pointer dereference"
99135 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
99136 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
99137 + select PAX_PER_CPU_PGD if X86_64
99138 + help
99139 + By saying Y here the kernel will be prevented from dereferencing
99140 + userland pointers in contexts where the kernel expects only kernel
99141 + pointers. This is both a useful runtime debugging feature and a
99142 + security measure that prevents exploiting a class of kernel bugs.
99143 +
99144 + The tradeoff is that some virtualization solutions may experience
99145 + a huge slowdown and therefore you should not enable this feature
99146 + for kernels meant to run in such environments. Whether a given VM
99147 + solution is affected or not is best determined by simply trying it
99148 + out, the performance impact will be obvious right on boot as this
99149 + mechanism engages from very early on. A good rule of thumb is that
99150 + VMs running on CPUs without hardware virtualization support (i.e.,
99151 + the majority of IA-32 CPUs) will likely experience the slowdown.
99152 +
99153 + On X86_64 the kernel will make use of PCID support when available
99154 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
99155 + or performance impact. Pass pax_weakuderef on the kernel command
99156 + line to choose the latter.
99157 +
99158 +config PAX_REFCOUNT
99159 + bool "Prevent various kernel object reference counter overflows"
99160 + default y if GRKERNSEC_CONFIG_AUTO
99161 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
99162 + help
99163 + By saying Y here the kernel will detect and prevent overflowing
99164 + various (but not all) kinds of object reference counters. Such
99165 + overflows can normally occur due to bugs only and are often, if
99166 + not always, exploitable.
99167 +
99168 + The tradeoff is that data structures protected by an overflowed
99169 + refcount will never be freed and therefore will leak memory. Note
99170 + that this leak also happens even without this protection but in
99171 + that case the overflow can eventually trigger the freeing of the
99172 + data structure while it is still being used elsewhere, resulting
99173 + in the exploitable situation that this feature prevents.
99174 +
99175 + Since this has a negligible performance impact, you should enable
99176 + this feature.
99177 +
99178 +config PAX_CONSTIFY_PLUGIN
99179 + bool "Automatically constify eligible structures"
99180 + default y
99181 + depends on !UML && PAX_KERNEXEC
99182 + help
99183 + By saying Y here the compiler will automatically constify a class
99184 + of types that contain only function pointers. This reduces the
99185 + kernel's attack surface and also produces a better memory layout.
99186 +
99187 + Note that the implementation requires a gcc with plugin support,
99188 + i.e., gcc 4.5 or newer. You may need to install the supporting
99189 + headers explicitly in addition to the normal gcc package.
99190 +
99191 + Note that if some code really has to modify constified variables
99192 + then the source code will have to be patched to allow it. Examples
99193 + can be found in PaX itself (the no_const attribute) and for some
99194 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
99195 +
99196 +config PAX_USERCOPY
99197 + bool "Harden heap object copies between kernel and userland"
99198 + default y if GRKERNSEC_CONFIG_AUTO
99199 + depends on ARM || IA64 || PPC || SPARC || X86
99200 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
99201 + select PAX_USERCOPY_SLABS
99202 + help
99203 + By saying Y here the kernel will enforce the size of heap objects
99204 + when they are copied in either direction between the kernel and
99205 + userland, even if only a part of the heap object is copied.
99206 +
99207 + Specifically, this checking prevents information leaking from the
99208 + kernel heap during kernel to userland copies (if the kernel heap
99209 + object is otherwise fully initialized) and prevents kernel heap
99210 + overflows during userland to kernel copies.
99211 +
99212 + Note that the current implementation provides the strictest bounds
99213 + checks for the SLUB allocator.
99214 +
99215 + Enabling this option also enables per-slab cache protection against
99216 + data in a given cache being copied into/out of via userland
99217 + accessors. Though the whitelist of regions will be reduced over
99218 + time, it notably protects important data structures like task structs.
99219 +
99220 + If frame pointers are enabled on x86, this option will also restrict
99221 + copies into and out of the kernel stack to local variables within a
99222 + single frame.
99223 +
99224 + Since this has a negligible performance impact, you should enable
99225 + this feature.
99226 +
99227 +config PAX_USERCOPY_DEBUG
99228 + bool
99229 + depends on X86 && PAX_USERCOPY
99230 + default n
99231 +
99232 +config PAX_SIZE_OVERFLOW
99233 + bool "Prevent various integer overflows in function size parameters"
99234 + default y if GRKERNSEC_CONFIG_AUTO
99235 + depends on X86
99236 + help
99237 + By saying Y here the kernel recomputes expressions of function
99238 + arguments marked by a size_overflow attribute with double integer
99239 + precision (DImode/TImode for 32/64 bit integer types).
99240 +
99241 + The recomputed argument is checked against TYPE_MAX and an event
99242 + is logged on overflow and the triggering process is killed.
99243 +
99244 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
99245 +
99246 + Note that the implementation requires a gcc with plugin support,
99247 + i.e., gcc 4.5 or newer. You may need to install the supporting
99248 + headers explicitly in addition to the normal gcc package.
99249 +
99250 +config PAX_LATENT_ENTROPY
99251 + bool "Generate some entropy during boot and runtime"
99252 + default y if GRKERNSEC_CONFIG_AUTO
99253 + help
99254 + By saying Y here the kernel will instrument some kernel code to
99255 + extract some entropy from both original and artificially created
99256 + program state. This will help especially embedded systems where
99257 + there is little 'natural' source of entropy normally. The cost
99258 + is some slowdown of the boot process and fork and irq processing.
99259 +
99260 + When pax_extra_latent_entropy is passed on the kernel command line,
99261 + entropy will be extracted from up to the first 4GB of RAM while the
99262 + runtime memory allocator is being initialized. This costs even more
99263 + slowdown of the boot process.
99264 +
99265 + Note that the implementation requires a gcc with plugin support,
99266 + i.e., gcc 4.5 or newer. You may need to install the supporting
99267 + headers explicitly in addition to the normal gcc package.
99268 +
99269 + Note that entropy extracted this way is not cryptographically
99270 + secure!
99271 +
99272 +endmenu
99273 +
99274 +endmenu
99275 +
99276 +source grsecurity/Kconfig
99277 +
99278 +endmenu
99279 +
99280 +endmenu
99281 +
99282 source security/keys/Kconfig
99283
99284 config SECURITY_DMESG_RESTRICT
99285 @@ -103,7 +1057,7 @@ config INTEL_TXT
99286 config LSM_MMAP_MIN_ADDR
99287 int "Low address space for LSM to protect from user allocation"
99288 depends on SECURITY && SECURITY_SELINUX
99289 - default 32768 if ARM
99290 + default 32768 if ALPHA || ARM || PARISC || SPARC32
99291 default 65536
99292 help
99293 This is the portion of low virtual memory which should be protected
99294 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
99295 index fb99e18..b3e0bbb 100644
99296 --- a/security/apparmor/lsm.c
99297 +++ b/security/apparmor/lsm.c
99298 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
99299 return error;
99300 }
99301
99302 -static struct security_operations apparmor_ops = {
99303 +static struct security_operations apparmor_ops __read_only = {
99304 .name = "apparmor",
99305
99306 .ptrace_access_check = apparmor_ptrace_access_check,
99307 diff --git a/security/commoncap.c b/security/commoncap.c
99308 index b9d613e..f68305c 100644
99309 --- a/security/commoncap.c
99310 +++ b/security/commoncap.c
99311 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
99312 return 0;
99313 }
99314
99315 +/* returns:
99316 + 1 for suid privilege
99317 + 2 for sgid privilege
99318 + 3 for fscap privilege
99319 +*/
99320 +int is_privileged_binary(const struct dentry *dentry)
99321 +{
99322 + struct cpu_vfs_cap_data capdata;
99323 + struct inode *inode = dentry->d_inode;
99324 +
99325 + if (!inode || S_ISDIR(inode->i_mode))
99326 + return 0;
99327 +
99328 + if (inode->i_mode & S_ISUID)
99329 + return 1;
99330 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
99331 + return 2;
99332 +
99333 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
99334 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
99335 + return 3;
99336 + }
99337 +
99338 + return 0;
99339 +}
99340 +
99341 /*
99342 * Attempt to get the on-exec apply capability sets for an executable file from
99343 * its xattrs and, if present, apply them to the proposed credentials being
99344 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
99345 const struct cred *cred = current_cred();
99346 kuid_t root_uid = make_kuid(cred->user_ns, 0);
99347
99348 + if (gr_acl_enable_at_secure())
99349 + return 1;
99350 +
99351 if (!uid_eq(cred->uid, root_uid)) {
99352 if (bprm->cap_effective)
99353 return 1;
99354 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
99355 index b3dd616..4bb17f3 100644
99356 --- a/security/integrity/ima/ima.h
99357 +++ b/security/integrity/ima/ima.h
99358 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
99359 extern spinlock_t ima_queue_lock;
99360
99361 struct ima_h_table {
99362 - atomic_long_t len; /* number of stored measurements in the list */
99363 - atomic_long_t violations;
99364 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
99365 + atomic_long_unchecked_t violations;
99366 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
99367 };
99368 extern struct ima_h_table ima_htable;
99369 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
99370 index 1c03e8f1..398a941 100644
99371 --- a/security/integrity/ima/ima_api.c
99372 +++ b/security/integrity/ima/ima_api.c
99373 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
99374 int result;
99375
99376 /* can overflow, only indicator */
99377 - atomic_long_inc(&ima_htable.violations);
99378 + atomic_long_inc_unchecked(&ima_htable.violations);
99379
99380 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
99381 if (!entry) {
99382 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
99383 index 38477c9..87a60c7 100644
99384 --- a/security/integrity/ima/ima_fs.c
99385 +++ b/security/integrity/ima/ima_fs.c
99386 @@ -28,12 +28,12 @@
99387 static int valid_policy = 1;
99388 #define TMPBUFLEN 12
99389 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
99390 - loff_t *ppos, atomic_long_t *val)
99391 + loff_t *ppos, atomic_long_unchecked_t *val)
99392 {
99393 char tmpbuf[TMPBUFLEN];
99394 ssize_t len;
99395
99396 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
99397 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
99398 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
99399 }
99400
99401 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
99402 index ff63fe0..809cd96 100644
99403 --- a/security/integrity/ima/ima_queue.c
99404 +++ b/security/integrity/ima/ima_queue.c
99405 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
99406 INIT_LIST_HEAD(&qe->later);
99407 list_add_tail_rcu(&qe->later, &ima_measurements);
99408
99409 - atomic_long_inc(&ima_htable.len);
99410 + atomic_long_inc_unchecked(&ima_htable.len);
99411 key = ima_hash_key(entry->digest);
99412 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
99413 return 0;
99414 diff --git a/security/keys/compat.c b/security/keys/compat.c
99415 index d65fa7f..cbfe366 100644
99416 --- a/security/keys/compat.c
99417 +++ b/security/keys/compat.c
99418 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
99419 if (ret == 0)
99420 goto no_payload_free;
99421
99422 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99423 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99424 err:
99425 if (iov != iovstack)
99426 kfree(iov);
99427 diff --git a/security/keys/internal.h b/security/keys/internal.h
99428 index d4f1468..cc52f92 100644
99429 --- a/security/keys/internal.h
99430 +++ b/security/keys/internal.h
99431 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
99432 extern long keyctl_invalidate_key(key_serial_t);
99433
99434 extern long keyctl_instantiate_key_common(key_serial_t,
99435 - const struct iovec *,
99436 + const struct iovec __user *,
99437 unsigned, size_t, key_serial_t);
99438
99439 /*
99440 diff --git a/security/keys/key.c b/security/keys/key.c
99441 index 8fb7c7b..ba3610d 100644
99442 --- a/security/keys/key.c
99443 +++ b/security/keys/key.c
99444 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
99445
99446 atomic_set(&key->usage, 1);
99447 init_rwsem(&key->sem);
99448 - lockdep_set_class(&key->sem, &type->lock_class);
99449 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
99450 key->type = type;
99451 key->user = user;
99452 key->quotalen = quotalen;
99453 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
99454 struct key_type *p;
99455 int ret;
99456
99457 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
99458 + pax_open_kernel();
99459 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
99460 + pax_close_kernel();
99461
99462 ret = -EEXIST;
99463 down_write(&key_types_sem);
99464 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
99465 }
99466
99467 /* store the type */
99468 - list_add(&ktype->link, &key_types_list);
99469 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
99470
99471 pr_notice("Key type %s registered\n", ktype->name);
99472 ret = 0;
99473 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
99474 void unregister_key_type(struct key_type *ktype)
99475 {
99476 down_write(&key_types_sem);
99477 - list_del_init(&ktype->link);
99478 + pax_list_del_init((struct list_head *)&ktype->link);
99479 downgrade_write(&key_types_sem);
99480 key_gc_keytype(ktype);
99481 pr_notice("Key type %s unregistered\n", ktype->name);
99482 @@ -1084,10 +1086,10 @@ void __init key_init(void)
99483 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
99484
99485 /* add the special key types */
99486 - list_add_tail(&key_type_keyring.link, &key_types_list);
99487 - list_add_tail(&key_type_dead.link, &key_types_list);
99488 - list_add_tail(&key_type_user.link, &key_types_list);
99489 - list_add_tail(&key_type_logon.link, &key_types_list);
99490 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
99491 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
99492 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
99493 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
99494
99495 /* record the root user tracking */
99496 rb_link_node(&root_key_user.node,
99497 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
99498 index 33cfd27..842fc5a 100644
99499 --- a/security/keys/keyctl.c
99500 +++ b/security/keys/keyctl.c
99501 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
99502 /*
99503 * Copy the iovec data from userspace
99504 */
99505 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99506 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
99507 unsigned ioc)
99508 {
99509 for (; ioc > 0; ioc--) {
99510 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99511 * If successful, 0 will be returned.
99512 */
99513 long keyctl_instantiate_key_common(key_serial_t id,
99514 - const struct iovec *payload_iov,
99515 + const struct iovec __user *payload_iov,
99516 unsigned ioc,
99517 size_t plen,
99518 key_serial_t ringid)
99519 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
99520 [0].iov_len = plen
99521 };
99522
99523 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
99524 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
99525 }
99526
99527 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
99528 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99529 if (ret == 0)
99530 goto no_payload_free;
99531
99532 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99533 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99534 err:
99535 if (iov != iovstack)
99536 kfree(iov);
99537 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99538 index 6ece7f2..ecdb55c 100644
99539 --- a/security/keys/keyring.c
99540 +++ b/security/keys/keyring.c
99541 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99542 ret = -EFAULT;
99543
99544 for (loop = 0; loop < klist->nkeys; loop++) {
99545 + key_serial_t serial;
99546 key = rcu_deref_link_locked(klist, loop,
99547 keyring);
99548 + serial = key->serial;
99549
99550 tmp = sizeof(key_serial_t);
99551 if (tmp > buflen)
99552 tmp = buflen;
99553
99554 - if (copy_to_user(buffer,
99555 - &key->serial,
99556 - tmp) != 0)
99557 + if (copy_to_user(buffer, &serial, tmp))
99558 goto error;
99559
99560 buflen -= tmp;
99561 diff --git a/security/min_addr.c b/security/min_addr.c
99562 index f728728..6457a0c 100644
99563 --- a/security/min_addr.c
99564 +++ b/security/min_addr.c
99565 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99566 */
99567 static void update_mmap_min_addr(void)
99568 {
99569 +#ifndef SPARC
99570 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99571 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99572 mmap_min_addr = dac_mmap_min_addr;
99573 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99574 #else
99575 mmap_min_addr = dac_mmap_min_addr;
99576 #endif
99577 +#endif
99578 }
99579
99580 /*
99581 diff --git a/security/security.c b/security/security.c
99582 index 4dc31f4..eabcf41 100644
99583 --- a/security/security.c
99584 +++ b/security/security.c
99585 @@ -33,8 +33,8 @@
99586 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99587 CONFIG_DEFAULT_SECURITY;
99588
99589 -static struct security_operations *security_ops;
99590 -static struct security_operations default_security_ops = {
99591 +struct security_operations *security_ops __read_only;
99592 +struct security_operations default_security_ops __read_only = {
99593 .name = "default",
99594 };
99595
99596 @@ -73,11 +73,6 @@ int __init security_init(void)
99597 return 0;
99598 }
99599
99600 -void reset_security_ops(void)
99601 -{
99602 - security_ops = &default_security_ops;
99603 -}
99604 -
99605 /* Save user chosen LSM */
99606 static int __init choose_lsm(char *str)
99607 {
99608 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99609 index fc3e662..7844c60 100644
99610 --- a/security/selinux/avc.c
99611 +++ b/security/selinux/avc.c
99612 @@ -59,7 +59,7 @@ struct avc_node {
99613 struct avc_cache {
99614 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99615 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99616 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99617 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99618 atomic_t active_nodes;
99619 u32 latest_notif; /* latest revocation notification */
99620 };
99621 @@ -167,7 +167,7 @@ void __init avc_init(void)
99622 spin_lock_init(&avc_cache.slots_lock[i]);
99623 }
99624 atomic_set(&avc_cache.active_nodes, 0);
99625 - atomic_set(&avc_cache.lru_hint, 0);
99626 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99627
99628 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99629 0, SLAB_PANIC, NULL);
99630 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99631 spinlock_t *lock;
99632
99633 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99634 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99635 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99636 head = &avc_cache.slots[hvalue];
99637 lock = &avc_cache.slots_lock[hvalue];
99638
99639 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99640 index 5b52310..da3bf8e 100644
99641 --- a/security/selinux/hooks.c
99642 +++ b/security/selinux/hooks.c
99643 @@ -5603,7 +5603,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99644
99645 #endif
99646
99647 -static struct security_operations selinux_ops = {
99648 +static struct security_operations selinux_ops __read_only = {
99649 .name = "selinux",
99650
99651 .ptrace_access_check = selinux_ptrace_access_check,
99652 @@ -5955,6 +5955,9 @@ static void selinux_nf_ip_exit(void)
99653 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99654 static int selinux_disabled;
99655
99656 +extern struct security_operations *security_ops;
99657 +extern struct security_operations default_security_ops;
99658 +
99659 int selinux_disable(void)
99660 {
99661 if (ss_initialized) {
99662 @@ -5972,7 +5975,9 @@ int selinux_disable(void)
99663 selinux_disabled = 1;
99664 selinux_enabled = 0;
99665
99666 - reset_security_ops();
99667 + pax_open_kernel();
99668 + security_ops = &default_security_ops;
99669 + pax_close_kernel();
99670
99671 /* Try to destroy the avc node cache */
99672 avc_disable();
99673 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99674 index 6713f04..c57ecef 100644
99675 --- a/security/selinux/include/xfrm.h
99676 +++ b/security/selinux/include/xfrm.h
99677 @@ -52,7 +52,7 @@ static inline void selinux_xfrm_notify_policyload(void)
99678 {
99679 struct net *net;
99680
99681 - atomic_inc(&flow_cache_genid);
99682 + atomic_inc_unchecked(&flow_cache_genid);
99683 rtnl_lock();
99684 for_each_net(net)
99685 rt_genid_bump_all(net);
99686 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99687 index 8825375..97a623b 100644
99688 --- a/security/smack/smack_lsm.c
99689 +++ b/security/smack/smack_lsm.c
99690 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99691 return 0;
99692 }
99693
99694 -struct security_operations smack_ops = {
99695 +struct security_operations smack_ops __read_only = {
99696 .name = "smack",
99697
99698 .ptrace_access_check = smack_ptrace_access_check,
99699 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99700 index 390c646..f2f8db3 100644
99701 --- a/security/tomoyo/mount.c
99702 +++ b/security/tomoyo/mount.c
99703 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99704 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99705 need_dev = -1; /* dev_name is a directory */
99706 } else {
99707 + if (!capable(CAP_SYS_ADMIN)) {
99708 + error = -EPERM;
99709 + goto out;
99710 + }
99711 fstype = get_fs_type(type);
99712 if (!fstype) {
99713 error = -ENODEV;
99714 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99715 index f0b756e..b129202 100644
99716 --- a/security/tomoyo/tomoyo.c
99717 +++ b/security/tomoyo/tomoyo.c
99718 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99719 * tomoyo_security_ops is a "struct security_operations" which is used for
99720 * registering TOMOYO.
99721 */
99722 -static struct security_operations tomoyo_security_ops = {
99723 +static struct security_operations tomoyo_security_ops __read_only = {
99724 .name = "tomoyo",
99725 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99726 .cred_prepare = tomoyo_cred_prepare,
99727 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99728 index 20ef514..4182bed 100644
99729 --- a/security/yama/Kconfig
99730 +++ b/security/yama/Kconfig
99731 @@ -1,6 +1,6 @@
99732 config SECURITY_YAMA
99733 bool "Yama support"
99734 - depends on SECURITY
99735 + depends on SECURITY && !GRKERNSEC
99736 select SECURITYFS
99737 select SECURITY_PATH
99738 default n
99739 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99740 index 13c88fbc..f8c115e 100644
99741 --- a/security/yama/yama_lsm.c
99742 +++ b/security/yama/yama_lsm.c
99743 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99744 }
99745
99746 #ifndef CONFIG_SECURITY_YAMA_STACKED
99747 -static struct security_operations yama_ops = {
99748 +static struct security_operations yama_ops __read_only = {
99749 .name = "yama",
99750
99751 .ptrace_access_check = yama_ptrace_access_check,
99752 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99753 #endif
99754
99755 #ifdef CONFIG_SYSCTL
99756 +static int zero __read_only;
99757 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99758 +
99759 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99760 void __user *buffer, size_t *lenp, loff_t *ppos)
99761 {
99762 - int rc;
99763 + ctl_table_no_const yama_table;
99764
99765 if (write && !capable(CAP_SYS_PTRACE))
99766 return -EPERM;
99767
99768 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99769 - if (rc)
99770 - return rc;
99771 -
99772 + yama_table = *table;
99773 /* Lock the max value if it ever gets set. */
99774 - if (write && *(int *)table->data == *(int *)table->extra2)
99775 - table->extra1 = table->extra2;
99776 -
99777 - return rc;
99778 + if (ptrace_scope == max_scope)
99779 + yama_table.extra1 = &max_scope;
99780 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99781 }
99782
99783 -static int zero;
99784 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99785 -
99786 struct ctl_path yama_sysctl_path[] = {
99787 { .procname = "kernel", },
99788 { .procname = "yama", },
99789 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99790 index 4cedc69..e59d8a3 100644
99791 --- a/sound/aoa/codecs/onyx.c
99792 +++ b/sound/aoa/codecs/onyx.c
99793 @@ -54,7 +54,7 @@ struct onyx {
99794 spdif_locked:1,
99795 analog_locked:1,
99796 original_mute:2;
99797 - int open_count;
99798 + local_t open_count;
99799 struct codec_info *codec_info;
99800
99801 /* mutex serializes concurrent access to the device
99802 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99803 struct onyx *onyx = cii->codec_data;
99804
99805 mutex_lock(&onyx->mutex);
99806 - onyx->open_count++;
99807 + local_inc(&onyx->open_count);
99808 mutex_unlock(&onyx->mutex);
99809
99810 return 0;
99811 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99812 struct onyx *onyx = cii->codec_data;
99813
99814 mutex_lock(&onyx->mutex);
99815 - onyx->open_count--;
99816 - if (!onyx->open_count)
99817 + if (local_dec_and_test(&onyx->open_count))
99818 onyx->spdif_locked = onyx->analog_locked = 0;
99819 mutex_unlock(&onyx->mutex);
99820
99821 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99822 index ffd2025..df062c9 100644
99823 --- a/sound/aoa/codecs/onyx.h
99824 +++ b/sound/aoa/codecs/onyx.h
99825 @@ -11,6 +11,7 @@
99826 #include <linux/i2c.h>
99827 #include <asm/pmac_low_i2c.h>
99828 #include <asm/prom.h>
99829 +#include <asm/local.h>
99830
99831 /* PCM3052 register definitions */
99832
99833 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99834 index 4c1cc51..16040040 100644
99835 --- a/sound/core/oss/pcm_oss.c
99836 +++ b/sound/core/oss/pcm_oss.c
99837 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99838 if (in_kernel) {
99839 mm_segment_t fs;
99840 fs = snd_enter_user();
99841 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99842 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99843 snd_leave_user(fs);
99844 } else {
99845 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99846 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99847 }
99848 if (ret != -EPIPE && ret != -ESTRPIPE)
99849 break;
99850 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99851 if (in_kernel) {
99852 mm_segment_t fs;
99853 fs = snd_enter_user();
99854 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99855 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99856 snd_leave_user(fs);
99857 } else {
99858 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99859 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99860 }
99861 if (ret == -EPIPE) {
99862 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99863 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99864 struct snd_pcm_plugin_channel *channels;
99865 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99866 if (!in_kernel) {
99867 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99868 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99869 return -EFAULT;
99870 buf = runtime->oss.buffer;
99871 }
99872 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99873 }
99874 } else {
99875 tmp = snd_pcm_oss_write2(substream,
99876 - (const char __force *)buf,
99877 + (const char __force_kernel *)buf,
99878 runtime->oss.period_bytes, 0);
99879 if (tmp <= 0)
99880 goto err;
99881 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99882 struct snd_pcm_runtime *runtime = substream->runtime;
99883 snd_pcm_sframes_t frames, frames1;
99884 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99885 - char __user *final_dst = (char __force __user *)buf;
99886 + char __user *final_dst = (char __force_user *)buf;
99887 if (runtime->oss.plugin_first) {
99888 struct snd_pcm_plugin_channel *channels;
99889 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99890 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99891 xfer += tmp;
99892 runtime->oss.buffer_used -= tmp;
99893 } else {
99894 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99895 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99896 runtime->oss.period_bytes, 0);
99897 if (tmp <= 0)
99898 goto err;
99899 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99900 size1);
99901 size1 /= runtime->channels; /* frames */
99902 fs = snd_enter_user();
99903 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99904 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99905 snd_leave_user(fs);
99906 }
99907 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99908 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99909 index af49721..e85058e 100644
99910 --- a/sound/core/pcm_compat.c
99911 +++ b/sound/core/pcm_compat.c
99912 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99913 int err;
99914
99915 fs = snd_enter_user();
99916 - err = snd_pcm_delay(substream, &delay);
99917 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99918 snd_leave_user(fs);
99919 if (err < 0)
99920 return err;
99921 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99922 index a68d4c6..72af3cf 100644
99923 --- a/sound/core/pcm_native.c
99924 +++ b/sound/core/pcm_native.c
99925 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99926 switch (substream->stream) {
99927 case SNDRV_PCM_STREAM_PLAYBACK:
99928 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99929 - (void __user *)arg);
99930 + (void __force_user *)arg);
99931 break;
99932 case SNDRV_PCM_STREAM_CAPTURE:
99933 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99934 - (void __user *)arg);
99935 + (void __force_user *)arg);
99936 break;
99937 default:
99938 result = -EINVAL;
99939 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99940 index 040c60e..989a19a 100644
99941 --- a/sound/core/seq/seq_device.c
99942 +++ b/sound/core/seq/seq_device.c
99943 @@ -64,7 +64,7 @@ struct ops_list {
99944 int argsize; /* argument size */
99945
99946 /* operators */
99947 - struct snd_seq_dev_ops ops;
99948 + struct snd_seq_dev_ops *ops;
99949
99950 /* registered devices */
99951 struct list_head dev_list; /* list of devices */
99952 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99953
99954 mutex_lock(&ops->reg_mutex);
99955 /* copy driver operators */
99956 - ops->ops = *entry;
99957 + ops->ops = entry;
99958 ops->driver |= DRIVER_LOADED;
99959 ops->argsize = argsize;
99960
99961 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99962 dev->name, ops->id, ops->argsize, dev->argsize);
99963 return -EINVAL;
99964 }
99965 - if (ops->ops.init_device(dev) >= 0) {
99966 + if (ops->ops->init_device(dev) >= 0) {
99967 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99968 ops->num_init_devices++;
99969 } else {
99970 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99971 dev->name, ops->id, ops->argsize, dev->argsize);
99972 return -EINVAL;
99973 }
99974 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99975 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99976 dev->status = SNDRV_SEQ_DEVICE_FREE;
99977 dev->driver_data = NULL;
99978 ops->num_init_devices--;
99979 diff --git a/sound/core/sound.c b/sound/core/sound.c
99980 index f002bd9..c462985 100644
99981 --- a/sound/core/sound.c
99982 +++ b/sound/core/sound.c
99983 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99984 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99985 default: return;
99986 }
99987 - request_module(str);
99988 + request_module("%s", str);
99989 }
99990
99991 #endif /* modular kernel */
99992 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99993 index 4e0dd22..7a1f32c 100644
99994 --- a/sound/drivers/mts64.c
99995 +++ b/sound/drivers/mts64.c
99996 @@ -29,6 +29,7 @@
99997 #include <sound/initval.h>
99998 #include <sound/rawmidi.h>
99999 #include <sound/control.h>
100000 +#include <asm/local.h>
100001
100002 #define CARD_NAME "Miditerminal 4140"
100003 #define DRIVER_NAME "MTS64"
100004 @@ -67,7 +68,7 @@ struct mts64 {
100005 struct pardevice *pardev;
100006 int pardev_claimed;
100007
100008 - int open_count;
100009 + local_t open_count;
100010 int current_midi_output_port;
100011 int current_midi_input_port;
100012 u8 mode[MTS64_NUM_INPUT_PORTS];
100013 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100014 {
100015 struct mts64 *mts = substream->rmidi->private_data;
100016
100017 - if (mts->open_count == 0) {
100018 + if (local_read(&mts->open_count) == 0) {
100019 /* We don't need a spinlock here, because this is just called
100020 if the device has not been opened before.
100021 So there aren't any IRQs from the device */
100022 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100023
100024 msleep(50);
100025 }
100026 - ++(mts->open_count);
100027 + local_inc(&mts->open_count);
100028
100029 return 0;
100030 }
100031 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100032 struct mts64 *mts = substream->rmidi->private_data;
100033 unsigned long flags;
100034
100035 - --(mts->open_count);
100036 - if (mts->open_count == 0) {
100037 + if (local_dec_return(&mts->open_count) == 0) {
100038 /* We need the spinlock_irqsave here because we can still
100039 have IRQs at this point */
100040 spin_lock_irqsave(&mts->lock, flags);
100041 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100042
100043 msleep(500);
100044
100045 - } else if (mts->open_count < 0)
100046 - mts->open_count = 0;
100047 + } else if (local_read(&mts->open_count) < 0)
100048 + local_set(&mts->open_count, 0);
100049
100050 return 0;
100051 }
100052 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
100053 index b953fb4..1999c01 100644
100054 --- a/sound/drivers/opl4/opl4_lib.c
100055 +++ b/sound/drivers/opl4/opl4_lib.c
100056 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
100057 MODULE_DESCRIPTION("OPL4 driver");
100058 MODULE_LICENSE("GPL");
100059
100060 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
100061 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
100062 {
100063 int timeout = 10;
100064 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
100065 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
100066 index 991018d..8984740 100644
100067 --- a/sound/drivers/portman2x4.c
100068 +++ b/sound/drivers/portman2x4.c
100069 @@ -48,6 +48,7 @@
100070 #include <sound/initval.h>
100071 #include <sound/rawmidi.h>
100072 #include <sound/control.h>
100073 +#include <asm/local.h>
100074
100075 #define CARD_NAME "Portman 2x4"
100076 #define DRIVER_NAME "portman"
100077 @@ -85,7 +86,7 @@ struct portman {
100078 struct pardevice *pardev;
100079 int pardev_claimed;
100080
100081 - int open_count;
100082 + local_t open_count;
100083 int mode[PORTMAN_NUM_INPUT_PORTS];
100084 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
100085 };
100086 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
100087 index ea995af..f1bfa37 100644
100088 --- a/sound/firewire/amdtp.c
100089 +++ b/sound/firewire/amdtp.c
100090 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
100091 ptr = s->pcm_buffer_pointer + data_blocks;
100092 if (ptr >= pcm->runtime->buffer_size)
100093 ptr -= pcm->runtime->buffer_size;
100094 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
100095 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
100096
100097 s->pcm_period_pointer += data_blocks;
100098 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
100099 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
100100 */
100101 void amdtp_out_stream_update(struct amdtp_out_stream *s)
100102 {
100103 - ACCESS_ONCE(s->source_node_id_field) =
100104 + ACCESS_ONCE_RW(s->source_node_id_field) =
100105 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
100106 }
100107 EXPORT_SYMBOL(amdtp_out_stream_update);
100108 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
100109 index f6103d6..4843fbf 100644
100110 --- a/sound/firewire/amdtp.h
100111 +++ b/sound/firewire/amdtp.h
100112 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
100113 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
100114 struct snd_pcm_substream *pcm)
100115 {
100116 - ACCESS_ONCE(s->pcm) = pcm;
100117 + ACCESS_ONCE_RW(s->pcm) = pcm;
100118 }
100119
100120 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
100121 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
100122 index 58a5afe..af5bd64 100644
100123 --- a/sound/firewire/isight.c
100124 +++ b/sound/firewire/isight.c
100125 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
100126 ptr += count;
100127 if (ptr >= runtime->buffer_size)
100128 ptr -= runtime->buffer_size;
100129 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
100130 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
100131
100132 isight->period_counter += count;
100133 if (isight->period_counter >= runtime->period_size) {
100134 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
100135 if (err < 0)
100136 return err;
100137
100138 - ACCESS_ONCE(isight->pcm_active) = true;
100139 + ACCESS_ONCE_RW(isight->pcm_active) = true;
100140
100141 return 0;
100142 }
100143 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
100144 {
100145 struct isight *isight = substream->private_data;
100146
100147 - ACCESS_ONCE(isight->pcm_active) = false;
100148 + ACCESS_ONCE_RW(isight->pcm_active) = false;
100149
100150 mutex_lock(&isight->mutex);
100151 isight_stop_streaming(isight);
100152 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
100153
100154 switch (cmd) {
100155 case SNDRV_PCM_TRIGGER_START:
100156 - ACCESS_ONCE(isight->pcm_running) = true;
100157 + ACCESS_ONCE_RW(isight->pcm_running) = true;
100158 break;
100159 case SNDRV_PCM_TRIGGER_STOP:
100160 - ACCESS_ONCE(isight->pcm_running) = false;
100161 + ACCESS_ONCE_RW(isight->pcm_running) = false;
100162 break;
100163 default:
100164 return -EINVAL;
100165 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
100166 index 505fc81..62e569e 100644
100167 --- a/sound/firewire/scs1x.c
100168 +++ b/sound/firewire/scs1x.c
100169 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
100170 {
100171 struct scs *scs = stream->rmidi->private_data;
100172
100173 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
100174 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
100175 if (up) {
100176 scs->output_idle = false;
100177 tasklet_schedule(&scs->tasklet);
100178 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
100179 {
100180 struct scs *scs = stream->rmidi->private_data;
100181
100182 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
100183 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
100184 }
100185
100186 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
100187 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
100188
100189 snd_card_disconnect(scs->card);
100190
100191 - ACCESS_ONCE(scs->output) = NULL;
100192 - ACCESS_ONCE(scs->input) = NULL;
100193 + ACCESS_ONCE_RW(scs->output) = NULL;
100194 + ACCESS_ONCE_RW(scs->input) = NULL;
100195
100196 wait_event(scs->idle_wait, scs->output_idle);
100197
100198 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
100199 index 048439a..3be9f6f 100644
100200 --- a/sound/oss/sb_audio.c
100201 +++ b/sound/oss/sb_audio.c
100202 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
100203 buf16 = (signed short *)(localbuf + localoffs);
100204 while (c)
100205 {
100206 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100207 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100208 if (copy_from_user(lbuf8,
100209 userbuf+useroffs + p,
100210 locallen))
100211 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
100212 index 7d8803a..559f8d0 100644
100213 --- a/sound/oss/swarm_cs4297a.c
100214 +++ b/sound/oss/swarm_cs4297a.c
100215 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
100216 {
100217 struct cs4297a_state *s;
100218 u32 pwr, id;
100219 - mm_segment_t fs;
100220 int rval;
100221 #ifndef CONFIG_BCM_CS4297A_CSWARM
100222 u64 cfg;
100223 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
100224 if (!rval) {
100225 char *sb1250_duart_present;
100226
100227 +#if 0
100228 + mm_segment_t fs;
100229 fs = get_fs();
100230 set_fs(KERNEL_DS);
100231 -#if 0
100232 val = SOUND_MASK_LINE;
100233 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
100234 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
100235 val = initvol[i].vol;
100236 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
100237 }
100238 + set_fs(fs);
100239 // cs4297a_write_ac97(s, 0x18, 0x0808);
100240 #else
100241 // cs4297a_write_ac97(s, 0x5e, 0x180);
100242 cs4297a_write_ac97(s, 0x02, 0x0808);
100243 cs4297a_write_ac97(s, 0x18, 0x0808);
100244 #endif
100245 - set_fs(fs);
100246
100247 list_add(&s->list, &cs4297a_devs);
100248
100249 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
100250 index 748c6a9..a27725a 100644
100251 --- a/sound/pci/hda/hda_codec.c
100252 +++ b/sound/pci/hda/hda_codec.c
100253 @@ -976,14 +976,10 @@ find_codec_preset(struct hda_codec *codec)
100254 mutex_unlock(&preset_mutex);
100255
100256 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
100257 - char name[32];
100258 if (!mod_requested)
100259 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
100260 - codec->vendor_id);
100261 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
100262 else
100263 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
100264 - (codec->vendor_id >> 16) & 0xffff);
100265 - request_module(name);
100266 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
100267 mod_requested++;
100268 goto again;
100269 }
100270 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
100271 index 4631a23..001ae57 100644
100272 --- a/sound/pci/ymfpci/ymfpci.h
100273 +++ b/sound/pci/ymfpci/ymfpci.h
100274 @@ -358,7 +358,7 @@ struct snd_ymfpci {
100275 spinlock_t reg_lock;
100276 spinlock_t voice_lock;
100277 wait_queue_head_t interrupt_sleep;
100278 - atomic_t interrupt_sleep_count;
100279 + atomic_unchecked_t interrupt_sleep_count;
100280 struct snd_info_entry *proc_entry;
100281 const struct firmware *dsp_microcode;
100282 const struct firmware *controller_microcode;
100283 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
100284 index d591c15..8cb8f94 100644
100285 --- a/sound/pci/ymfpci/ymfpci_main.c
100286 +++ b/sound/pci/ymfpci/ymfpci_main.c
100287 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
100288 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
100289 break;
100290 }
100291 - if (atomic_read(&chip->interrupt_sleep_count)) {
100292 - atomic_set(&chip->interrupt_sleep_count, 0);
100293 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100294 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100295 wake_up(&chip->interrupt_sleep);
100296 }
100297 __end:
100298 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
100299 continue;
100300 init_waitqueue_entry(&wait, current);
100301 add_wait_queue(&chip->interrupt_sleep, &wait);
100302 - atomic_inc(&chip->interrupt_sleep_count);
100303 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
100304 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
100305 remove_wait_queue(&chip->interrupt_sleep, &wait);
100306 }
100307 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
100308 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
100309 spin_unlock(&chip->reg_lock);
100310
100311 - if (atomic_read(&chip->interrupt_sleep_count)) {
100312 - atomic_set(&chip->interrupt_sleep_count, 0);
100313 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100314 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100315 wake_up(&chip->interrupt_sleep);
100316 }
100317 }
100318 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
100319 spin_lock_init(&chip->reg_lock);
100320 spin_lock_init(&chip->voice_lock);
100321 init_waitqueue_head(&chip->interrupt_sleep);
100322 - atomic_set(&chip->interrupt_sleep_count, 0);
100323 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100324 chip->card = card;
100325 chip->pci = pci;
100326 chip->irq = -1;
100327 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
100328 index 6b81d0c..031c056 100644
100329 --- a/sound/soc/fsl/fsl_ssi.c
100330 +++ b/sound/soc/fsl/fsl_ssi.c
100331 @@ -864,7 +864,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
100332 {
100333 struct fsl_ssi_private *ssi_private;
100334 int ret = 0;
100335 - struct device_attribute *dev_attr = NULL;
100336 + device_attribute_no_const *dev_attr = NULL;
100337 struct device_node *np = pdev->dev.of_node;
100338 const char *p, *sprop;
100339 const uint32_t *iprop;
100340 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
100341 index 1a38be0..66809d1 100644
100342 --- a/sound/soc/soc-core.c
100343 +++ b/sound/soc/soc-core.c
100344 @@ -2248,8 +2248,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
100345 if (ret)
100346 return ret;
100347
100348 - ops->warm_reset = snd_soc_ac97_warm_reset;
100349 - ops->reset = snd_soc_ac97_reset;
100350 + pax_open_kernel();
100351 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
100352 + *(void **)&ops->reset = snd_soc_ac97_reset;
100353 + pax_close_kernel();
100354
100355 snd_ac97_rst_cfg = cfg;
100356 return 0;
100357 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
100358 new file mode 100644
100359 index 0000000..50f2f2f
100360 --- /dev/null
100361 +++ b/tools/gcc/.gitignore
100362 @@ -0,0 +1 @@
100363 +size_overflow_hash.h
100364 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
100365 new file mode 100644
100366 index 0000000..144dbee
100367 --- /dev/null
100368 +++ b/tools/gcc/Makefile
100369 @@ -0,0 +1,45 @@
100370 +#CC := gcc
100371 +#PLUGIN_SOURCE_FILES := pax_plugin.c
100372 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
100373 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
100374 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
100375 +
100376 +ifeq ($(PLUGINCC),$(HOSTCC))
100377 +HOSTLIBS := hostlibs
100378 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
100379 +else
100380 +HOSTLIBS := hostcxxlibs
100381 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
100382 +endif
100383 +
100384 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
100385 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
100386 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
100387 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
100388 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
100389 +$(HOSTLIBS)-y += colorize_plugin.so
100390 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
100391 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
100392 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
100393 +
100394 +always := $($(HOSTLIBS)-y)
100395 +
100396 +constify_plugin-objs := constify_plugin.o
100397 +stackleak_plugin-objs := stackleak_plugin.o
100398 +kallocstat_plugin-objs := kallocstat_plugin.o
100399 +kernexec_plugin-objs := kernexec_plugin.o
100400 +checker_plugin-objs := checker_plugin.o
100401 +colorize_plugin-objs := colorize_plugin.o
100402 +size_overflow_plugin-objs := size_overflow_plugin.o
100403 +latent_entropy_plugin-objs := latent_entropy_plugin.o
100404 +structleak_plugin-objs := structleak_plugin.o
100405 +
100406 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
100407 +
100408 +quiet_cmd_build_size_overflow_hash = GENHASH $@
100409 + cmd_build_size_overflow_hash = \
100410 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
100411 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
100412 + $(call if_changed,build_size_overflow_hash)
100413 +
100414 +targets += size_overflow_hash.h
100415 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
100416 new file mode 100644
100417 index 0000000..22f03c0
100418 --- /dev/null
100419 +++ b/tools/gcc/checker_plugin.c
100420 @@ -0,0 +1,172 @@
100421 +/*
100422 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
100423 + * Licensed under the GPL v2
100424 + *
100425 + * Note: the choice of the license means that the compilation process is
100426 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100427 + * but for the kernel it doesn't matter since it doesn't link against
100428 + * any of the gcc libraries
100429 + *
100430 + * gcc plugin to implement various sparse (source code checker) features
100431 + *
100432 + * TODO:
100433 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
100434 + *
100435 + * BUGS:
100436 + * - none known
100437 + */
100438 +#include "gcc-plugin.h"
100439 +#include "config.h"
100440 +#include "system.h"
100441 +#include "coretypes.h"
100442 +#include "tree.h"
100443 +#include "tree-pass.h"
100444 +#include "flags.h"
100445 +#include "intl.h"
100446 +#include "toplev.h"
100447 +#include "plugin.h"
100448 +//#include "expr.h" where are you...
100449 +#include "diagnostic.h"
100450 +#include "plugin-version.h"
100451 +#include "tm.h"
100452 +#include "function.h"
100453 +#include "basic-block.h"
100454 +#include "gimple.h"
100455 +#include "rtl.h"
100456 +#include "emit-rtl.h"
100457 +#include "tree-flow.h"
100458 +#include "target.h"
100459 +
100460 +extern void c_register_addr_space (const char *str, addr_space_t as);
100461 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
100462 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
100463 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
100464 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
100465 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
100466 +
100467 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100468 +extern rtx emit_move_insn(rtx x, rtx y);
100469 +
100470 +int plugin_is_GPL_compatible;
100471 +
100472 +static struct plugin_info checker_plugin_info = {
100473 + .version = "201111150100",
100474 + .help = NULL,
100475 +};
100476 +
100477 +#define ADDR_SPACE_KERNEL 0
100478 +#define ADDR_SPACE_FORCE_KERNEL 1
100479 +#define ADDR_SPACE_USER 2
100480 +#define ADDR_SPACE_FORCE_USER 3
100481 +#define ADDR_SPACE_IOMEM 0
100482 +#define ADDR_SPACE_FORCE_IOMEM 0
100483 +#define ADDR_SPACE_PERCPU 0
100484 +#define ADDR_SPACE_FORCE_PERCPU 0
100485 +#define ADDR_SPACE_RCU 0
100486 +#define ADDR_SPACE_FORCE_RCU 0
100487 +
100488 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
100489 +{
100490 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
100491 +}
100492 +
100493 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
100494 +{
100495 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
100496 +}
100497 +
100498 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
100499 +{
100500 + return default_addr_space_valid_pointer_mode(mode, as);
100501 +}
100502 +
100503 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
100504 +{
100505 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
100506 +}
100507 +
100508 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
100509 +{
100510 + return default_addr_space_legitimize_address(x, oldx, mode, as);
100511 +}
100512 +
100513 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
100514 +{
100515 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
100516 + return true;
100517 +
100518 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
100519 + return true;
100520 +
100521 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
100522 + return true;
100523 +
100524 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
100525 + return true;
100526 +
100527 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
100528 + return true;
100529 +
100530 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
100531 + return true;
100532 +
100533 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
100534 + return true;
100535 +
100536 + return subset == superset;
100537 +}
100538 +
100539 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100540 +{
100541 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100542 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100543 +
100544 + return op;
100545 +}
100546 +
100547 +static void register_checker_address_spaces(void *event_data, void *data)
100548 +{
100549 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100550 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100551 + c_register_addr_space("__user", ADDR_SPACE_USER);
100552 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100553 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100554 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100555 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100556 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100557 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100558 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100559 +
100560 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100561 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100562 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100563 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100564 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100565 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100566 + targetm.addr_space.convert = checker_addr_space_convert;
100567 +}
100568 +
100569 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100570 +{
100571 + const char * const plugin_name = plugin_info->base_name;
100572 + const int argc = plugin_info->argc;
100573 + const struct plugin_argument * const argv = plugin_info->argv;
100574 + int i;
100575 +
100576 + if (!plugin_default_version_check(version, &gcc_version)) {
100577 + error(G_("incompatible gcc/plugin versions"));
100578 + return 1;
100579 + }
100580 +
100581 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100582 +
100583 + for (i = 0; i < argc; ++i)
100584 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100585 +
100586 + if (TARGET_64BIT == 0)
100587 + return 0;
100588 +
100589 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100590 +
100591 + return 0;
100592 +}
100593 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100594 new file mode 100644
100595 index 0000000..414fe5e
100596 --- /dev/null
100597 +++ b/tools/gcc/colorize_plugin.c
100598 @@ -0,0 +1,151 @@
100599 +/*
100600 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100601 + * Licensed under the GPL v2
100602 + *
100603 + * Note: the choice of the license means that the compilation process is
100604 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100605 + * but for the kernel it doesn't matter since it doesn't link against
100606 + * any of the gcc libraries
100607 + *
100608 + * gcc plugin to colorize diagnostic output
100609 + *
100610 + */
100611 +
100612 +#include "gcc-plugin.h"
100613 +#include "config.h"
100614 +#include "system.h"
100615 +#include "coretypes.h"
100616 +#include "tree.h"
100617 +#include "tree-pass.h"
100618 +#include "flags.h"
100619 +#include "intl.h"
100620 +#include "toplev.h"
100621 +#include "plugin.h"
100622 +#include "diagnostic.h"
100623 +#include "plugin-version.h"
100624 +#include "tm.h"
100625 +
100626 +int plugin_is_GPL_compatible;
100627 +
100628 +static struct plugin_info colorize_plugin_info = {
100629 + .version = "201302112000",
100630 + .help = NULL,
100631 +};
100632 +
100633 +#define GREEN "\033[32m\033[2m"
100634 +#define LIGHTGREEN "\033[32m\033[1m"
100635 +#define YELLOW "\033[33m\033[2m"
100636 +#define LIGHTYELLOW "\033[33m\033[1m"
100637 +#define RED "\033[31m\033[2m"
100638 +#define LIGHTRED "\033[31m\033[1m"
100639 +#define BLUE "\033[34m\033[2m"
100640 +#define LIGHTBLUE "\033[34m\033[1m"
100641 +#define BRIGHT "\033[m\033[1m"
100642 +#define NORMAL "\033[m"
100643 +
100644 +static diagnostic_starter_fn old_starter;
100645 +static diagnostic_finalizer_fn old_finalizer;
100646 +
100647 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100648 +{
100649 + const char *color;
100650 + char *newprefix;
100651 +
100652 + switch (diagnostic->kind) {
100653 + case DK_NOTE:
100654 + color = LIGHTBLUE;
100655 + break;
100656 +
100657 + case DK_PEDWARN:
100658 + case DK_WARNING:
100659 + color = LIGHTYELLOW;
100660 + break;
100661 +
100662 + case DK_ERROR:
100663 + case DK_FATAL:
100664 + case DK_ICE:
100665 + case DK_PERMERROR:
100666 + case DK_SORRY:
100667 + color = LIGHTRED;
100668 + break;
100669 +
100670 + default:
100671 + color = NORMAL;
100672 + }
100673 +
100674 + old_starter(context, diagnostic);
100675 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100676 + return;
100677 + pp_destroy_prefix(context->printer);
100678 + pp_set_prefix(context->printer, newprefix);
100679 +}
100680 +
100681 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100682 +{
100683 + old_finalizer(context, diagnostic);
100684 +}
100685 +
100686 +static void colorize_arm(void)
100687 +{
100688 + old_starter = diagnostic_starter(global_dc);
100689 + old_finalizer = diagnostic_finalizer(global_dc);
100690 +
100691 + diagnostic_starter(global_dc) = start_colorize;
100692 + diagnostic_finalizer(global_dc) = finalize_colorize;
100693 +}
100694 +
100695 +static unsigned int execute_colorize_rearm(void)
100696 +{
100697 + if (diagnostic_starter(global_dc) == start_colorize)
100698 + return 0;
100699 +
100700 + colorize_arm();
100701 + return 0;
100702 +}
100703 +
100704 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100705 + .pass = {
100706 + .type = SIMPLE_IPA_PASS,
100707 + .name = "colorize_rearm",
100708 +#if BUILDING_GCC_VERSION >= 4008
100709 + .optinfo_flags = OPTGROUP_NONE,
100710 +#endif
100711 + .gate = NULL,
100712 + .execute = execute_colorize_rearm,
100713 + .sub = NULL,
100714 + .next = NULL,
100715 + .static_pass_number = 0,
100716 + .tv_id = TV_NONE,
100717 + .properties_required = 0,
100718 + .properties_provided = 0,
100719 + .properties_destroyed = 0,
100720 + .todo_flags_start = 0,
100721 + .todo_flags_finish = 0
100722 + }
100723 +};
100724 +
100725 +static void colorize_start_unit(void *gcc_data, void *user_data)
100726 +{
100727 + colorize_arm();
100728 +}
100729 +
100730 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100731 +{
100732 + const char * const plugin_name = plugin_info->base_name;
100733 + struct register_pass_info colorize_rearm_pass_info = {
100734 + .pass = &pass_ipa_colorize_rearm.pass,
100735 + .reference_pass_name = "*free_lang_data",
100736 + .ref_pass_instance_number = 1,
100737 + .pos_op = PASS_POS_INSERT_AFTER
100738 + };
100739 +
100740 + if (!plugin_default_version_check(version, &gcc_version)) {
100741 + error(G_("incompatible gcc/plugin versions"));
100742 + return 1;
100743 + }
100744 +
100745 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100746 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100747 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100748 + return 0;
100749 +}
100750 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100751 new file mode 100644
100752 index 0000000..c17312d
100753 --- /dev/null
100754 +++ b/tools/gcc/constify_plugin.c
100755 @@ -0,0 +1,560 @@
100756 +/*
100757 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100758 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100759 + * Licensed under the GPL v2, or (at your option) v3
100760 + *
100761 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100762 + *
100763 + * Homepage:
100764 + * http://www.grsecurity.net/~ephox/const_plugin/
100765 + *
100766 + * Usage:
100767 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100768 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100769 + */
100770 +
100771 +#include "gcc-plugin.h"
100772 +#include "config.h"
100773 +#include "system.h"
100774 +#include "coretypes.h"
100775 +#include "tree.h"
100776 +#include "tree-pass.h"
100777 +#include "flags.h"
100778 +#include "intl.h"
100779 +#include "toplev.h"
100780 +#include "plugin.h"
100781 +#include "diagnostic.h"
100782 +#include "plugin-version.h"
100783 +#include "tm.h"
100784 +#include "function.h"
100785 +#include "basic-block.h"
100786 +#include "gimple.h"
100787 +#include "rtl.h"
100788 +#include "emit-rtl.h"
100789 +#include "tree-flow.h"
100790 +#include "target.h"
100791 +#include "langhooks.h"
100792 +
100793 +// should come from c-tree.h if only it were installed for gcc 4.5...
100794 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100795 +
100796 +// unused type flag in all versions 4.5-4.8
100797 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100798 +
100799 +int plugin_is_GPL_compatible;
100800 +
100801 +static struct plugin_info const_plugin_info = {
100802 + .version = "201305231310",
100803 + .help = "no-constify\tturn off constification\n",
100804 +};
100805 +
100806 +typedef struct {
100807 + bool has_fptr_field;
100808 + bool has_writable_field;
100809 + bool has_do_const_field;
100810 + bool has_no_const_field;
100811 +} constify_info;
100812 +
100813 +static const_tree get_field_type(const_tree field)
100814 +{
100815 + return strip_array_types(TREE_TYPE(field));
100816 +}
100817 +
100818 +static bool is_fptr(const_tree field)
100819 +{
100820 + const_tree ptr = get_field_type(field);
100821 +
100822 + if (TREE_CODE(ptr) != POINTER_TYPE)
100823 + return false;
100824 +
100825 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100826 +}
100827 +
100828 +/*
100829 + * determine whether the given structure type meets the requirements for automatic constification,
100830 + * including the constification attributes on nested structure types
100831 + */
100832 +static void constifiable(const_tree node, constify_info *cinfo)
100833 +{
100834 + const_tree field;
100835 +
100836 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100837 +
100838 + // e.g., pointer to structure fields while still constructing the structure type
100839 + if (TYPE_FIELDS(node) == NULL_TREE)
100840 + return;
100841 +
100842 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100843 + const_tree type = get_field_type(field);
100844 + enum tree_code code = TREE_CODE(type);
100845 +
100846 + if (node == type)
100847 + continue;
100848 +
100849 + if (is_fptr(field))
100850 + cinfo->has_fptr_field = true;
100851 + else if (!TREE_READONLY(field))
100852 + cinfo->has_writable_field = true;
100853 +
100854 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100855 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100856 + cinfo->has_do_const_field = true;
100857 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100858 + cinfo->has_no_const_field = true;
100859 + else
100860 + constifiable(type, cinfo);
100861 + }
100862 + }
100863 +}
100864 +
100865 +static bool constified(const_tree node)
100866 +{
100867 + constify_info cinfo = {
100868 + .has_fptr_field = false,
100869 + .has_writable_field = false,
100870 + .has_do_const_field = false,
100871 + .has_no_const_field = false
100872 + };
100873 +
100874 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100875 +
100876 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100877 + gcc_assert(!TYPE_READONLY(node));
100878 + return false;
100879 + }
100880 +
100881 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100882 + gcc_assert(TYPE_READONLY(node));
100883 + return true;
100884 + }
100885 +
100886 + constifiable(node, &cinfo);
100887 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100888 + return false;
100889 +
100890 + return TYPE_READONLY(node);
100891 +}
100892 +
100893 +static void deconstify_tree(tree node);
100894 +
100895 +static void deconstify_type(tree type)
100896 +{
100897 + tree field;
100898 +
100899 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100900 +
100901 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100902 + const_tree fieldtype = get_field_type(field);
100903 +
100904 + // special case handling of simple ptr-to-same-array-type members
100905 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100906 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100907 +
100908 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100909 + continue;
100910 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100911 + continue;
100912 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100913 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100914 + TREE_TYPE(TREE_TYPE(field)) = type;
100915 + }
100916 + continue;
100917 + }
100918 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100919 + continue;
100920 + if (!constified(fieldtype))
100921 + continue;
100922 +
100923 + deconstify_tree(field);
100924 + TREE_READONLY(field) = 0;
100925 + }
100926 + TYPE_READONLY(type) = 0;
100927 + C_TYPE_FIELDS_READONLY(type) = 0;
100928 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100929 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100930 +}
100931 +
100932 +static void deconstify_tree(tree node)
100933 +{
100934 + tree old_type, new_type, field;
100935 +
100936 + old_type = TREE_TYPE(node);
100937 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100938 + node = TREE_TYPE(node) = copy_node(old_type);
100939 + old_type = TREE_TYPE(old_type);
100940 + }
100941 +
100942 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100943 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100944 +
100945 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100946 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100947 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100948 + DECL_FIELD_CONTEXT(field) = new_type;
100949 +
100950 + deconstify_type(new_type);
100951 +
100952 + TREE_TYPE(node) = new_type;
100953 +}
100954 +
100955 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100956 +{
100957 + tree type;
100958 + constify_info cinfo = {
100959 + .has_fptr_field = false,
100960 + .has_writable_field = false,
100961 + .has_do_const_field = false,
100962 + .has_no_const_field = false
100963 + };
100964 +
100965 + *no_add_attrs = true;
100966 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100967 + error("%qE attribute does not apply to functions", name);
100968 + return NULL_TREE;
100969 + }
100970 +
100971 + if (TREE_CODE(*node) == PARM_DECL) {
100972 + error("%qE attribute does not apply to function parameters", name);
100973 + return NULL_TREE;
100974 + }
100975 +
100976 + if (TREE_CODE(*node) == VAR_DECL) {
100977 + error("%qE attribute does not apply to variables", name);
100978 + return NULL_TREE;
100979 + }
100980 +
100981 + if (TYPE_P(*node)) {
100982 + *no_add_attrs = false;
100983 + type = *node;
100984 + } else {
100985 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100986 + type = TREE_TYPE(*node);
100987 + }
100988 +
100989 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100990 + error("%qE attribute applies to struct and union types only", name);
100991 + return NULL_TREE;
100992 + }
100993 +
100994 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100995 + error("%qE attribute is already applied to the type", name);
100996 + return NULL_TREE;
100997 + }
100998 +
100999 + if (TYPE_P(*node)) {
101000 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101001 + error("%qE attribute is incompatible with 'do_const'", name);
101002 + return NULL_TREE;
101003 + }
101004 +
101005 + constifiable(type, &cinfo);
101006 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101007 + deconstify_tree(*node);
101008 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
101009 + return NULL_TREE;
101010 + }
101011 +
101012 + error("%qE attribute used on type that is not constified", name);
101013 + return NULL_TREE;
101014 +}
101015 +
101016 +static void constify_type(tree type)
101017 +{
101018 + TYPE_READONLY(type) = 1;
101019 + C_TYPE_FIELDS_READONLY(type) = 1;
101020 + TYPE_CONSTIFY_VISITED(type) = 1;
101021 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
101022 +}
101023 +
101024 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101025 +{
101026 + *no_add_attrs = true;
101027 + if (!TYPE_P(*node)) {
101028 + error("%qE attribute applies to types only", name);
101029 + return NULL_TREE;
101030 + }
101031 +
101032 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
101033 + error("%qE attribute applies to struct and union types only", name);
101034 + return NULL_TREE;
101035 + }
101036 +
101037 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
101038 + error("%qE attribute is already applied to the type", name);
101039 + return NULL_TREE;
101040 + }
101041 +
101042 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
101043 + error("%qE attribute is incompatible with 'no_const'", name);
101044 + return NULL_TREE;
101045 + }
101046 +
101047 + *no_add_attrs = false;
101048 + return NULL_TREE;
101049 +}
101050 +
101051 +static struct attribute_spec no_const_attr = {
101052 + .name = "no_const",
101053 + .min_length = 0,
101054 + .max_length = 0,
101055 + .decl_required = false,
101056 + .type_required = false,
101057 + .function_type_required = false,
101058 + .handler = handle_no_const_attribute,
101059 +#if BUILDING_GCC_VERSION >= 4007
101060 + .affects_type_identity = true
101061 +#endif
101062 +};
101063 +
101064 +static struct attribute_spec do_const_attr = {
101065 + .name = "do_const",
101066 + .min_length = 0,
101067 + .max_length = 0,
101068 + .decl_required = false,
101069 + .type_required = false,
101070 + .function_type_required = false,
101071 + .handler = handle_do_const_attribute,
101072 +#if BUILDING_GCC_VERSION >= 4007
101073 + .affects_type_identity = true
101074 +#endif
101075 +};
101076 +
101077 +static void register_attributes(void *event_data, void *data)
101078 +{
101079 + register_attribute(&no_const_attr);
101080 + register_attribute(&do_const_attr);
101081 +}
101082 +
101083 +static void finish_type(void *event_data, void *data)
101084 +{
101085 + tree type = (tree)event_data;
101086 + constify_info cinfo = {
101087 + .has_fptr_field = false,
101088 + .has_writable_field = false,
101089 + .has_do_const_field = false,
101090 + .has_no_const_field = false
101091 + };
101092 +
101093 + if (type == NULL_TREE || type == error_mark_node)
101094 + return;
101095 +
101096 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
101097 + return;
101098 +
101099 + constifiable(type, &cinfo);
101100 +
101101 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
101102 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101103 + return;
101104 + if (cinfo.has_writable_field)
101105 + return;
101106 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
101107 + return;
101108 + }
101109 +
101110 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
101111 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
101112 + deconstify_type(type);
101113 + TYPE_CONSTIFY_VISITED(type) = 1;
101114 + } else
101115 + error("'no_const' attribute used on type that is not constified");
101116 + return;
101117 + }
101118 +
101119 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101120 + constify_type(type);
101121 + return;
101122 + }
101123 +
101124 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
101125 + constify_type(type);
101126 + return;
101127 + }
101128 +
101129 + deconstify_type(type);
101130 + TYPE_CONSTIFY_VISITED(type) = 1;
101131 +}
101132 +
101133 +static void check_global_variables(void)
101134 +{
101135 + struct varpool_node *node;
101136 +
101137 +#if BUILDING_GCC_VERSION <= 4007
101138 + for (node = varpool_nodes; node; node = node->next) {
101139 + tree var = node->decl;
101140 +#else
101141 + FOR_EACH_VARIABLE(node) {
101142 + tree var = node->symbol.decl;
101143 +#endif
101144 + tree type = TREE_TYPE(var);
101145 +
101146 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101147 + continue;
101148 +
101149 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101150 + continue;
101151 +
101152 + if (!TYPE_CONSTIFY_VISITED(type))
101153 + continue;
101154 +
101155 + if (DECL_EXTERNAL(var))
101156 + continue;
101157 +
101158 + if (DECL_INITIAL(var))
101159 + continue;
101160 +
101161 + // this works around a gcc bug/feature where uninitialized globals
101162 + // are moved into the .bss section regardless of any constification
101163 + DECL_INITIAL(var) = build_constructor(type, NULL);
101164 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
101165 + }
101166 +}
101167 +
101168 +static unsigned int check_local_variables(void)
101169 +{
101170 + unsigned int ret = 0;
101171 + tree var;
101172 +
101173 +#if BUILDING_GCC_VERSION == 4005
101174 + tree vars;
101175 +#else
101176 + unsigned int i;
101177 +#endif
101178 +
101179 +#if BUILDING_GCC_VERSION == 4005
101180 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
101181 + var = TREE_VALUE(vars);
101182 +#else
101183 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
101184 +#endif
101185 + tree type = TREE_TYPE(var);
101186 +
101187 + gcc_assert(DECL_P(var));
101188 + if (is_global_var(var))
101189 + continue;
101190 +
101191 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101192 + continue;
101193 +
101194 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101195 + continue;
101196 +
101197 + if (!TYPE_CONSTIFY_VISITED(type))
101198 + continue;
101199 +
101200 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
101201 + ret = 1;
101202 + }
101203 + return ret;
101204 +}
101205 +
101206 +static unsigned int check_variables(void)
101207 +{
101208 + check_global_variables();
101209 + return check_local_variables();
101210 +}
101211 +
101212 + unsigned int ret = 0;
101213 +static struct gimple_opt_pass pass_local_variable = {
101214 + {
101215 + .type = GIMPLE_PASS,
101216 + .name = "check_variables",
101217 +#if BUILDING_GCC_VERSION >= 4008
101218 + .optinfo_flags = OPTGROUP_NONE,
101219 +#endif
101220 + .gate = NULL,
101221 + .execute = check_variables,
101222 + .sub = NULL,
101223 + .next = NULL,
101224 + .static_pass_number = 0,
101225 + .tv_id = TV_NONE,
101226 + .properties_required = 0,
101227 + .properties_provided = 0,
101228 + .properties_destroyed = 0,
101229 + .todo_flags_start = 0,
101230 + .todo_flags_finish = 0
101231 + }
101232 +};
101233 +
101234 +static struct {
101235 + const char *name;
101236 + const char *asm_op;
101237 +} sections[] = {
101238 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
101239 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
101240 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
101241 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
101242 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
101243 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
101244 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
101245 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
101246 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
101247 +};
101248 +
101249 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
101250 +
101251 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
101252 +{
101253 + size_t i;
101254 +
101255 + for (i = 0; i < ARRAY_SIZE(sections); i++)
101256 + if (!strcmp(sections[i].name, name))
101257 + return 0;
101258 + return old_section_type_flags(decl, name, reloc);
101259 +}
101260 +
101261 +static void constify_start_unit(void *gcc_data, void *user_data)
101262 +{
101263 +// size_t i;
101264 +
101265 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
101266 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
101267 +// sections[i].section = get_section(sections[i].name, 0, NULL);
101268 +
101269 + old_section_type_flags = targetm.section_type_flags;
101270 + targetm.section_type_flags = constify_section_type_flags;
101271 +}
101272 +
101273 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101274 +{
101275 + const char * const plugin_name = plugin_info->base_name;
101276 + const int argc = plugin_info->argc;
101277 + const struct plugin_argument * const argv = plugin_info->argv;
101278 + int i;
101279 + bool constify = true;
101280 +
101281 + struct register_pass_info local_variable_pass_info = {
101282 + .pass = &pass_local_variable.pass,
101283 + .reference_pass_name = "ssa",
101284 + .ref_pass_instance_number = 1,
101285 + .pos_op = PASS_POS_INSERT_BEFORE
101286 + };
101287 +
101288 + if (!plugin_default_version_check(version, &gcc_version)) {
101289 + error(G_("incompatible gcc/plugin versions"));
101290 + return 1;
101291 + }
101292 +
101293 + for (i = 0; i < argc; ++i) {
101294 + if (!(strcmp(argv[i].key, "no-constify"))) {
101295 + constify = false;
101296 + continue;
101297 + }
101298 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101299 + }
101300 +
101301 + if (strcmp(lang_hooks.name, "GNU C")) {
101302 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
101303 + constify = false;
101304 + }
101305 +
101306 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
101307 + if (constify) {
101308 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
101309 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
101310 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
101311 + }
101312 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101313 +
101314 + return 0;
101315 +}
101316 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
101317 new file mode 100644
101318 index 0000000..e518932
101319 --- /dev/null
101320 +++ b/tools/gcc/generate_size_overflow_hash.sh
101321 @@ -0,0 +1,94 @@
101322 +#!/bin/bash
101323 +
101324 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
101325 +
101326 +header1="size_overflow_hash.h"
101327 +database="size_overflow_hash.data"
101328 +n=65536
101329 +
101330 +usage() {
101331 +cat <<EOF
101332 +usage: $0 options
101333 +OPTIONS:
101334 + -h|--help help
101335 + -o header file
101336 + -d database file
101337 + -n hash array size
101338 +EOF
101339 + return 0
101340 +}
101341 +
101342 +while true
101343 +do
101344 + case "$1" in
101345 + -h|--help) usage && exit 0;;
101346 + -n) n=$2; shift 2;;
101347 + -o) header1="$2"; shift 2;;
101348 + -d) database="$2"; shift 2;;
101349 + --) shift 1; break ;;
101350 + *) break ;;
101351 + esac
101352 +done
101353 +
101354 +create_defines() {
101355 + for i in `seq 0 31`
101356 + do
101357 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
101358 + done
101359 + echo >> "$header1"
101360 +}
101361 +
101362 +create_structs() {
101363 + rm -f "$header1"
101364 +
101365 + create_defines
101366 +
101367 + cat "$database" | while read data
101368 + do
101369 + data_array=($data)
101370 + struct_hash_name="${data_array[0]}"
101371 + funcn="${data_array[1]}"
101372 + params="${data_array[2]}"
101373 + next="${data_array[4]}"
101374 +
101375 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
101376 +
101377 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
101378 + echo -en "\t.param\t= " >> "$header1"
101379 + line=
101380 + for param_num in ${params//-/ };
101381 + do
101382 + line="${line}PARAM"$param_num"|"
101383 + done
101384 +
101385 + echo -e "${line%?},\n};\n" >> "$header1"
101386 + done
101387 +}
101388 +
101389 +create_headers() {
101390 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
101391 +}
101392 +
101393 +create_array_elements() {
101394 + index=0
101395 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
101396 + do
101397 + data_array=($data)
101398 + i="${data_array[3]}"
101399 + hash="${data_array[0]}"
101400 + while [[ $index -lt $i ]]
101401 + do
101402 + echo -e "\t["$index"]\t= NULL," >> "$header1"
101403 + index=$(($index + 1))
101404 + done
101405 + index=$(($index + 1))
101406 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
101407 + done
101408 + echo '};' >> $header1
101409 +}
101410 +
101411 +create_structs
101412 +create_headers
101413 +create_array_elements
101414 +
101415 +exit 0
101416 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
101417 new file mode 100644
101418 index 0000000..568b360
101419 --- /dev/null
101420 +++ b/tools/gcc/kallocstat_plugin.c
101421 @@ -0,0 +1,170 @@
101422 +/*
101423 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101424 + * Licensed under the GPL v2
101425 + *
101426 + * Note: the choice of the license means that the compilation process is
101427 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101428 + * but for the kernel it doesn't matter since it doesn't link against
101429 + * any of the gcc libraries
101430 + *
101431 + * gcc plugin to find the distribution of k*alloc sizes
101432 + *
101433 + * TODO:
101434 + *
101435 + * BUGS:
101436 + * - none known
101437 + */
101438 +#include "gcc-plugin.h"
101439 +#include "config.h"
101440 +#include "system.h"
101441 +#include "coretypes.h"
101442 +#include "tree.h"
101443 +#include "tree-pass.h"
101444 +#include "flags.h"
101445 +#include "intl.h"
101446 +#include "toplev.h"
101447 +#include "plugin.h"
101448 +//#include "expr.h" where are you...
101449 +#include "diagnostic.h"
101450 +#include "plugin-version.h"
101451 +#include "tm.h"
101452 +#include "function.h"
101453 +#include "basic-block.h"
101454 +#include "gimple.h"
101455 +#include "rtl.h"
101456 +#include "emit-rtl.h"
101457 +
101458 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101459 +
101460 +int plugin_is_GPL_compatible;
101461 +
101462 +static const char * const kalloc_functions[] = {
101463 + "__kmalloc",
101464 + "kmalloc",
101465 + "kmalloc_large",
101466 + "kmalloc_node",
101467 + "kmalloc_order",
101468 + "kmalloc_order_trace",
101469 + "kmalloc_slab",
101470 + "kzalloc",
101471 + "kzalloc_node",
101472 +};
101473 +
101474 +static struct plugin_info kallocstat_plugin_info = {
101475 + .version = "201302112000",
101476 +};
101477 +
101478 +static unsigned int execute_kallocstat(void);
101479 +
101480 +static struct gimple_opt_pass kallocstat_pass = {
101481 + .pass = {
101482 + .type = GIMPLE_PASS,
101483 + .name = "kallocstat",
101484 +#if BUILDING_GCC_VERSION >= 4008
101485 + .optinfo_flags = OPTGROUP_NONE,
101486 +#endif
101487 + .gate = NULL,
101488 + .execute = execute_kallocstat,
101489 + .sub = NULL,
101490 + .next = NULL,
101491 + .static_pass_number = 0,
101492 + .tv_id = TV_NONE,
101493 + .properties_required = 0,
101494 + .properties_provided = 0,
101495 + .properties_destroyed = 0,
101496 + .todo_flags_start = 0,
101497 + .todo_flags_finish = 0
101498 + }
101499 +};
101500 +
101501 +static bool is_kalloc(const char *fnname)
101502 +{
101503 + size_t i;
101504 +
101505 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
101506 + if (!strcmp(fnname, kalloc_functions[i]))
101507 + return true;
101508 + return false;
101509 +}
101510 +
101511 +static unsigned int execute_kallocstat(void)
101512 +{
101513 + basic_block bb;
101514 +
101515 + // 1. loop through BBs and GIMPLE statements
101516 + FOR_EACH_BB(bb) {
101517 + gimple_stmt_iterator gsi;
101518 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101519 + // gimple match:
101520 + tree fndecl, size;
101521 + gimple call_stmt;
101522 + const char *fnname;
101523 +
101524 + // is it a call
101525 + call_stmt = gsi_stmt(gsi);
101526 + if (!is_gimple_call(call_stmt))
101527 + continue;
101528 + fndecl = gimple_call_fndecl(call_stmt);
101529 + if (fndecl == NULL_TREE)
101530 + continue;
101531 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
101532 + continue;
101533 +
101534 + // is it a call to k*alloc
101535 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
101536 + if (!is_kalloc(fnname))
101537 + continue;
101538 +
101539 + // is the size arg the result of a simple const assignment
101540 + size = gimple_call_arg(call_stmt, 0);
101541 + while (true) {
101542 + gimple def_stmt;
101543 + expanded_location xloc;
101544 + size_t size_val;
101545 +
101546 + if (TREE_CODE(size) != SSA_NAME)
101547 + break;
101548 + def_stmt = SSA_NAME_DEF_STMT(size);
101549 + if (!def_stmt || !is_gimple_assign(def_stmt))
101550 + break;
101551 + if (gimple_num_ops(def_stmt) != 2)
101552 + break;
101553 + size = gimple_assign_rhs1(def_stmt);
101554 + if (!TREE_CONSTANT(size))
101555 + continue;
101556 + xloc = expand_location(gimple_location(def_stmt));
101557 + if (!xloc.file)
101558 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101559 + size_val = TREE_INT_CST_LOW(size);
101560 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101561 + break;
101562 + }
101563 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101564 +//debug_tree(gimple_call_fn(call_stmt));
101565 +//print_node(stderr, "pax", fndecl, 4);
101566 + }
101567 + }
101568 +
101569 + return 0;
101570 +}
101571 +
101572 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101573 +{
101574 + const char * const plugin_name = plugin_info->base_name;
101575 + struct register_pass_info kallocstat_pass_info = {
101576 + .pass = &kallocstat_pass.pass,
101577 + .reference_pass_name = "ssa",
101578 + .ref_pass_instance_number = 1,
101579 + .pos_op = PASS_POS_INSERT_AFTER
101580 + };
101581 +
101582 + if (!plugin_default_version_check(version, &gcc_version)) {
101583 + error(G_("incompatible gcc/plugin versions"));
101584 + return 1;
101585 + }
101586 +
101587 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101588 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101589 +
101590 + return 0;
101591 +}
101592 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101593 new file mode 100644
101594 index 0000000..698da67
101595 --- /dev/null
101596 +++ b/tools/gcc/kernexec_plugin.c
101597 @@ -0,0 +1,471 @@
101598 +/*
101599 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101600 + * Licensed under the GPL v2
101601 + *
101602 + * Note: the choice of the license means that the compilation process is
101603 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101604 + * but for the kernel it doesn't matter since it doesn't link against
101605 + * any of the gcc libraries
101606 + *
101607 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101608 + *
101609 + * TODO:
101610 + *
101611 + * BUGS:
101612 + * - none known
101613 + */
101614 +#include "gcc-plugin.h"
101615 +#include "config.h"
101616 +#include "system.h"
101617 +#include "coretypes.h"
101618 +#include "tree.h"
101619 +#include "tree-pass.h"
101620 +#include "flags.h"
101621 +#include "intl.h"
101622 +#include "toplev.h"
101623 +#include "plugin.h"
101624 +//#include "expr.h" where are you...
101625 +#include "diagnostic.h"
101626 +#include "plugin-version.h"
101627 +#include "tm.h"
101628 +#include "function.h"
101629 +#include "basic-block.h"
101630 +#include "gimple.h"
101631 +#include "rtl.h"
101632 +#include "emit-rtl.h"
101633 +#include "tree-flow.h"
101634 +
101635 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101636 +extern rtx emit_move_insn(rtx x, rtx y);
101637 +
101638 +#if BUILDING_GCC_VERSION <= 4006
101639 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101640 +#endif
101641 +
101642 +#if BUILDING_GCC_VERSION >= 4008
101643 +#define TODO_dump_func 0
101644 +#endif
101645 +
101646 +int plugin_is_GPL_compatible;
101647 +
101648 +static struct plugin_info kernexec_plugin_info = {
101649 + .version = "201308230150",
101650 + .help = "method=[bts|or]\tinstrumentation method\n"
101651 +};
101652 +
101653 +static unsigned int execute_kernexec_reload(void);
101654 +static unsigned int execute_kernexec_fptr(void);
101655 +static unsigned int execute_kernexec_retaddr(void);
101656 +static bool kernexec_cmodel_check(void);
101657 +
101658 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101659 +static void (*kernexec_instrument_retaddr)(rtx);
101660 +
101661 +static struct gimple_opt_pass kernexec_reload_pass = {
101662 + .pass = {
101663 + .type = GIMPLE_PASS,
101664 + .name = "kernexec_reload",
101665 +#if BUILDING_GCC_VERSION >= 4008
101666 + .optinfo_flags = OPTGROUP_NONE,
101667 +#endif
101668 + .gate = kernexec_cmodel_check,
101669 + .execute = execute_kernexec_reload,
101670 + .sub = NULL,
101671 + .next = NULL,
101672 + .static_pass_number = 0,
101673 + .tv_id = TV_NONE,
101674 + .properties_required = 0,
101675 + .properties_provided = 0,
101676 + .properties_destroyed = 0,
101677 + .todo_flags_start = 0,
101678 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101679 + }
101680 +};
101681 +
101682 +static struct gimple_opt_pass kernexec_fptr_pass = {
101683 + .pass = {
101684 + .type = GIMPLE_PASS,
101685 + .name = "kernexec_fptr",
101686 +#if BUILDING_GCC_VERSION >= 4008
101687 + .optinfo_flags = OPTGROUP_NONE,
101688 +#endif
101689 + .gate = kernexec_cmodel_check,
101690 + .execute = execute_kernexec_fptr,
101691 + .sub = NULL,
101692 + .next = NULL,
101693 + .static_pass_number = 0,
101694 + .tv_id = TV_NONE,
101695 + .properties_required = 0,
101696 + .properties_provided = 0,
101697 + .properties_destroyed = 0,
101698 + .todo_flags_start = 0,
101699 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101700 + }
101701 +};
101702 +
101703 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101704 + .pass = {
101705 + .type = RTL_PASS,
101706 + .name = "kernexec_retaddr",
101707 +#if BUILDING_GCC_VERSION >= 4008
101708 + .optinfo_flags = OPTGROUP_NONE,
101709 +#endif
101710 + .gate = kernexec_cmodel_check,
101711 + .execute = execute_kernexec_retaddr,
101712 + .sub = NULL,
101713 + .next = NULL,
101714 + .static_pass_number = 0,
101715 + .tv_id = TV_NONE,
101716 + .properties_required = 0,
101717 + .properties_provided = 0,
101718 + .properties_destroyed = 0,
101719 + .todo_flags_start = 0,
101720 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101721 + }
101722 +};
101723 +
101724 +static bool kernexec_cmodel_check(void)
101725 +{
101726 + tree section;
101727 +
101728 + if (ix86_cmodel != CM_KERNEL)
101729 + return false;
101730 +
101731 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101732 + if (!section || !TREE_VALUE(section))
101733 + return true;
101734 +
101735 + section = TREE_VALUE(TREE_VALUE(section));
101736 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101737 + return true;
101738 +
101739 + return false;
101740 +}
101741 +
101742 +/*
101743 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101744 + */
101745 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101746 +{
101747 + gimple asm_movabs_stmt;
101748 +
101749 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101750 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101751 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101752 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101753 + update_stmt(asm_movabs_stmt);
101754 +}
101755 +
101756 +/*
101757 + * find all asm() stmts that clobber r10 and add a reload of r10
101758 + */
101759 +static unsigned int execute_kernexec_reload(void)
101760 +{
101761 + basic_block bb;
101762 +
101763 + // 1. loop through BBs and GIMPLE statements
101764 + FOR_EACH_BB(bb) {
101765 + gimple_stmt_iterator gsi;
101766 +
101767 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101768 + // gimple match: __asm__ ("" : : : "r10");
101769 + gimple asm_stmt;
101770 + size_t nclobbers;
101771 +
101772 + // is it an asm ...
101773 + asm_stmt = gsi_stmt(gsi);
101774 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101775 + continue;
101776 +
101777 + // ... clobbering r10
101778 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101779 + while (nclobbers--) {
101780 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101781 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101782 + continue;
101783 + kernexec_reload_fptr_mask(&gsi);
101784 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101785 + break;
101786 + }
101787 + }
101788 + }
101789 +
101790 + return 0;
101791 +}
101792 +
101793 +/*
101794 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101795 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101796 + */
101797 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101798 +{
101799 + gimple assign_intptr, assign_new_fptr, call_stmt;
101800 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101801 +
101802 + call_stmt = gsi_stmt(*gsi);
101803 + old_fptr = gimple_call_fn(call_stmt);
101804 +
101805 + // create temporary unsigned long variable used for bitops and cast fptr to it
101806 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101807 +#if BUILDING_GCC_VERSION <= 4007
101808 + add_referenced_var(intptr);
101809 +#endif
101810 + intptr = make_ssa_name(intptr, NULL);
101811 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101812 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101813 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101814 + update_stmt(assign_intptr);
101815 +
101816 + // apply logical or to temporary unsigned long and bitmask
101817 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101818 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101819 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101820 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101821 + assign_intptr = gimple_build_assign(intptr, orptr);
101822 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101823 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101824 + update_stmt(assign_intptr);
101825 +
101826 + // cast temporary unsigned long back to a temporary fptr variable
101827 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101828 +#if BUILDING_GCC_VERSION <= 4007
101829 + add_referenced_var(new_fptr);
101830 +#endif
101831 + new_fptr = make_ssa_name(new_fptr, NULL);
101832 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101833 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101834 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101835 + update_stmt(assign_new_fptr);
101836 +
101837 + // replace call stmt fn with the new fptr
101838 + gimple_call_set_fn(call_stmt, new_fptr);
101839 + update_stmt(call_stmt);
101840 +}
101841 +
101842 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101843 +{
101844 + gimple asm_or_stmt, call_stmt;
101845 + tree old_fptr, new_fptr, input, output;
101846 +#if BUILDING_GCC_VERSION <= 4007
101847 + VEC(tree, gc) *inputs = NULL;
101848 + VEC(tree, gc) *outputs = NULL;
101849 +#else
101850 + vec<tree, va_gc> *inputs = NULL;
101851 + vec<tree, va_gc> *outputs = NULL;
101852 +#endif
101853 +
101854 + call_stmt = gsi_stmt(*gsi);
101855 + old_fptr = gimple_call_fn(call_stmt);
101856 +
101857 + // create temporary fptr variable
101858 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101859 +#if BUILDING_GCC_VERSION <= 4007
101860 + add_referenced_var(new_fptr);
101861 +#endif
101862 + new_fptr = make_ssa_name(new_fptr, NULL);
101863 +
101864 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101865 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101866 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101867 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101868 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101869 +#if BUILDING_GCC_VERSION <= 4007
101870 + VEC_safe_push(tree, gc, inputs, input);
101871 + VEC_safe_push(tree, gc, outputs, output);
101872 +#else
101873 + vec_safe_push(inputs, input);
101874 + vec_safe_push(outputs, output);
101875 +#endif
101876 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101877 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101878 + gimple_asm_set_volatile(asm_or_stmt, true);
101879 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101880 + update_stmt(asm_or_stmt);
101881 +
101882 + // replace call stmt fn with the new fptr
101883 + gimple_call_set_fn(call_stmt, new_fptr);
101884 + update_stmt(call_stmt);
101885 +}
101886 +
101887 +/*
101888 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101889 + */
101890 +static unsigned int execute_kernexec_fptr(void)
101891 +{
101892 + basic_block bb;
101893 +
101894 + // 1. loop through BBs and GIMPLE statements
101895 + FOR_EACH_BB(bb) {
101896 + gimple_stmt_iterator gsi;
101897 +
101898 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101899 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101900 + tree fn;
101901 + gimple call_stmt;
101902 +
101903 + // is it a call ...
101904 + call_stmt = gsi_stmt(gsi);
101905 + if (!is_gimple_call(call_stmt))
101906 + continue;
101907 + fn = gimple_call_fn(call_stmt);
101908 + if (TREE_CODE(fn) == ADDR_EXPR)
101909 + continue;
101910 + if (TREE_CODE(fn) != SSA_NAME)
101911 + gcc_unreachable();
101912 +
101913 + // ... through a function pointer
101914 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101915 + fn = SSA_NAME_VAR(fn);
101916 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101917 + debug_tree(fn);
101918 + gcc_unreachable();
101919 + }
101920 + }
101921 + fn = TREE_TYPE(fn);
101922 + if (TREE_CODE(fn) != POINTER_TYPE)
101923 + continue;
101924 + fn = TREE_TYPE(fn);
101925 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101926 + continue;
101927 +
101928 + kernexec_instrument_fptr(&gsi);
101929 +
101930 +//debug_tree(gimple_call_fn(call_stmt));
101931 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101932 + }
101933 + }
101934 +
101935 + return 0;
101936 +}
101937 +
101938 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101939 +static void kernexec_instrument_retaddr_bts(rtx insn)
101940 +{
101941 + rtx btsq;
101942 + rtvec argvec, constraintvec, labelvec;
101943 + int line;
101944 +
101945 + // create asm volatile("btsq $63,(%%rsp)":::)
101946 + argvec = rtvec_alloc(0);
101947 + constraintvec = rtvec_alloc(0);
101948 + labelvec = rtvec_alloc(0);
101949 + line = expand_location(RTL_LOCATION(insn)).line;
101950 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101951 + MEM_VOLATILE_P(btsq) = 1;
101952 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101953 + emit_insn_before(btsq, insn);
101954 +}
101955 +
101956 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101957 +static void kernexec_instrument_retaddr_or(rtx insn)
101958 +{
101959 + rtx orq;
101960 + rtvec argvec, constraintvec, labelvec;
101961 + int line;
101962 +
101963 + // create asm volatile("orq %%r10,(%%rsp)":::)
101964 + argvec = rtvec_alloc(0);
101965 + constraintvec = rtvec_alloc(0);
101966 + labelvec = rtvec_alloc(0);
101967 + line = expand_location(RTL_LOCATION(insn)).line;
101968 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101969 + MEM_VOLATILE_P(orq) = 1;
101970 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101971 + emit_insn_before(orq, insn);
101972 +}
101973 +
101974 +/*
101975 + * find all asm level function returns and forcibly set the highest bit of the return address
101976 + */
101977 +static unsigned int execute_kernexec_retaddr(void)
101978 +{
101979 + rtx insn;
101980 +
101981 + // 1. find function returns
101982 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101983 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101984 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101985 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101986 + rtx body;
101987 +
101988 + // is it a retn
101989 + if (!JUMP_P(insn))
101990 + continue;
101991 + body = PATTERN(insn);
101992 + if (GET_CODE(body) == PARALLEL)
101993 + body = XVECEXP(body, 0, 0);
101994 + if (!ANY_RETURN_P(body))
101995 + continue;
101996 + kernexec_instrument_retaddr(insn);
101997 + }
101998 +
101999 +// print_simple_rtl(stderr, get_insns());
102000 +// print_rtl(stderr, get_insns());
102001 +
102002 + return 0;
102003 +}
102004 +
102005 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102006 +{
102007 + const char * const plugin_name = plugin_info->base_name;
102008 + const int argc = plugin_info->argc;
102009 + const struct plugin_argument * const argv = plugin_info->argv;
102010 + int i;
102011 + struct register_pass_info kernexec_reload_pass_info = {
102012 + .pass = &kernexec_reload_pass.pass,
102013 + .reference_pass_name = "ssa",
102014 + .ref_pass_instance_number = 1,
102015 + .pos_op = PASS_POS_INSERT_AFTER
102016 + };
102017 + struct register_pass_info kernexec_fptr_pass_info = {
102018 + .pass = &kernexec_fptr_pass.pass,
102019 + .reference_pass_name = "ssa",
102020 + .ref_pass_instance_number = 1,
102021 + .pos_op = PASS_POS_INSERT_AFTER
102022 + };
102023 + struct register_pass_info kernexec_retaddr_pass_info = {
102024 + .pass = &kernexec_retaddr_pass.pass,
102025 + .reference_pass_name = "pro_and_epilogue",
102026 + .ref_pass_instance_number = 1,
102027 + .pos_op = PASS_POS_INSERT_AFTER
102028 + };
102029 +
102030 + if (!plugin_default_version_check(version, &gcc_version)) {
102031 + error(G_("incompatible gcc/plugin versions"));
102032 + return 1;
102033 + }
102034 +
102035 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
102036 +
102037 + if (TARGET_64BIT == 0)
102038 + return 0;
102039 +
102040 + for (i = 0; i < argc; ++i) {
102041 + if (!strcmp(argv[i].key, "method")) {
102042 + if (!argv[i].value) {
102043 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102044 + continue;
102045 + }
102046 + if (!strcmp(argv[i].value, "bts")) {
102047 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
102048 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
102049 + } else if (!strcmp(argv[i].value, "or")) {
102050 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
102051 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
102052 + fix_register("r10", 1, 1);
102053 + } else
102054 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102055 + continue;
102056 + }
102057 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102058 + }
102059 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
102060 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
102061 +
102062 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
102063 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
102064 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
102065 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
102066 +
102067 + return 0;
102068 +}
102069 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
102070 new file mode 100644
102071 index 0000000..679b9ef
102072 --- /dev/null
102073 +++ b/tools/gcc/latent_entropy_plugin.c
102074 @@ -0,0 +1,335 @@
102075 +/*
102076 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
102077 + * Licensed under the GPL v2
102078 + *
102079 + * Note: the choice of the license means that the compilation process is
102080 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102081 + * but for the kernel it doesn't matter since it doesn't link against
102082 + * any of the gcc libraries
102083 + *
102084 + * gcc plugin to help generate a little bit of entropy from program state,
102085 + * used during boot in the kernel
102086 + *
102087 + * TODO:
102088 + * - add ipa pass to identify not explicitly marked candidate functions
102089 + * - mix in more program state (function arguments/return values, loop variables, etc)
102090 + * - more instrumentation control via attribute parameters
102091 + *
102092 + * BUGS:
102093 + * - LTO needs -flto-partition=none for now
102094 + */
102095 +#include "gcc-plugin.h"
102096 +#include "config.h"
102097 +#include "system.h"
102098 +#include "coretypes.h"
102099 +#include "tree.h"
102100 +#include "tree-pass.h"
102101 +#include "flags.h"
102102 +#include "intl.h"
102103 +#include "toplev.h"
102104 +#include "plugin.h"
102105 +//#include "expr.h" where are you...
102106 +#include "diagnostic.h"
102107 +#include "plugin-version.h"
102108 +#include "tm.h"
102109 +#include "function.h"
102110 +#include "basic-block.h"
102111 +#include "gimple.h"
102112 +#include "rtl.h"
102113 +#include "emit-rtl.h"
102114 +#include "tree-flow.h"
102115 +#include "langhooks.h"
102116 +
102117 +#if BUILDING_GCC_VERSION >= 4008
102118 +#define TODO_dump_func 0
102119 +#endif
102120 +
102121 +int plugin_is_GPL_compatible;
102122 +
102123 +static tree latent_entropy_decl;
102124 +
102125 +static struct plugin_info latent_entropy_plugin_info = {
102126 + .version = "201308230230",
102127 + .help = NULL
102128 +};
102129 +
102130 +static unsigned int execute_latent_entropy(void);
102131 +static bool gate_latent_entropy(void);
102132 +
102133 +static struct gimple_opt_pass latent_entropy_pass = {
102134 + .pass = {
102135 + .type = GIMPLE_PASS,
102136 + .name = "latent_entropy",
102137 +#if BUILDING_GCC_VERSION >= 4008
102138 + .optinfo_flags = OPTGROUP_NONE,
102139 +#endif
102140 + .gate = gate_latent_entropy,
102141 + .execute = execute_latent_entropy,
102142 + .sub = NULL,
102143 + .next = NULL,
102144 + .static_pass_number = 0,
102145 + .tv_id = TV_NONE,
102146 + .properties_required = PROP_gimple_leh | PROP_cfg,
102147 + .properties_provided = 0,
102148 + .properties_destroyed = 0,
102149 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102150 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102151 + }
102152 +};
102153 +
102154 +static unsigned HOST_WIDE_INT seed;
102155 +static unsigned HOST_WIDE_INT get_random_const(void)
102156 +{
102157 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
102158 + return seed;
102159 +}
102160 +
102161 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102162 +{
102163 + switch (TREE_CODE(*node)) {
102164 + default:
102165 + *no_add_attrs = true;
102166 + error("%qE attribute only applies to functions and variables", name);
102167 + break;
102168 +
102169 + case VAR_DECL:
102170 + if (DECL_INITIAL(*node)) {
102171 + *no_add_attrs = true;
102172 + error("variable %qD with %qE attribute must not be initialized", *node, name);
102173 + break;
102174 + }
102175 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
102176 + break;
102177 +
102178 + case FUNCTION_DECL:
102179 + break;
102180 + }
102181 +
102182 + return NULL_TREE;
102183 +}
102184 +
102185 +static struct attribute_spec latent_entropy_attr = {
102186 + .name = "latent_entropy",
102187 + .min_length = 0,
102188 + .max_length = 0,
102189 + .decl_required = true,
102190 + .type_required = false,
102191 + .function_type_required = false,
102192 + .handler = handle_latent_entropy_attribute,
102193 +#if BUILDING_GCC_VERSION >= 4007
102194 + .affects_type_identity = false
102195 +#endif
102196 +};
102197 +
102198 +static void register_attributes(void *event_data, void *data)
102199 +{
102200 + register_attribute(&latent_entropy_attr);
102201 +}
102202 +
102203 +static bool gate_latent_entropy(void)
102204 +{
102205 + tree latent_entropy_attr;
102206 +
102207 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
102208 + return latent_entropy_attr != NULL_TREE;
102209 +}
102210 +
102211 +static enum tree_code get_op(tree *rhs)
102212 +{
102213 + static enum tree_code op;
102214 + unsigned HOST_WIDE_INT random_const;
102215 +
102216 + random_const = get_random_const();
102217 +
102218 + switch (op) {
102219 + case BIT_XOR_EXPR:
102220 + op = PLUS_EXPR;
102221 + break;
102222 +
102223 + case PLUS_EXPR:
102224 + if (rhs) {
102225 + op = LROTATE_EXPR;
102226 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
102227 + break;
102228 + }
102229 +
102230 + case LROTATE_EXPR:
102231 + default:
102232 + op = BIT_XOR_EXPR;
102233 + break;
102234 + }
102235 + if (rhs)
102236 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
102237 + return op;
102238 +}
102239 +
102240 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
102241 +{
102242 + gimple_stmt_iterator gsi;
102243 + gimple assign;
102244 + tree addxorrol, rhs;
102245 + enum tree_code op;
102246 +
102247 + op = get_op(&rhs);
102248 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
102249 + assign = gimple_build_assign(local_entropy, addxorrol);
102250 + gsi = gsi_after_labels(bb);
102251 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102252 + update_stmt(assign);
102253 +//debug_bb(bb);
102254 +}
102255 +
102256 +static void perturb_latent_entropy(basic_block bb, tree rhs)
102257 +{
102258 + gimple_stmt_iterator gsi;
102259 + gimple assign;
102260 + tree addxorrol, temp;
102261 +
102262 + // 1. create temporary copy of latent_entropy
102263 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
102264 +#if BUILDING_GCC_VERSION <= 4007
102265 + add_referenced_var(temp);
102266 +#endif
102267 +
102268 + // 2. read...
102269 + temp = make_ssa_name(temp, NULL);
102270 + assign = gimple_build_assign(temp, latent_entropy_decl);
102271 + SSA_NAME_DEF_STMT(temp) = assign;
102272 +#if BUILDING_GCC_VERSION <= 4007
102273 + add_referenced_var(latent_entropy_decl);
102274 +#endif
102275 + gsi = gsi_after_labels(bb);
102276 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102277 + update_stmt(assign);
102278 +
102279 + // 3. ...modify...
102280 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
102281 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
102282 + assign = gimple_build_assign(temp, addxorrol);
102283 + SSA_NAME_DEF_STMT(temp) = assign;
102284 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102285 + update_stmt(assign);
102286 +
102287 + // 4. ...write latent_entropy
102288 + assign = gimple_build_assign(latent_entropy_decl, temp);
102289 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102290 + update_stmt(assign);
102291 +}
102292 +
102293 +static unsigned int execute_latent_entropy(void)
102294 +{
102295 + basic_block bb;
102296 + gimple assign;
102297 + gimple_stmt_iterator gsi;
102298 + tree local_entropy;
102299 +
102300 + if (!latent_entropy_decl) {
102301 + struct varpool_node *node;
102302 +
102303 +#if BUILDING_GCC_VERSION <= 4007
102304 + for (node = varpool_nodes; node; node = node->next) {
102305 + tree var = node->decl;
102306 +#else
102307 + FOR_EACH_VARIABLE(node) {
102308 + tree var = node->symbol.decl;
102309 +#endif
102310 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
102311 + continue;
102312 + latent_entropy_decl = var;
102313 +// debug_tree(var);
102314 + break;
102315 + }
102316 + if (!latent_entropy_decl) {
102317 +// debug_tree(current_function_decl);
102318 + return 0;
102319 + }
102320 + }
102321 +
102322 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102323 +
102324 + // 1. create local entropy variable
102325 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
102326 +#if BUILDING_GCC_VERSION <= 4007
102327 + add_referenced_var(local_entropy);
102328 + mark_sym_for_renaming(local_entropy);
102329 +#endif
102330 +
102331 + // 2. initialize local entropy variable
102332 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102333 + if (dom_info_available_p(CDI_DOMINATORS))
102334 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102335 + gsi = gsi_start_bb(bb);
102336 +
102337 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
102338 +// gimple_set_location(assign, loc);
102339 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102340 + update_stmt(assign);
102341 +//debug_bb(bb);
102342 + bb = bb->next_bb;
102343 +
102344 + // 3. instrument each BB with an operation on the local entropy variable
102345 + while (bb != EXIT_BLOCK_PTR) {
102346 + perturb_local_entropy(bb, local_entropy);
102347 +//debug_bb(bb);
102348 + bb = bb->next_bb;
102349 + };
102350 +
102351 + // 4. mix local entropy into the global entropy variable
102352 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
102353 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
102354 + return 0;
102355 +}
102356 +
102357 +static void start_unit_callback(void *gcc_data, void *user_data)
102358 +{
102359 + tree latent_entropy_type;
102360 +
102361 +#if BUILDING_GCC_VERSION >= 4007
102362 + seed = get_random_seed(false);
102363 +#else
102364 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
102365 + seed *= seed;
102366 +#endif
102367 +
102368 + if (in_lto_p)
102369 + return;
102370 +
102371 + // extern volatile u64 latent_entropy
102372 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
102373 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
102374 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
102375 +
102376 + TREE_STATIC(latent_entropy_decl) = 1;
102377 + TREE_PUBLIC(latent_entropy_decl) = 1;
102378 + TREE_USED(latent_entropy_decl) = 1;
102379 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
102380 + DECL_EXTERNAL(latent_entropy_decl) = 1;
102381 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
102382 + lang_hooks.decls.pushdecl(latent_entropy_decl);
102383 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
102384 +// varpool_finalize_decl(latent_entropy_decl);
102385 +// varpool_mark_needed_node(latent_entropy_decl);
102386 +}
102387 +
102388 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102389 +{
102390 + const char * const plugin_name = plugin_info->base_name;
102391 + struct register_pass_info latent_entropy_pass_info = {
102392 + .pass = &latent_entropy_pass.pass,
102393 + .reference_pass_name = "optimized",
102394 + .ref_pass_instance_number = 1,
102395 + .pos_op = PASS_POS_INSERT_BEFORE
102396 + };
102397 +
102398 + if (!plugin_default_version_check(version, &gcc_version)) {
102399 + error(G_("incompatible gcc/plugin versions"));
102400 + return 1;
102401 + }
102402 +
102403 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
102404 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102405 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
102406 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102407 +
102408 + return 0;
102409 +}
102410 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
102411 new file mode 100644
102412 index 0000000..0a9d518
102413 --- /dev/null
102414 +++ b/tools/gcc/size_overflow_hash.data
102415 @@ -0,0 +1,7637 @@
102416 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
102417 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL
102418 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
102419 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
102420 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
102421 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
102422 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
102423 +padzero_55 padzero 1 55 &sel_read_policyvers_55
102424 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
102425 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
102426 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
102427 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
102428 +load_msg_95 load_msg 2 95 NULL
102429 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
102430 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 NULL nohasharray
102431 +write_all_supers_117 write_all_supers 0 117 &ipath_verbs_send_117
102432 +init_q_132 init_q 4 132 NULL
102433 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
102434 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
102435 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
102436 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
102437 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
102438 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
102439 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
102440 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
102441 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
102442 +device_add_bin_attributes_205 device_add_bin_attributes 0 205 NULL
102443 +br_port_info_size_268 br_port_info_size 0 268 NULL
102444 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
102445 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
102446 +SYSC_connect_304 SYSC_connect 3 304 NULL
102447 +syslog_print_307 syslog_print 2 307 NULL
102448 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
102449 +next_node_allowed_318 next_node_allowed 1-0 318 NULL
102450 +mlx5_core_access_reg_361 mlx5_core_access_reg 5-3 361 NULL
102451 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
102452 +get_more_blocks_367 get_more_blocks 0 367 NULL
102453 +sysfs_create_dir_398 sysfs_create_dir 0 398 NULL
102454 +hw_device_state_409 hw_device_state 0 409 NULL
102455 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL
102456 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
102457 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
102458 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
102459 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
102460 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
102461 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
102462 +_snd_pcm_hw_param_first_516 _snd_pcm_hw_param_first 0 516 NULL
102463 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
102464 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
102465 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
102466 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
102467 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
102468 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
102469 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
102470 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
102471 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
102472 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
102473 +cl_page_own0_599 cl_page_own0 0 599 NULL
102474 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
102475 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
102476 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
102477 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
102478 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
102479 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
102480 +clone_split_bio_633 clone_split_bio 6 633 NULL
102481 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
102482 +remap_to_cache_640 remap_to_cache 3 640 NULL
102483 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL nohasharray
102484 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 &cfs_hash_bkt_size_643
102485 +unlink_queued_645 unlink_queued 4 645 NULL
102486 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
102487 +div_u64_rem_672 div_u64_rem 0 672 NULL
102488 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
102489 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
102490 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
102491 +disk_max_parts_719 disk_max_parts 0 719 NULL
102492 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
102493 +dvb_video_write_754 dvb_video_write 3 754 NULL
102494 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
102495 +jbd2_journal_dirty_metadata_784 jbd2_journal_dirty_metadata 0 784 NULL
102496 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
102497 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
102498 +if_writecmd_815 if_writecmd 2 815 NULL
102499 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
102500 +SyS_write_846 SyS_write 3 846 NULL
102501 +um_idi_read_850 um_idi_read 3 850 NULL
102502 +error_state_read_859 error_state_read 6 859 NULL
102503 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
102504 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
102505 +intel_alloc_iova_883 intel_alloc_iova 3 883 NULL
102506 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
102507 +readw_931 readw 0 931 NULL
102508 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
102509 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
102510 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
102511 +memcmp_990 memcmp 0 990 NULL
102512 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL
102513 +free_ind_block_999 free_ind_block 0 999 NULL
102514 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
102515 +readreg_1017 readreg 0-1 1017 NULL
102516 +_do_truncate_1019 _do_truncate 2 1019 NULL
102517 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
102518 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
102519 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
102520 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
102521 +ext4_orphan_add_1080 ext4_orphan_add 0 1080 NULL
102522 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
102523 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
102524 +inode_ref_info_1094 inode_ref_info 0 1094 NULL nohasharray
102525 +llc_mac_hdr_init_1094 llc_mac_hdr_init 0 1094 &inode_ref_info_1094
102526 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
102527 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
102528 +__btrfs_cow_block_1125 __btrfs_cow_block 7-0 1125 NULL nohasharray
102529 +__ext4_journal_stop_1125 __ext4_journal_stop 0 1125 &__btrfs_cow_block_1125
102530 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
102531 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
102532 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
102533 +find_free_extent_1173 find_free_extent 4-0 1173 NULL
102534 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
102535 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
102536 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
102537 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
102538 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
102539 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
102540 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
102541 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
102542 +nested_get_page_1252 nested_get_page 2 1252 NULL
102543 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
102544 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
102545 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
102546 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
102547 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
102548 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
102549 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
102550 +ffs_1322 ffs 0 1322 NULL
102551 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL nohasharray
102552 +push_node_left_1327 push_node_left 0 1327 &qlcnic_pci_sriov_configure_1327
102553 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
102554 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
102555 +btrfs_alloc_logged_file_extent_1354 btrfs_alloc_logged_file_extent 0 1354 NULL
102556 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
102557 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
102558 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
102559 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
102560 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
102561 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
102562 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
102563 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
102564 +zone_page_state_1393 zone_page_state 0 1393 NULL
102565 +file_read_actor_1401 file_read_actor 4 1401 NULL
102566 +vb2_vmalloc_alloc_1402 vb2_vmalloc_alloc 2 1402 NULL
102567 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
102568 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
102569 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
102570 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
102571 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
102572 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
102573 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
102574 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
102575 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102576 +fpregs_set_1497 fpregs_set 4 1497 NULL
102577 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
102578 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102579 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102580 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102581 +extent_from_logical_1585 extent_from_logical 0 1585 NULL
102582 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102583 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
102584 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102585 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102586 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102587 +run_delayed_extent_op_1637 run_delayed_extent_op 0 1637 NULL
102588 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102589 +qgroup_rescan_init_1664 qgroup_rescan_init 0 1664 NULL
102590 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102591 +rmap_add_1677 rmap_add 3 1677 NULL
102592 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102593 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
102594 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL nohasharray
102595 +gfn_to_hva_prot_1711 gfn_to_hva_prot 2 1711 &coda_psdev_write_1711
102596 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102597 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102598 +internal_create_group_1733 internal_create_group 0 1733 NULL
102599 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
102600 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102601 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102602 +cosa_write_1774 cosa_write 3 1774 NULL
102603 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102604 +__nodelist_scnprintf_1815 __nodelist_scnprintf 4-2-0 1815 NULL
102605 +sb_issue_zeroout_1884 sb_issue_zeroout 3-0 1884 NULL
102606 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102607 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102608 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102609 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
102610 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102611 +bdev_erase_1933 bdev_erase 3 1933 NULL
102612 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
102613 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102614 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102615 +read_swap_header_1957 read_swap_header 0 1957 NULL
102616 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102617 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102618 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
102619 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
102620 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102621 +sb_min_blocksize_2004 sb_min_blocksize 0-2 2004 NULL
102622 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102623 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102624 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102625 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102626 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102627 +BcmCopySection_2035 BcmCopySection 5-0 2035 NULL
102628 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102629 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102630 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
102631 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL nohasharray
102632 +alloc_retstack_tasklist_2077 alloc_retstack_tasklist 0 2077 &diva_set_driver_dbg_mask_2077
102633 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102634 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
102635 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102636 +audit_expand_2098 audit_expand 0 2098 NULL
102637 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102638 +shrd128_2106 shrd128 0-1-3-2 2106 NULL
102639 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102640 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102641 +enable_read_2117 enable_read 3 2117 NULL
102642 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102643 +snd_interval_refine_last_2127 snd_interval_refine_last 0 2127 NULL
102644 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102645 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102646 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102647 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
102648 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
102649 +_ore_get_io_state_2166 _ore_get_io_state 5-3-4 2166 NULL
102650 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102651 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
102652 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102653 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102654 +vhci_write_2224 vhci_write 3 2224 NULL
102655 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
102656 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102657 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102658 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102659 +do_update_counters_2259 do_update_counters 4 2259 NULL
102660 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102661 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102662 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
102663 +kvm_clear_guest_page_2308 kvm_clear_guest_page 2-4 2308 NULL
102664 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102665 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL nohasharray
102666 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 &picolcd_fb_write_2318
102667 +gart_map_page_2325 gart_map_page 4-3 2325 NULL
102668 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102669 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102670 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102671 +SyS_mremap_2367 SyS_mremap 2-3-1-5 2367 NULL
102672 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL nohasharray
102673 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
102674 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102675 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102676 +SYSC_mlock_2415 SYSC_mlock 1-2 2415 NULL
102677 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102678 +raid1_size_2419 raid1_size 0-2 2419 NULL
102679 +timespec_to_jiffies_timeout_2428 timespec_to_jiffies_timeout 0 2428 NULL
102680 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102681 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102682 +wiphy_new_2482 wiphy_new 2 2482 NULL
102683 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102684 +hfsplus_user_setxattr_2485 hfsplus_user_setxattr 4 2485 NULL
102685 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102686 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102687 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102688 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102689 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102690 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102691 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
102692 +slot_bytes_2609 slot_bytes 0 2609 NULL
102693 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102694 +switch_status_2629 switch_status 5 2629 NULL
102695 +tlv_put_string_2631 tlv_put_string 0 2631 NULL
102696 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102697 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL
102698 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
102699 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
102700 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
102701 +oti6858_write_2692 oti6858_write 4 2692 NULL
102702 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102703 +memcpy_fromiovecend_2707 memcpy_fromiovecend 4-3 2707 NULL
102704 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 NULL nohasharray
102705 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 &SyS_pwrite64_2708
102706 +__xip_file_write_2733 __xip_file_write 3-4 2733 NULL
102707 +can_nocow_extent_2744 can_nocow_extent 3 2744 NULL
102708 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
102709 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102710 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102711 +__next_cpu_2782 __next_cpu 1-0 2782 NULL
102712 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102713 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
102714 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
102715 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102716 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
102717 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
102718 +sock_create_2838 sock_create 0 2838 NULL
102719 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102720 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102721 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102722 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
102723 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102724 +mq_map_2871 mq_map 2 2871 NULL
102725 +__swab64p_2875 __swab64p 0 2875 NULL
102726 +nla_padlen_2883 nla_padlen 1 2883 NULL
102727 +cmm_write_2896 cmm_write 3 2896 NULL
102728 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102729 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
102730 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102731 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102732 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102733 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
102734 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102735 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
102736 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102737 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
102738 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102739 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
102740 +btrfs_add_block_group_cache_3016 btrfs_add_block_group_cache 0 3016 NULL
102741 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102742 +depth_write_3021 depth_write 3 3021 NULL
102743 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102744 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL
102745 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102746 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
102747 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
102748 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102749 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102750 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102751 +__blk_end_bidi_request_3070 __blk_end_bidi_request 4-3 3070 NULL
102752 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102753 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
102754 +free_coherent_3082 free_coherent 4-2 3082 NULL
102755 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
102756 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102757 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102758 +rb_alloc_3102 rb_alloc 1 3102 NULL
102759 +simple_write_to_buffer_3122 simple_write_to_buffer 2-5 3122 NULL
102760 +print_time_3132 print_time 0 3132 NULL
102761 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102762 +find_free_extent_3153 find_free_extent 5 3153 NULL
102763 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102764 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102765 +i915_gem_obj_ggtt_offset_3162 i915_gem_obj_ggtt_offset 0 3162 NULL
102766 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102767 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102768 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102769 +wait_table_bits_3187 wait_table_bits 1 3187 NULL
102770 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
102771 +alloc_context_3194 alloc_context 1 3194 NULL
102772 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
102773 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
102774 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102775 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
102776 +btrfs_next_leaf_3232 btrfs_next_leaf 0 3232 NULL
102777 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102778 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
102779 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102780 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102781 +key_key_read_3241 key_key_read 3 3241 NULL
102782 +mmap_piobufs_3244 mmap_piobufs 4 3244 NULL
102783 +did_overwrite_first_ref_3259 did_overwrite_first_ref 0 3259 NULL
102784 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102785 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 0-4-3 3314 NULL
102786 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102787 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102788 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102789 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
102790 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102791 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102792 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102793 +scnprintf_3360 scnprintf 0-2 3360 NULL
102794 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
102795 +sr_read_3366 sr_read 3 3366 NULL
102796 +count_inode_refs_3375 count_inode_refs 0 3375 NULL
102797 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102798 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102799 +send_stream_3397 send_stream 4 3397 NULL
102800 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102801 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102802 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102803 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102804 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102805 +send_unlink_3438 send_unlink 0 3438 NULL
102806 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102807 +map_single_3449 map_single 0 3449 NULL
102808 +softsynth_write_3455 softsynth_write 3 3455 NULL
102809 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102810 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 &jffs2_acl_setxattr_3464
102811 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102812 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102813 +run_one_delayed_ref_3503 run_one_delayed_ref 0 3503 NULL nohasharray
102814 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 &run_one_delayed_ref_3503
102815 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
102816 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
102817 +SyS_readv_3539 SyS_readv 3 3539 NULL
102818 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102819 +iommu_map_3554 iommu_map 3-2 3554 NULL
102820 +btrfs_delayed_update_inode_3557 btrfs_delayed_update_inode 0 3557 NULL
102821 +i915_gem_execbuffer_reserve_3558 i915_gem_execbuffer_reserve 0 3558 NULL
102822 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102823 +evtchn_read_3569 evtchn_read 3 3569 NULL
102824 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
102825 +vc_resize_3585 vc_resize 3-2 3585 NULL
102826 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL
102827 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102828 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102829 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102830 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102831 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL
102832 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102833 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102834 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
102835 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102836 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703
102837 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102838 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102839 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102840 +uar_index2pfn_3741 uar_index2pfn 0-2 3741 NULL
102841 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102842 +btrfs_alloc_chunk_3808 btrfs_alloc_chunk 0 3808 NULL
102843 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102844 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
102845 +btrfs_uuid_iter_rem_3831 btrfs_uuid_iter_rem 0 3831 NULL
102846 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
102847 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102848 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102849 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102850 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102851 +get_fd_set_3866 get_fd_set 1 3866 NULL
102852 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
102853 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102854 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102855 +nvram_write_3894 nvram_write 3 3894 NULL
102856 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102857 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102858 +vcs_write_3910 vcs_write 3 3910 NULL
102859 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
102860 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
102861 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102862 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
102863 +do_add_counters_3992 do_add_counters 3 3992 NULL
102864 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
102865 +userspace_status_4004 userspace_status 4 4004 NULL
102866 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102867 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102868 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102869 +mm_populate_4016 mm_populate 1-2 4016 NULL nohasharray
102870 +i915_gem_object_unbind_4016 i915_gem_object_unbind 0 4016 &mm_populate_4016
102871 +blk_end_request_4024 blk_end_request 3 4024 NULL
102872 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102873 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
102874 +i915_gpu_idle_4062 i915_gpu_idle 0 4062 NULL
102875 +read_file_queues_4078 read_file_queues 3 4078 NULL
102876 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102877 +btrfs_inc_ref_4084 btrfs_inc_ref 0 4084 NULL
102878 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102879 +tm6000_read_4151 tm6000_read 3 4151 NULL
102880 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102881 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102882 +get_alua_req_4166 get_alua_req 3 4166 NULL
102883 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102884 +read_file_bool_4180 read_file_bool 3 4180 NULL
102885 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
102886 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102887 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102888 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102889 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
102890 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102891 +msb_do_write_request_4286 msb_do_write_request 2 4286 NULL
102892 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102893 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102894 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102895 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102896 +__pool_find_4308 __pool_find 3 4308 NULL
102897 +count_strings_4315 count_strings 0 4315 NULL
102898 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102899 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102900 +kvm_apic_get_reg_4354 kvm_apic_get_reg 0 4354 NULL
102901 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 0-3 4365 NULL nohasharray
102902 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
102903 +btrfs_set_disk_extent_flags_4374 btrfs_set_disk_extent_flags 0 4374 NULL
102904 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102905 +access_process_vm_4412 access_process_vm 0-4-2 4412 NULL nohasharray
102906 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102907 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102908 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
102909 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102910 +memparse_4444 memparse 0 4444 NULL
102911 +tcp_dma_try_early_copy_4457 tcp_dma_try_early_copy 3 4457 NULL
102912 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102913 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 5-0 4481 NULL
102914 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
102915 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102916 +set_link_security_4502 set_link_security 4 4502 NULL
102917 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102918 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2-0 4530 NULL
102919 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
102920 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102921 +tty_register_device_4544 tty_register_device 2 4544 NULL
102922 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102923 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102924 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102925 +iommu_map_page_4588 iommu_map_page 5 4588 NULL
102926 +bch_alloc_4593 bch_alloc 1 4593 NULL
102927 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
102928 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102929 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
102930 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102931 +ext3_orphan_add_4665 ext3_orphan_add 0 4665 NULL
102932 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102933 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102934 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102935 +kone_receive_4690 kone_receive 4 4690 NULL
102936 +link_to_fixup_dir_4699 link_to_fixup_dir 0 4699 NULL
102937 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102938 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102939 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102940 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102941 +gfs2_bit_search_4728 gfs2_bit_search 0-2 4728 NULL
102942 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 NULL nohasharray
102943 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 &ll_rw_offset_stats_seq_write_4736
102944 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102945 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
102946 +find_next_best_node_4774 find_next_best_node 1-0 4774 NULL nohasharray
102947 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 &find_next_best_node_4774
102948 +btrfs_del_items_4791 btrfs_del_items 0 4791 NULL nohasharray
102949 +create_subvol_4791 create_subvol 4 4791 &btrfs_del_items_4791
102950 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102951 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
102952 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
102953 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102954 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102955 +get_new_location_4866 get_new_location 0 4866 NULL
102956 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3-2 4873 NULL
102957 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102958 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102959 +ntfs_rl_insert_4931 ntfs_rl_insert 4-2 4931 NULL
102960 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102961 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
102962 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102963 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102964 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102965 +do_sync_read_4977 do_sync_read 0 4977 NULL
102966 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102967 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
102968 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
102969 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
102970 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
102971 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 3-2 5066 NULL
102972 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102973 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102974 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102975 +kfifo_copy_from_user_5091 kfifo_copy_from_user 4-3-0 5091 &get_random_bytes_5091 nohasharray
102976 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102977 +sound_write_5102 sound_write 3 5102 NULL
102978 +clear_dirty_5105 clear_dirty 3 5105 NULL
102979 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
102980 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
102981 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102982 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
102983 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102984 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102985 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102986 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL nohasharray
102987 +r600_mip_minify_5214 r600_mip_minify 2-1-0 5214 &ppp_cp_parse_cr_5214
102988 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102989 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102990 +nouveau_fb_create__5244 nouveau_fb_create_ 5 5244 NULL
102991 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102992 +btrfs_alloc_reserved_file_extent_5274 btrfs_alloc_reserved_file_extent 0 5274 NULL
102993 +iommu_domain_identity_map_5284 iommu_domain_identity_map 2-3 5284 NULL
102994 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102995 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
102996 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102997 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
102998 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102999 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
103000 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
103001 +vm_insert_pfn_5341 vm_insert_pfn 3-0 5341 NULL
103002 +cq_free_res_5355 cq_free_res 5 5355 NULL
103003 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
103004 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 2-3 5368 NULL
103005 +kvm_pin_pages_5369 kvm_pin_pages 2-0 5369 NULL
103006 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
103007 +security_inode_init_security_5408 security_inode_init_security 0 5408 NULL
103008 +__resolve_indirect_refs_5409 __resolve_indirect_refs 0 5409 NULL
103009 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
103010 +check_item_in_log_5440 check_item_in_log 0 5440 NULL
103011 +__split_bvec_across_targets_5454 __split_bvec_across_targets 3 5454 NULL
103012 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
103013 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
103014 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
103015 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
103016 +tty_write_5494 tty_write 3 5494 NULL
103017 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
103018 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
103019 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
103020 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
103021 +iommu_prepare_identity_map_5540 iommu_prepare_identity_map 2-3 5540 NULL
103022 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
103023 +le_readq_5557 le_readq 0 5557 NULL
103024 +inw_5558 inw 0 5558 NULL
103025 +bioset_create_5580 bioset_create 1 5580 NULL
103026 +domain_sg_mapping_5586 domain_sg_mapping 4 5586 NULL
103027 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
103028 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
103029 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
103030 +SYSC_init_module_5626 SYSC_init_module 2 5626 NULL
103031 +iterate_extent_inodes_5631 iterate_extent_inodes 0 5631 NULL
103032 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
103033 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
103034 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
103035 +kgdb_arch_pc_5673 kgdb_arch_pc 0 5673 NULL
103036 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
103037 +get_arg_5694 get_arg 3 5694 NULL
103038 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
103039 +ntfs_attr_record_resize_5720 ntfs_attr_record_resize 0 5720 NULL
103040 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
103041 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
103042 +ubi_calc_fm_size_5749 ubi_calc_fm_size 0 5749 NULL
103043 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
103044 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
103045 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
103046 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
103047 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
103048 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
103049 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
103050 +setup_req_5848 setup_req 3 5848 NULL
103051 +ria_page_count_5849 ria_page_count 0 5849 NULL
103052 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
103053 +config_buf_5862 config_buf 0 5862 NULL
103054 +ext4_ext_correct_indexes_5865 ext4_ext_correct_indexes 0 5865 NULL
103055 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
103056 +scan_bitmap_5888 scan_bitmap 3 5888 NULL
103057 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
103058 +port_show_regs_5904 port_show_regs 3 5904 NULL
103059 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
103060 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
103061 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
103062 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
103063 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
103064 +find_parent_nodes_5948 find_parent_nodes 0 5948 NULL
103065 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
103066 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
103067 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
103068 +native_pte_val_5978 native_pte_val 0 5978 NULL
103069 +jbd2_journal_stop_5979 jbd2_journal_stop 0 5979 NULL
103070 +ntfs_rl_append_6037 ntfs_rl_append 4-2 6037 NULL
103071 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL nohasharray
103072 +device_add_attributes_6058 device_add_attributes 0 6058 &da9052_request_irq_6058
103073 +alloc_msg_6072 alloc_msg 1 6072 NULL
103074 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
103075 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
103076 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
103077 +finish_inode_if_needed_6098 finish_inode_if_needed 0 6098 NULL
103078 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
103079 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
103080 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
103081 +__btrfs_commit_inode_delayed_items_6150 __btrfs_commit_inode_delayed_items 0 6150 NULL
103082 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
103083 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
103084 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
103085 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
103086 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
103087 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
103088 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
103089 +cl_sync_io_wait_6196 cl_sync_io_wait 0 6196 NULL
103090 +i915_gem_execbuffer_move_to_gpu_6197 i915_gem_execbuffer_move_to_gpu 0 6197 NULL
103091 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
103092 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
103093 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
103094 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
103095 +changed_ref_6242 changed_ref 0 6242 NULL
103096 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
103097 +ext4_ext_split_6249 ext4_ext_split 0 6249 NULL
103098 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
103099 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
103100 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
103101 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
103102 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
103103 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
103104 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
103105 +exclude_super_stripes_6326 exclude_super_stripes 0 6326 NULL
103106 +SyS_mincore_6329 SyS_mincore 2-1 6329 NULL nohasharray
103107 +hfa384x_inw_6329 hfa384x_inw 0 6329 &SyS_mincore_6329
103108 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
103109 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
103110 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
103111 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
103112 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
103113 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
103114 +msb_write_block_6379 msb_write_block 3 6379 NULL
103115 +BcmFlash2xBulkRead_6395 BcmFlash2xBulkRead 0 6395 NULL
103116 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
103117 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
103118 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
103119 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
103120 +add_to_list_6433 add_to_list 0 6433 NULL
103121 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
103122 +i915_gem_object_wait_rendering_6446 i915_gem_object_wait_rendering 0 6446 NULL
103123 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL
103124 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
103125 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
103126 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
103127 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
103128 +mei_read_6507 mei_read 3 6507 NULL
103129 +__start_delalloc_inodes_6528 __start_delalloc_inodes 0 6528 NULL
103130 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
103131 +wdm_read_6549 wdm_read 3 6549 NULL
103132 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
103133 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
103134 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
103135 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
103136 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
103137 +btrfs_start_all_delalloc_inodes_6596 btrfs_start_all_delalloc_inodes 0 6596 NULL
103138 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
103139 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
103140 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
103141 +journal_dirty_metadata_6658 journal_dirty_metadata 0 6658 NULL
103142 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
103143 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3-0 6696 NULL
103144 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
103145 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
103146 +mpeg_read_6708 mpeg_read 3 6708 NULL
103147 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
103148 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
103149 +video_proc_write_6724 video_proc_write 3 6724 NULL
103150 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
103151 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
103152 +btrfs_inode_delayed_dir_index_count_6759 btrfs_inode_delayed_dir_index_count 0 6759 NULL
103153 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
103154 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
103155 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
103156 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
103157 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
103158 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
103159 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
103160 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
103161 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
103162 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
103163 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
103164 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
103165 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
103166 +dio_complete_6879 dio_complete 0-2-3 6879 NULL
103167 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
103168 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
103169 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
103170 +ext4_inode_bitmap_6902 ext4_inode_bitmap 0 6902 NULL
103171 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
103172 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
103173 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
103174 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
103175 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
103176 +__vxge_hw_mempool_create_6923 __vxge_hw_mempool_create 3-2-6 6923 NULL
103177 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
103178 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
103179 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
103180 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
103181 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
103182 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
103183 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 NULL nohasharray
103184 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 &i40e_dbg_dump_write_6973
103185 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
103186 +request_key_async_6990 request_key_async 4 6990 NULL
103187 +tpl_write_6998 tpl_write 3 6998 NULL
103188 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
103189 +log_wait_commit_7005 log_wait_commit 0 7005 NULL
103190 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
103191 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
103192 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
103193 +wimax_msg_7030 wimax_msg 4 7030 NULL
103194 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
103195 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
103196 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
103197 +event_enable_read_7074 event_enable_read 3 7074 NULL
103198 +ip_vs_sync_conn_7075 ip_vs_sync_conn 3 7075 NULL
103199 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
103200 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
103201 +check_header_7108 check_header 0 7108 NULL
103202 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
103203 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
103204 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
103205 +ipv6_recv_rxpmtu_7142 ipv6_recv_rxpmtu 3 7142 NULL
103206 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
103207 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
103208 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
103209 +ext3_xattr_ibody_list_7201 ext3_xattr_ibody_list 3-0 7201 NULL
103210 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
103211 +get_param_h_7247 get_param_h 0 7247 NULL
103212 +af_alg_make_sg_7254 af_alg_make_sg 3-0 7254 NULL
103213 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
103214 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
103215 +snd_mask_refine_7267 snd_mask_refine 0 7267 NULL
103216 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
103217 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5-0 7272 NULL
103218 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
103219 +get_string_7302 get_string 0 7302 NULL
103220 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
103221 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
103222 +mgmt_control_7349 mgmt_control 3 7349 NULL
103223 +max8998_irq_domain_map_7359 max8998_irq_domain_map 2 7359 NULL
103224 +i915_gem_do_execbuffer_7362 i915_gem_do_execbuffer 0 7362 NULL nohasharray
103225 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 &i915_gem_do_execbuffer_7362
103226 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
103227 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
103228 +schedule_timeout_7371 schedule_timeout 0 7371 NULL
103229 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
103230 +hweight_long_7388 hweight_long 1-0 7388 NULL
103231 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
103232 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
103233 +readb_7401 readb 0 7401 NULL
103234 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
103235 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
103236 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
103237 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
103238 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
103239 +ReadHSCX_7471 ReadHSCX 0 7471 NULL nohasharray
103240 +garp_request_join_7471 garp_request_join 4 7471 &ReadHSCX_7471
103241 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
103242 +iwl_mvm_power_dbgfs_read_7502 iwl_mvm_power_dbgfs_read 0 7502 NULL
103243 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
103244 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
103245 +array_zalloc_7519 array_zalloc 2-1 7519 NULL
103246 +btrfs_insert_xattr_item_7545 btrfs_insert_xattr_item 0 7545 NULL
103247 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
103248 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
103249 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
103250 +ext4_ext_insert_extent_7576 ext4_ext_insert_extent 0 7576 NULL
103251 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3-0 7579 NULL
103252 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3-0 7590 NULL
103253 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
103254 +create_dir_7614 create_dir 0 7614 NULL nohasharray
103255 +groups_alloc_7614 groups_alloc 1 7614 &create_dir_7614
103256 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
103257 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
103258 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 1-2 7685 NULL
103259 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
103260 +dev_write_7708 dev_write 3 7708 NULL
103261 +unmap_region_7709 unmap_region 1 7709 NULL
103262 +dbg_check_cats_7713 dbg_check_cats 0 7713 NULL
103263 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
103264 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
103265 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
103266 +paths_from_inode_7774 paths_from_inode 0 7774 NULL
103267 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
103268 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
103269 +bnx2_nvram_write_7790 bnx2_nvram_write 2-4 7790 NULL
103270 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
103271 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
103272 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
103273 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
103274 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL
103275 +btrfs_find_space_for_alloc_7876 btrfs_find_space_for_alloc 2 7876 NULL
103276 +config_desc_7878 config_desc 0 7878 NULL
103277 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
103278 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
103279 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
103280 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
103281 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
103282 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
103283 +compare_refs_7938 compare_refs 0 7938 NULL
103284 +fsnotify_7943 fsnotify 0 7943 NULL
103285 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
103286 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
103287 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
103288 +bch_btree_to_text_7960 bch_btree_to_text 2 7960 NULL
103289 +fixup_inode_link_count_8002 fixup_inode_link_count 0 8002 NULL
103290 +extend_or_restart_transaction_8008 extend_or_restart_transaction 0 8008 NULL
103291 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
103292 +vcs_read_8017 vcs_read 3 8017 NULL
103293 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
103294 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
103295 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
103296 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
103297 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
103298 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
103299 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
103300 +ext4_ext_map_blocks_8078 ext4_ext_map_blocks 0 8078 NULL
103301 +venus_lookup_8121 venus_lookup 4 8121 NULL
103302 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
103303 +xfs_iomap_prealloc_size_8141 xfs_iomap_prealloc_size 3 8141 NULL
103304 +dma_map_area_8178 dma_map_area 3-2-5-0 8178 NULL
103305 +ore_truncate_8181 ore_truncate 3 8181 NULL
103306 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
103307 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
103308 +update_cowonly_root_8200 update_cowonly_root 0 8200 NULL
103309 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
103310 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
103311 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
103312 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
103313 +play_iframe_8219 play_iframe 3 8219 NULL
103314 +create_log_8225 create_log 2 8225 NULL nohasharray
103315 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
103316 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
103317 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
103318 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
103319 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
103320 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
103321 +init_cdev_8274 init_cdev 1 8274 NULL
103322 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
103323 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
103324 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
103325 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
103326 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
103327 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
103328 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
103329 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
103330 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
103331 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
103332 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
103333 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
103334 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
103335 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
103336 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
103337 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
103338 +irq_create_mapping_8437 irq_create_mapping 2-0 8437 NULL
103339 +generic_bin_search_8440 generic_bin_search 0 8440 NULL
103340 +ring_wait_for_space_8457 ring_wait_for_space 0 8457 NULL
103341 +dir_changed_8471 dir_changed 0 8471 NULL
103342 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
103343 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
103344 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
103345 +dev_config_8506 dev_config 3 8506 NULL
103346 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
103347 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
103348 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
103349 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
103350 +user_on_off_8552 user_on_off 2 8552 NULL
103351 +profile_remove_8556 profile_remove 3 8556 NULL
103352 +remove_extent_backref_8559 remove_extent_backref 0 8559 NULL
103353 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
103354 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
103355 +tower_write_8580 tower_write 3 8580 NULL
103356 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
103357 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
103358 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
103359 +iommu_unmap_8624 iommu_unmap 2-0 8624 NULL
103360 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
103361 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
103362 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
103363 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
103364 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
103365 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
103366 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
103367 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
103368 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
103369 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
103370 +arcfb_write_8702 arcfb_write 3 8702 NULL
103371 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
103372 +init_header_8703 init_header 0 8703 &i_size_read_8703
103373 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
103374 +ctrl_out_8712 ctrl_out 5-3 8712 NULL
103375 +__create_free_space_inode_8724 __create_free_space_inode 0 8724 NULL
103376 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
103377 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
103378 +f_dupfd_8730 f_dupfd 1 8730 NULL
103379 +__create_irqs_8733 __create_irqs 2-1-0 8733 NULL
103380 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
103381 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
103382 +compound_order_8750 compound_order 0 8750 NULL
103383 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
103384 +yurex_write_8761 yurex_write 3 8761 NULL
103385 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
103386 +x32_arch_ptrace_8767 x32_arch_ptrace 3 8767 NULL
103387 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
103388 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
103389 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
103390 +aligned_nrpages_8791 aligned_nrpages 0-1-2 8791 NULL
103391 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
103392 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
103393 +intel_ring_begin_8808 intel_ring_begin 0 8808 NULL
103394 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
103395 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
103396 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
103397 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
103398 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
103399 +clear_bitset_8840 clear_bitset 2 8840 NULL
103400 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
103401 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
103402 +sk_memory_allocated_8882 sk_memory_allocated 0 8882 NULL
103403 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
103404 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
103405 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
103406 +xfs_contig_bits_8904 xfs_contig_bits 3-0 8904 NULL
103407 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
103408 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
103409 +write_file_ani_8918 write_file_ani 3 8918 NULL
103410 +layout_commit_8926 layout_commit 3 8926 NULL
103411 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
103412 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
103413 +lookup_zone_8956 lookup_zone 2 8956 NULL
103414 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
103415 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
103416 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
103417 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
103418 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
103419 +seq_open_net_8968 seq_open_net 4 8968 NULL nohasharray
103420 +vol_cdev_read_8968 vol_cdev_read 3 8968 &seq_open_net_8968
103421 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
103422 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3-8 8986 NULL
103423 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
103424 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
103425 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
103426 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
103427 +nla_put_9042 nla_put 3 9042 NULL
103428 +offset_il_node_9059 offset_il_node 0 9059 NULL
103429 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 5-3 9061 NULL
103430 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
103431 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
103432 +create_queues_9088 create_queues 3-2 9088 NULL
103433 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
103434 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
103435 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
103436 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110
103437 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
103438 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
103439 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
103440 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
103441 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
103442 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
103443 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
103444 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
103445 +__btrfs_add_delayed_deletion_item_9177 __btrfs_add_delayed_deletion_item 0 9177 NULL
103446 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
103447 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
103448 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
103449 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
103450 +get_pfn_9207 get_pfn 1 9207 NULL
103451 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
103452 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
103453 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
103454 +ext4_mark_iloc_dirty_9239 ext4_mark_iloc_dirty 0 9239 NULL
103455 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4-0 9256 NULL
103456 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
103457 +btrfs_search_slot_9264 btrfs_search_slot 0 9264 NULL
103458 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
103459 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
103460 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
103461 +flakey_status_9274 flakey_status 5 9274 NULL
103462 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
103463 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
103464 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
103465 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
103466 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
103467 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
103468 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
103469 +get_request_type_9393 get_request_type 0 9393 NULL nohasharray
103470 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2 9393 &get_request_type_9393
103471 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
103472 +read_9397 read 3 9397 NULL
103473 +btrfs_drop_extents_9423 btrfs_drop_extents 4-0 9423 NULL
103474 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
103475 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
103476 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
103477 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
103478 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
103479 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
103480 +btrfs_csum_file_blocks_9491 btrfs_csum_file_blocks 0 9491 NULL
103481 +crypt_status_9492 crypt_status 5 9492 NULL
103482 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
103483 +btrfs_add_delayed_data_ref_9508 btrfs_add_delayed_data_ref 0 9508 NULL
103484 +lp_write_9511 lp_write 3 9511 NULL
103485 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL
103486 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
103487 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
103488 +read_file_dma_9530 read_file_dma 3 9530 NULL
103489 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
103490 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
103491 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 NULL
103492 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
103493 +readl_9557 readl 0 9557 NULL
103494 +fw_node_create_9559 fw_node_create 2 9559 NULL
103495 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
103496 +kobj_map_9566 kobj_map 3-2 9566 NULL
103497 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
103498 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
103499 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
103500 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
103501 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
103502 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
103503 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 3-4 9635 NULL
103504 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
103505 +compat_sys_keyctl_9639 compat_sys_keyctl 4 9639 NULL
103506 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
103507 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
103508 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
103509 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
103510 +dns_query_9676 dns_query 3 9676 NULL
103511 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
103512 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
103513 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
103514 +fnb_9703 fnb 2-3-0 9703 NULL
103515 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
103516 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
103517 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
103518 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
103519 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
103520 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
103521 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
103522 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
103523 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
103524 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
103525 +ni_calculate_power_boost_limit_9757 ni_calculate_power_boost_limit 3 9757 NULL
103526 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
103527 +__alloc_percpu_9764 __alloc_percpu 2-1 9764 NULL
103528 +btrfs_write_and_wait_transaction_9768 btrfs_write_and_wait_transaction 0 9768 NULL
103529 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
103530 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
103531 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
103532 +parse_uac2_sample_rate_range_9801 parse_uac2_sample_rate_range 0 9801 NULL
103533 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
103534 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
103535 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
103536 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
103537 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
103538 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
103539 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
103540 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
103541 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
103542 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
103543 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
103544 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
103545 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 5-3 9895 NULL
103546 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
103547 +ext4_map_blocks_9916 ext4_map_blocks 0 9916 NULL
103548 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
103549 +tc3589x_reg_read_9940 tc3589x_reg_read 0 9940 NULL
103550 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
103551 +read_file_misc_9948 read_file_misc 3 9948 NULL
103552 +ext2_new_blocks_9954 ext2_new_blocks 2-0 9954 NULL
103553 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 4-3 9957 NULL
103554 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
103555 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
103556 +btrfs_add_link_9973 btrfs_add_link 5-0 9973 NULL
103557 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
103558 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
103559 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
103560 +iterate_inodes_from_logical_10037 iterate_inodes_from_logical 0 10037 NULL
103561 +vm_iomap_memory_10038 vm_iomap_memory 2 10038 NULL
103562 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
103563 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
103564 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
103565 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
103566 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
103567 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL nohasharray
103568 +offset_to_bit_10134 offset_to_bit 0-2-1-3 10134 &SyS_migrate_pages_10134
103569 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
103570 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
103571 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
103572 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
103573 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
103574 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
103575 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
103576 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
103577 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
103578 +register_ftrace_function_10218 register_ftrace_function 0 10218 NULL
103579 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
103580 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
103581 +insert_orphan_item_10249 insert_orphan_item 0 10249 NULL
103582 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
103583 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
103584 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
103585 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
103586 +ubi_leb_change_10289 ubi_leb_change 0-4 10289 NULL
103587 +read_emulate_10310 read_emulate 2-4 10310 NULL
103588 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
103589 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
103590 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
103591 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
103592 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
103593 +get_dump_page_10338 get_dump_page 1 10338 NULL
103594 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
103595 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
103596 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
103597 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
103598 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
103599 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
103600 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
103601 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
103602 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
103603 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
103604 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
103605 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
103606 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
103607 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
103608 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
103609 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
103610 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
103611 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
103612 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
103613 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL nohasharray
103614 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 &snd_pcm_lib_read_10536
103615 +SYSC_read_10545 SYSC_read 3 10545 NULL
103616 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
103617 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
103618 +otp_read_10594 otp_read 5-4-2 10594 NULL
103619 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
103620 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
103621 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
103622 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 NULL nohasharray
103623 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 &ubi_io_write_vid_hdr_10660
103624 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
103625 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
103626 +parport_write_10669 parport_write 0 10669 NULL
103627 +edge_write_10692 edge_write 4 10692 NULL
103628 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
103629 +inl_10708 inl 0 10708 NULL nohasharray
103630 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
103631 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
103632 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
103633 +spi_sync_10731 spi_sync 0 10731 NULL
103634 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
103635 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
103636 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
103637 +ttm_ref_object_add_10748 ttm_ref_object_add 0 10748 NULL
103638 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
103639 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
103640 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 2-4 10765 NULL
103641 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
103642 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
103643 +i915_gem_wait_for_error_10791 i915_gem_wait_for_error 0 10791 NULL
103644 +snd_mask_value_10794 snd_mask_value 0 10794 NULL
103645 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
103646 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
103647 +ida_get_new_above_10853 ida_get_new_above 2-0 10853 NULL
103648 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
103649 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
103650 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
103651 +drm_ht_insert_item_10877 drm_ht_insert_item 0 10877 NULL
103652 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL
103653 +get_scq_10897 get_scq 2 10897 NULL
103654 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
103655 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
103656 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
103657 +__copy_from_user_10918 __copy_from_user 3-0 10918 NULL
103658 +kobject_add_10919 kobject_add 0 10919 NULL
103659 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
103660 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
103661 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
103662 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
103663 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
103664 +lz4_compress_10986 lz4_compress 2 10986 NULL
103665 +do_switch_10994 do_switch 0 10994 NULL
103666 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
103667 +btrfs_add_delayed_extent_op_11000 btrfs_add_delayed_extent_op 0 11000 NULL
103668 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
103669 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
103670 +btrfs_find_space_for_alloc_11028 btrfs_find_space_for_alloc 2 11028 NULL
103671 +mb_find_next_bit_11037 mb_find_next_bit 0-2-3 11037 NULL
103672 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
103673 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8-0 11063 NULL
103674 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
103675 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
103676 +count_argc_11083 count_argc 0 11083 NULL
103677 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
103678 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
103679 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
103680 +page_offset_11120 page_offset 0 11120 NULL
103681 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
103682 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
103683 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
103684 +eb_lookup_objects_11163 eb_lookup_objects 0 11163 NULL
103685 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 4-3 11172 NULL
103686 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
103687 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
103688 +mmap_region_11247 mmap_region 0-2 11247 NULL
103689 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
103690 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
103691 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
103692 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
103693 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
103694 +btrfs_update_inode_fallback_11313 btrfs_update_inode_fallback 0 11313 NULL
103695 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
103696 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
103697 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
103698 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
103699 +construct_key_11329 construct_key 3 11329 NULL nohasharray
103700 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
103701 +next_segment_11330 next_segment 0-2-1 11330 NULL
103702 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
103703 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
103704 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 NULL nohasharray
103705 +sel_write_create_11353 sel_write_create 3 11353 &nl80211_send_mgmt_11353
103706 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
103707 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
103708 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
103709 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
103710 +__btrfs_add_delayed_insertion_item_11400 __btrfs_add_delayed_insertion_item 0 11400 NULL
103711 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
103712 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
103713 +str_to_user_11411 str_to_user 2 11411 NULL
103714 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
103715 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
103716 +relocate_entry_gtt_11416 relocate_entry_gtt 0 11416 NULL
103717 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
103718 +trace_options_read_11419 trace_options_read 3 11419 NULL
103719 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
103720 +__irq_set_trigger_11422 __irq_set_trigger 0 11422 NULL nohasharray
103721 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 &__irq_set_trigger_11422
103722 +prepare_image_11424 prepare_image 0 11424 NULL
103723 +ext3_xattr_block_list_11428 ext3_xattr_block_list 3 11428 NULL
103724 +bttv_read_11432 bttv_read 3 11432 NULL
103725 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
103726 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL
103727 +swp_offset_11475 swp_offset 0 11475 NULL
103728 +st_sensors_write_data_with_mask_11476 st_sensors_write_data_with_mask 3 11476 NULL
103729 +pci_set_power_state_11479 pci_set_power_state 0 11479 NULL nohasharray
103730 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 &pci_set_power_state_11479
103731 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
103732 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
103733 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
103734 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
103735 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
103736 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
103737 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
103738 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
103739 +posix_acl_create_masq_11567 posix_acl_create_masq 0 11567 NULL
103740 +qgroup_account_ref_step2_11575 qgroup_account_ref_step2 0 11575 NULL
103741 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
103742 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
103743 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
103744 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
103745 +btrfs_uuid_tree_add_11598 btrfs_uuid_tree_add 0 11598 NULL
103746 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
103747 +i915_gem_object_pin_11630 i915_gem_object_pin 0 11630 NULL
103748 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
103749 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
103750 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
103751 +slab_ksize_11664 slab_ksize 0 11664 NULL
103752 +__btrfs_run_delayed_items_11671 __btrfs_run_delayed_items 0 11671 NULL
103753 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
103754 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
103755 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
103756 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
103757 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
103758 +split_11691 split 2 11691 NULL
103759 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
103760 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
103761 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
103762 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
103763 +intel_map_page_11762 intel_map_page 4-3 11762 NULL
103764 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 NULL
103765 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
103766 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
103767 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
103768 +rtw_alloc_etherdev_11792 rtw_alloc_etherdev 1 11792 NULL
103769 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
103770 +umc_device_register_11824 umc_device_register 0 11824 NULL
103771 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
103772 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
103773 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
103774 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
103775 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
103776 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
103777 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
103778 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
103779 +ti_write_11916 ti_write 4 11916 NULL
103780 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103781 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103782 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103783 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
103784 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103785 +usc_InReg_11976 usc_InReg 0 11976 NULL nohasharray
103786 +split_node_11976 split_node 0 11976 &usc_InReg_11976
103787 +BeceemFlashBulkRead_11979 BeceemFlashBulkRead 0 11979 NULL
103788 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103789 +i40e_pci_sriov_configure_12011 i40e_pci_sriov_configure 2 12011 NULL
103790 +intel_init_ring_buffer_12016 intel_init_ring_buffer 0 12016 NULL
103791 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103792 +did_overwrite_ref_12046 did_overwrite_ref 0 12046 NULL
103793 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103794 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103795 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103796 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103797 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103798 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
103799 +twl6030_irq_map_12105 twl6030_irq_map 2 12105 NULL
103800 +i915_gem_evict_something_12118 i915_gem_evict_something 0 12118 NULL
103801 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103802 +set_powered_12129 set_powered 4 12129 NULL
103803 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103804 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103805 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103806 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103807 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
103808 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103809 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103810 +ocfs2_local_alloc_new_window_12153 ocfs2_local_alloc_new_window 0 12153 NULL
103811 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103812 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103813 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
103814 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103815 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103816 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103817 +scaled_div_12201 scaled_div 2-1-0 12201 NULL
103818 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103819 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103820 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103821 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
103822 +kvirt_to_pa_12247 kvirt_to_pa 0 12247 NULL
103823 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103824 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103825 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103826 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103827 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 NULL nohasharray
103828 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 &il_dbgfs_nvm_read_12288
103829 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103830 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
103831 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103832 +btrfs_lookup_file_extent_12341 btrfs_lookup_file_extent 0 12341 NULL
103833 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103834 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103835 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103836 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103837 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL nohasharray
103838 +populate_dir_12391 populate_dir 0 12391 &btrfs_file_extent_ram_bytes_12391
103839 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL nohasharray
103840 +ext4_bg_num_gdb_nometa_12413 ext4_bg_num_gdb_nometa 0 12413 &ntfs_get_size_for_mapping_pairs_12413
103841 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103842 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103843 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
103844 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103845 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103846 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103847 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103848 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
103849 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103850 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103851 +ceph_osdc_wait_request_12572 ceph_osdc_wait_request 0 12572 NULL
103852 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103853 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103854 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103855 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
103856 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103857 +ipath_mmap_mem_12625 ipath_mmap_mem 3 12625 NULL
103858 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
103859 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103860 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103861 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103862 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
103863 +wb_create_12651 wb_create 1 12651 NULL
103864 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
103865 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103866 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103867 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103868 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
103869 +ext4_bg_num_gdb_meta_12702 ext4_bg_num_gdb_meta 0 12702 NULL
103870 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
103871 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103872 +ivtv_write_12721 ivtv_write 3 12721 NULL
103873 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103874 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103875 +run_delayed_data_ref_12749 run_delayed_data_ref 0 12749 NULL
103876 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103877 +listxattr_12769 listxattr 3 12769 NULL
103878 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103879 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2-0 12793 NULL
103880 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103881 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103882 +tlv_put_uuid_12824 tlv_put_uuid 0 12824 NULL
103883 +readq_12825 readq 0 12825 NULL
103884 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
103885 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103886 +spidev_sync_12842 spidev_sync 0 12842 NULL
103887 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103888 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103889 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103890 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103891 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103892 +free_tind_blocks_12926 free_tind_blocks 0 12926 NULL
103893 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103894 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
103895 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103896 +bm_status_write_12964 bm_status_write 3 12964 NULL
103897 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103898 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103899 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103900 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103901 +btrfs_write_dirty_block_groups_13030 btrfs_write_dirty_block_groups 0 13030 NULL
103902 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103903 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
103904 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103905 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 NULL nohasharray
103906 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 &ptlrpc_lprocfs_threads_min_seq_write_13060
103907 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103908 +_ocfs2_free_suballoc_bits_13085 _ocfs2_free_suballoc_bits 0 13085 NULL
103909 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103910 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103911 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3-0 13100 NULL
103912 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
103913 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
103914 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103915 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103916 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103917 +blk_update_request_13146 blk_update_request 3 13146 NULL
103918 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103919 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103920 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103921 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103922 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103923 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103924 +comedi_read_13199 comedi_read 3 13199 NULL
103925 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103926 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103927 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
103928 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103929 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103930 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103931 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 NULL
103932 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103933 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103934 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
103935 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103936 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103937 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103938 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103939 +sd_major_13294 sd_major 0-1 13294 NULL
103940 +kempld_read16_13297 kempld_read16 0 13297 NULL
103941 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103942 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103943 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103944 +get_bits_13353 get_bits 0-2 13353 NULL
103945 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
103946 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103947 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103948 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
103949 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
103950 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
103951 +BcmSetActiveSection_13389 BcmSetActiveSection 0 13389 NULL
103952 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
103953 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103954 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
103955 +keyring_read_13438 keyring_read 3 13438 NULL
103956 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
103957 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103958 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
103959 +data_read_13494 data_read 3 13494 NULL
103960 +i915_switch_context_13498 i915_switch_context 0 13498 NULL
103961 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
103962 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2-0 13512 NULL
103963 +core_status_13515 core_status 4 13515 NULL
103964 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103965 +bm_init_13529 bm_init 2 13529 NULL
103966 +kvm_get_cr8_13538 kvm_get_cr8 0 13538 NULL
103967 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1-2 13540 NULL nohasharray
103968 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 &SYSC_remap_file_pages_13540
103969 +__btrfs_alloc_chunk_13554 __btrfs_alloc_chunk 0 13554 NULL
103970 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
103971 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103972 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103973 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103974 +cache_write_13589 cache_write 3 13589 NULL
103975 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
103976 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103977 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103978 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103979 +packet_snd_13634 packet_snd 3 13634 NULL
103980 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103981 +cache_downcall_13666 cache_downcall 3 13666 NULL
103982 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0-4 13682 NULL
103983 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
103984 +usb_get_string_13693 usb_get_string 0 13693 NULL
103985 +atomic_cmpxchg_13700 atomic_cmpxchg 0 13700 NULL
103986 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103987 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
103988 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103989 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103990 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103991 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103992 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103993 +random_read_13815 random_read 3 13815 NULL
103994 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
103995 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103996 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103997 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
103998 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
103999 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
104000 +btrfs_insert_empty_item_13885 btrfs_insert_empty_item 0 13885 NULL
104001 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
104002 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
104003 +window_alignment_13895 window_alignment 0 13895 NULL
104004 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
104005 +is_inode_existent_13913 is_inode_existent 0 13913 NULL
104006 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
104007 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
104008 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
104009 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
104010 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
104011 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
104012 +qib_mmap_mem_13947 qib_mmap_mem 3 13947 NULL
104013 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
104014 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
104015 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
104016 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
104017 +qcam_read_13977 qcam_read 3 13977 NULL
104018 +dsp_read_13980 dsp_read 2 13980 NULL
104019 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
104020 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
104021 +create_files_14003 create_files 0 14003 NULL
104022 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
104023 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
104024 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
104025 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
104026 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
104027 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
104028 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
104029 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
104030 +ovs_flow_actions_alloc_14072 ovs_flow_actions_alloc 1 14072 NULL
104031 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
104032 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
104033 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
104034 +intel_ring_wait_seqno_14107 intel_ring_wait_seqno 0 14107 NULL
104035 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
104036 +ntfs_rl_replace_14136 ntfs_rl_replace 4-2 14136 NULL
104037 +qfq_ffs_14139 qfq_ffs 2 14139 NULL
104038 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
104039 +em_canid_change_14150 em_canid_change 3 14150 NULL
104040 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
104041 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
104042 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL
104043 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
104044 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
104045 +do_splice_14196 do_splice 5 14196 NULL
104046 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
104047 +alloc_async_14208 alloc_async 1 14208 NULL
104048 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
104049 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
104050 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
104051 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
104052 +ext4_journal_restart_14251 ext4_journal_restart 0 14251 NULL
104053 +will_overwrite_ref_14252 will_overwrite_ref 0 14252 NULL
104054 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
104055 +rr_status_14293 rr_status 5 14293 NULL
104056 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
104057 +__readl_14308 __readl 0 14308 NULL
104058 +send_chown_14309 send_chown 0 14309 NULL
104059 +i915_gem_object_finish_gpu_14312 i915_gem_object_finish_gpu 0 14312 NULL
104060 +oo_objects_14319 oo_objects 0 14319 NULL
104061 +ww_mutex_deadlock_injection_14321 ww_mutex_deadlock_injection 0 14321 NULL
104062 +ll_get_user_pages_14328 ll_get_user_pages 2-3-0 14328 NULL
104063 +down_write_failed_14331 down_write_failed 2 14331 NULL
104064 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
104065 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
104066 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
104067 +btrfs_set_inode_index_14379 btrfs_set_inode_index 0 14379 NULL
104068 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
104069 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
104070 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
104071 +first_logical_byte_14403 first_logical_byte 0 14403 NULL
104072 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
104073 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
104074 +qib_user_sdma_page_length_14432 qib_user_sdma_page_length 0-2-1 14432 NULL
104075 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
104076 +block_size_14443 block_size 0 14443 NULL
104077 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
104078 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
104079 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
104080 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
104081 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
104082 +efx_mdio_check_mmds_14486 efx_mdio_check_mmds 2 14486 NULL nohasharray
104083 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 &efx_mdio_check_mmds_14486
104084 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
104085 +ep0_write_14536 ep0_write 3 14536 NULL nohasharray
104086 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 &ep0_write_14536
104087 +register_trace_sched_switch_14545 register_trace_sched_switch 0 14545 NULL
104088 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
104089 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
104090 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
104091 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
104092 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
104093 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
104094 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
104095 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
104096 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
104097 +dbJoin_14644 dbJoin 0 14644 NULL
104098 +profile_replace_14652 profile_replace 3 14652 NULL
104099 +add_to_page_cache_locked_14668 add_to_page_cache_locked 0 14668 NULL
104100 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
104101 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
104102 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
104103 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
104104 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
104105 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
104106 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
104107 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
104108 +cgroup_path_14713 cgroup_path 3 14713 NULL
104109 +get_bio_block_14714 get_bio_block 0 14714 NULL
104110 +vfd_write_14717 vfd_write 3 14717 NULL
104111 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
104112 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
104113 +raid1_resize_14740 raid1_resize 2 14740 NULL
104114 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
104115 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
104116 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
104117 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
104118 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
104119 +keys_proc_write_14792 keys_proc_write 3 14792 NULL
104120 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
104121 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
104122 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
104123 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
104124 +changed_cb_14819 changed_cb 0 14819 NULL
104125 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
104126 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
104127 +lcd_write_14857 lcd_write 3 14857 NULL
104128 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
104129 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
104130 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
104131 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
104132 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2-0 14910 NULL
104133 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
104134 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
104135 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
104136 +range_to_mtrr_14940 range_to_mtrr 2 14940 NULL
104137 +queue_cnt_14951 queue_cnt 0 14951 NULL
104138 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
104139 +i915_vma_unbind_14954 i915_vma_unbind 0 14954 NULL
104140 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
104141 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
104142 +setkey_14987 setkey 3 14987 NULL nohasharray
104143 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
104144 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
104145 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
104146 +irq_get_next_irq_15053 irq_get_next_irq 1-0 15053 NULL
104147 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
104148 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
104149 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
104150 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5-0 15072 NULL
104151 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
104152 +ceph_calc_ceph_pg_15075 ceph_calc_ceph_pg 0 15075 NULL
104153 +perf_trace_sched_stat_runtime_15115 perf_trace_sched_stat_runtime 3 15115 NULL
104154 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
104155 +start_port_15124 start_port 0 15124 NULL
104156 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
104157 +iwl_dbgfs_sta_drain_write_15167 iwl_dbgfs_sta_drain_write 3 15167 NULL
104158 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
104159 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
104160 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
104161 +reserve_resources_15194 reserve_resources 3 15194 NULL
104162 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
104163 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
104164 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
104165 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
104166 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
104167 +simple_strtol_15273 simple_strtol 0 15273 NULL
104168 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
104169 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
104170 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
104171 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
104172 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-3-5 15330 NULL
104173 +bfloat_mantissa_15334 bfloat_mantissa 0 15334 NULL
104174 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
104175 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
104176 +ioread16_15342 ioread16 0 15342 NULL
104177 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
104178 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
104179 +count_inode_extrefs_15366 count_inode_extrefs 0 15366 NULL
104180 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
104181 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
104182 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
104183 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
104184 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
104185 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
104186 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
104187 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
104188 +get_modalias_15406 get_modalias 2 15406 NULL
104189 +blockdev_direct_IO_15408 blockdev_direct_IO 0-5 15408 NULL
104190 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
104191 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
104192 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL
104193 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
104194 +memweight_15450 memweight 2 15450 NULL
104195 +vmalloc_15464 vmalloc 1 15464 NULL
104196 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
104197 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
104198 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
104199 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
104200 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
104201 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
104202 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
104203 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
104204 +persistent_status_15574 persistent_status 4 15574 NULL
104205 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
104206 +cl_io_submit_sync_15579 cl_io_submit_sync 0 15579 NULL
104207 +vme_user_write_15587 vme_user_write 3 15587 NULL
104208 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7-0 15595 NULL
104209 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
104210 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
104211 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
104212 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
104213 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 4-2 15642 NULL nohasharray
104214 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
104215 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
104216 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
104217 +fs_path_add_15648 fs_path_add 3-0 15648 NULL
104218 +xsd_read_15653 xsd_read 3 15653 NULL
104219 +unix_bind_15668 unix_bind 3 15668 NULL
104220 +SyS_connect_15674 SyS_connect 3 15674 NULL nohasharray
104221 +dm_read_15674 dm_read 3 15674 &SyS_connect_15674
104222 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
104223 +i915_gem_object_set_to_cpu_domain_15705 i915_gem_object_set_to_cpu_domain 0 15705 NULL
104224 +ocfs2_split_tree_15716 ocfs2_split_tree 5-0 15716 NULL
104225 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
104226 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
104227 +ftrace_profile_init_cpu_15761 ftrace_profile_init_cpu 0 15761 NULL
104228 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1-0 15762 NULL
104229 +i915_gem_init_seqno_15793 i915_gem_init_seqno 0 15793 NULL
104230 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
104231 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
104232 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
104233 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
104234 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
104235 +table_size_15851 table_size 0-1-2 15851 NULL
104236 +ubi_io_write_15870 ubi_io_write 0-5-4 15870 NULL nohasharray
104237 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
104238 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
104239 +profile_pc_15887 profile_pc 0 15887 NULL
104240 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
104241 +native_read_msr_15905 native_read_msr 0 15905 NULL
104242 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
104243 +power_read_15939 power_read 3 15939 NULL
104244 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
104245 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
104246 +tfrc_calc_x_15975 tfrc_calc_x 2-1 15975 NULL
104247 +frame_alloc_15981 frame_alloc 4 15981 NULL
104248 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
104249 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
104250 +i915_gem_object_pin_16032 i915_gem_object_pin 0 16032 NULL
104251 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
104252 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
104253 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
104254 +ocfs2_sync_local_to_main_16076 ocfs2_sync_local_to_main 0 16076 NULL
104255 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
104256 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
104257 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
104258 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
104259 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
104260 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
104261 +fsm_init_16134 fsm_init 2 16134 NULL
104262 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
104263 +update_block_group_16155 update_block_group 0 16155 NULL
104264 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
104265 +mapping_level_16188 mapping_level 2 16188 NULL
104266 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
104267 +tcp_syn_options_16197 tcp_syn_options 0 16197 NULL
104268 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
104269 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
104270 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
104271 +create_table_16213 create_table 2 16213 NULL
104272 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
104273 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
104274 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
104275 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL nohasharray
104276 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &i40e_dbg_dump_read_16247
104277 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
104278 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
104279 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
104280 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
104281 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
104282 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
104283 +nand_bch_init_16280 nand_bch_init 2-3 16280 &drbd_setsockopt_16280
104284 +account_16283 account 0-4-2 16283 NULL nohasharray
104285 +mirror_status_16283 mirror_status 5 16283 &account_16283
104286 +retry_instruction_16285 retry_instruction 2 16285 NULL
104287 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
104288 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
104289 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
104290 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
104291 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
104292 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
104293 +wb_map_16301 wb_map 2 16301 NULL
104294 +kvm_handle_hva_range_16312 kvm_handle_hva_range 3-2 16312 NULL
104295 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
104296 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
104297 +btrfs_insert_item_16357 btrfs_insert_item 0 16357 NULL
104298 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
104299 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
104300 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
104301 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
104302 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
104303 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
104304 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
104305 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 0 16452 NULL
104306 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
104307 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
104308 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
104309 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
104310 +add_qgroup_item_16492 add_qgroup_item 0 16492 NULL
104311 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
104312 +filemap_write_and_wait_16506 filemap_write_and_wait 0 16506 NULL
104313 +start_this_handle_16519 start_this_handle 0 16519 NULL
104314 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
104315 +raid10_resize_16537 raid10_resize 2 16537 NULL
104316 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
104317 +perf_event_set_period_16574 perf_event_set_period 2-3 16574 NULL
104318 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
104319 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
104320 +btrfs_insert_orphan_item_16602 btrfs_insert_orphan_item 0 16602 NULL
104321 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
104322 +btrfs_end_transaction_16610 btrfs_end_transaction 0 16610 NULL
104323 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
104324 +btrfs_wait_marked_extents_16615 btrfs_wait_marked_extents 0 16615 NULL
104325 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
104326 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
104327 +packet_recv_error_16669 packet_recv_error 3 16669 NULL
104328 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
104329 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
104330 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
104331 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
104332 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
104333 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
104334 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
104335 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
104336 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
104337 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
104338 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
104339 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
104340 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
104341 +st_write_16874 st_write 3 16874 NULL
104342 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
104343 +transport_init_session_tags_16878 transport_init_session_tags 1-2 16878 NULL
104344 +ext4_ext_zeroout_16895 ext4_ext_zeroout 0 16895 NULL
104345 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
104346 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
104347 +_sp2d_alloc_16944 _sp2d_alloc 3-2-1 16944 NULL
104348 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
104349 +wrm_16966 wrm 0 16966 NULL
104350 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
104351 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
104352 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
104353 +snd_mask_refine_first_17026 snd_mask_refine_first 0 17026 NULL
104354 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
104355 +btrfs_unlink_inode_17043 btrfs_unlink_inode 0 17043 NULL
104356 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
104357 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
104358 +__copy_user_nocache_17065 __copy_user_nocache 0 17065 NULL
104359 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
104360 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
104361 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
104362 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
104363 +entry_length_17093 entry_length 0 17093 NULL
104364 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
104365 +write_mem_17114 write_mem 3 17114 NULL
104366 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
104367 +wrmaltWithLock_17139 wrmaltWithLock 0 17139 NULL
104368 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
104369 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
104370 +sep_read_17161 sep_read 3 17161 NULL
104371 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
104372 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
104373 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
104374 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 NULL nohasharray
104375 +access_remote_vm_17189 access_remote_vm 0-4-2 17189 &ocfs2_flock_handle_signal_17189 nohasharray
104376 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189
104377 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
104378 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
104379 +sync_request_17208 sync_request 2 17208 NULL
104380 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
104381 +send_write_or_clone_17241 send_write_or_clone 0 17241 NULL
104382 +to_oblock_17254 to_oblock 0-1 17254 NULL
104383 +unpack_value_17259 unpack_value 1 17259 NULL
104384 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
104385 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
104386 +alloc_reserved_file_extent_17267 alloc_reserved_file_extent 0 17267 NULL
104387 +alloc_ep_17269 alloc_ep 1 17269 NULL
104388 +hw_test_and_write_17271 hw_test_and_write 3 17271 NULL
104389 +pg_read_17276 pg_read 3 17276 NULL
104390 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
104391 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
104392 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
104393 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
104394 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
104395 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
104396 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
104397 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
104398 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
104399 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
104400 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
104401 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
104402 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
104403 +compat_sys_ppoll_17430 compat_sys_ppoll 2 17430 NULL
104404 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
104405 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
104406 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
104407 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
104408 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
104409 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
104410 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
104411 +lookup_tree_block_ref_17494 lookup_tree_block_ref 0 17494 NULL
104412 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
104413 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
104414 +qp_free_res_17541 qp_free_res 5 17541 NULL
104415 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
104416 +__copy_to_user_17551 __copy_to_user 3-0 17551 NULL
104417 +copy_from_user_17559 copy_from_user 3-0 17559 NULL
104418 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
104419 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
104420 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
104421 +__inode_info_17603 __inode_info 0 17603 NULL
104422 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
104423 +osst_execute_17607 osst_execute 7-6 17607 NULL
104424 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
104425 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
104426 +dma_map_page_17628 dma_map_page 0 17628 NULL
104427 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
104428 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
104429 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
104430 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
104431 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
104432 +kernel_write_17665 kernel_write 3 17665 NULL
104433 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
104434 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
104435 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2-0 17693 NULL
104436 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 NULL nohasharray
104437 +venus_rename_17707 venus_rename 4-5 17707 &__einj_error_trigger_17707
104438 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
104439 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
104440 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
104441 +dgap_do_fep_load_17765 dgap_do_fep_load 3 17765 NULL
104442 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
104443 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
104444 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
104445 +perf_clock_17787 perf_clock 0 17787 NULL
104446 +ubifs_leb_change_17789 ubifs_leb_change 0-4 17789 NULL
104447 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL nohasharray
104448 +shrink_slab_node_17794 shrink_slab_node 3-4 17794 &get_unaligned_be64_17794
104449 +bkey_to_cacheline_17811 bkey_to_cacheline 0 17811 NULL
104450 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
104451 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
104452 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
104453 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
104454 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
104455 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
104456 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
104457 +orinoco_set_key_17878 orinoco_set_key 7-5 17878 NULL nohasharray
104458 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
104459 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
104460 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
104461 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
104462 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
104463 +recover_head_17904 recover_head 3 17904 NULL
104464 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
104465 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
104466 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
104467 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
104468 +ufs_free_blocks_17963 ufs_free_blocks 3-2 17963 NULL nohasharray
104469 +tlv_put_u64_17963 tlv_put_u64 0 17963 &ufs_free_blocks_17963
104470 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
104471 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
104472 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
104473 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
104474 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
104475 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
104476 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
104477 +fill_read_18019 fill_read 0 18019 NULL
104478 +o2hb_highest_node_18034 o2hb_highest_node 2-0 18034 NULL
104479 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
104480 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
104481 +cryptd_alloc_instance_18048 cryptd_alloc_instance 3-2 18048 NULL
104482 +find_next_inuse_18051 find_next_inuse 2-3-0 18051 NULL
104483 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
104484 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
104485 +fpregs_get_18066 fpregs_get 4 18066 NULL
104486 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
104487 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
104488 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
104489 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
104490 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
104491 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
104492 +svc_getnl_18120 svc_getnl 0 18120 NULL
104493 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
104494 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
104495 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
104496 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
104497 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
104498 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
104499 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
104500 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
104501 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
104502 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
104503 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
104504 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
104505 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
104506 +__sysfs_add_one_18258 __sysfs_add_one 0 18258 NULL
104507 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
104508 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
104509 +alloc_ring_18278 alloc_ring 4-2 18278 NULL
104510 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
104511 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
104512 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
104513 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
104514 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
104515 +um_idi_write_18293 um_idi_write 3 18293 NULL
104516 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
104517 +vga_r_18310 vga_r 0 18310 NULL
104518 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
104519 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
104520 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
104521 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
104522 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
104523 +__inorder_to_tree_18329 __inorder_to_tree 0-3-1 18329 NULL
104524 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
104525 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
104526 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
104527 +SyS_process_vm_readv_18366 SyS_process_vm_readv 5-3 18366 NULL
104528 +ep_io_18367 ep_io 0 18367 NULL
104529 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
104530 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
104531 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
104532 +btrfs_update_inode_18394 btrfs_update_inode 0 18394 NULL
104533 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
104534 +__video_register_device_18399 __video_register_device 3 18399 NULL
104535 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
104536 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
104537 +btrfs_rmap_block_18403 btrfs_rmap_block 0 18403 NULL
104538 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
104539 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
104540 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
104541 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
104542 +btrfs_uuid_tree_lookup_18451 btrfs_uuid_tree_lookup 0 18451 NULL
104543 +flash_dev_cache_miss_18454 flash_dev_cache_miss 4 18454 NULL
104544 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
104545 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
104546 +pcibios_window_alignment_18460 pcibios_window_alignment 0 18460 NULL
104547 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
104548 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
104549 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
104550 +r600_texture_size_18487 r600_texture_size 4-5-6 18487 NULL nohasharray
104551 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 &r600_texture_size_18487
104552 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL nohasharray
104553 +remap_pmd_range_18501 remap_pmd_range 3-4-5 18501 &btrfs_fiemap_18501
104554 +i915_gem_object_wait_fence_18508 i915_gem_object_wait_fence 0 18508 NULL
104555 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
104556 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL
104557 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
104558 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
104559 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
104560 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
104561 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
104562 +vb2_streamon_18562 vb2_streamon 0 18562 NULL
104563 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
104564 +debug_output_18575 debug_output 3 18575 NULL
104565 +is_extent_unchanged_18576 is_extent_unchanged 0 18576 NULL
104566 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
104567 +numa_node_id_18596 numa_node_id 0 18596 NULL
104568 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
104569 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
104570 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
104571 +audio_get_endpoint_req_18624 audio_get_endpoint_req 0 18624 NULL
104572 +from_buffer_18625 from_buffer 3 18625 NULL
104573 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
104574 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
104575 +unmap_page_18665 unmap_page 2-3 18665 NULL
104576 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
104577 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
104578 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
104579 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
104580 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
104581 +ocfs2_trim_extent_18711 ocfs2_trim_extent 3-4 18711 NULL
104582 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
104583 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
104584 +ext4_es_insert_extent_18729 ext4_es_insert_extent 0 18729 NULL
104585 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
104586 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
104587 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
104588 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
104589 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
104590 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
104591 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
104592 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
104593 +prealloc_18800 prealloc 0 18800 NULL
104594 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
104595 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
104596 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
104597 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
104598 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
104599 +iterate_inode_refs_18846 iterate_inode_refs 0 18846 NULL
104600 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
104601 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
104602 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL nohasharray
104603 +heads_to_leaves_18869 heads_to_leaves 2-0 18869 &ieee80211_if_read_element_ttl_18869
104604 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
104605 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
104606 +overwrite_item_18896 overwrite_item 0 18896 NULL
104607 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
104608 +ext4_block_in_group_18922 ext4_block_in_group 2 18922 NULL
104609 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
104610 +create_pending_snapshot_18936 create_pending_snapshot 0 18936 NULL
104611 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
104612 +regcache_sync_block_18963 regcache_sync_block 4-3 18963 NULL
104613 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
104614 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
104615 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
104616 +get_inode_path_18988 get_inode_path 0 18988 NULL
104617 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL nohasharray
104618 +test_check_exists_19001 test_check_exists 2 19001 &find_dirtiest_idx_leb_19001
104619 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
104620 +huge_page_size_19008 huge_page_size 0 19008 NULL
104621 +push_leaf_right_19017 push_leaf_right 0 19017 NULL
104622 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
104623 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL
104624 +revalidate_19043 revalidate 2 19043 NULL
104625 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
104626 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL
104627 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
104628 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
104629 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
104630 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
104631 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
104632 +ATOMIC_SUB_RETURN_19115 ATOMIC_SUB_RETURN 2 19115 NULL
104633 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
104634 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
104635 +btrfs_run_delayed_refs_19137 btrfs_run_delayed_refs 0 19137 NULL
104636 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
104637 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
104638 +ext3_reserve_inode_write_19163 ext3_reserve_inode_write 0 19163 NULL
104639 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
104640 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
104641 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
104642 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3-0 19214 NULL
104643 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
104644 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
104645 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
104646 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
104647 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
104648 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
104649 +ucma_query_19260 ucma_query 4 19260 NULL
104650 +write_one_cache_group_19261 write_one_cache_group 0 19261 NULL
104651 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
104652 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 NULL
104653 +qc_capture_19298 qc_capture 3 19298 NULL
104654 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 4-3 19303 NULL
104655 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
104656 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
104657 +debug_read_19322 debug_read 3 19322 NULL
104658 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
104659 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL nohasharray
104660 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 &cfg80211_inform_bss_19332
104661 +closure_sub_19359 closure_sub 2 19359 NULL
104662 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
104663 +read_zero_19366 read_zero 3 19366 NULL
104664 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
104665 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
104666 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
104667 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
104668 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
104669 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
104670 +__phys_addr_19434 __phys_addr 0 19434 NULL
104671 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
104672 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
104673 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
104674 +sky2_read16_19475 sky2_read16 0 19475 NULL
104675 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
104676 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
104677 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
104678 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 NULL nohasharray
104679 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 &cfc_write_array_to_buffer_19529
104680 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
104681 +howmany_64_19548 howmany_64 2 19548 NULL
104682 +btrfs_xattr_security_init_19553 btrfs_xattr_security_init 0 19553 NULL
104683 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
104684 +kernel_read_19559 kernel_read 4-0 19559 NULL
104685 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
104686 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL
104687 +nfsd_read_19568 nfsd_read 5 19568 NULL
104688 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
104689 +bm_status_read_19583 bm_status_read 3 19583 NULL
104690 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
104691 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
104692 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
104693 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
104694 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
104695 +i915_gem_object_bind_to_gtt_19682 i915_gem_object_bind_to_gtt 0 19682 NULL
104696 +bio_detain_19690 bio_detain 2 19690 NULL
104697 +btrfs_del_inode_extref_19692 btrfs_del_inode_extref 0 19692 NULL
104698 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
104699 +btrfs_write_marked_extents_19720 btrfs_write_marked_extents 0 19720 NULL
104700 +read_reg_19723 read_reg 0 19723 NULL
104701 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
104702 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4-0 19736 NULL
104703 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
104704 +p9_client_read_19750 p9_client_read 0-5 19750 NULL
104705 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
104706 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
104707 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
104708 +readhscx_19769 readhscx 0 19769 NULL
104709 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
104710 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
104711 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
104712 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
104713 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
104714 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
104715 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
104716 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
104717 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
104718 +__nla_put_19857 __nla_put 3 19857 NULL
104719 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
104720 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
104721 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
104722 +mangle_name_19923 mangle_name 0 19923 NULL
104723 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
104724 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
104725 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
104726 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
104727 +alloc_elfnotes_buf_19974 alloc_elfnotes_buf 1 19974 NULL
104728 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
104729 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
104730 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL
104731 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
104732 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL
104733 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
104734 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
104735 +mlx5_ib_db_map_user_20037 mlx5_ib_db_map_user 2 20037 NULL
104736 +btrfs_block_rsv_migrate_20050 btrfs_block_rsv_migrate 0 20050 NULL
104737 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
104738 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
104739 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4 20067 NULL
104740 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
104741 +target_message_20072 target_message 2 20072 NULL
104742 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
104743 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
104744 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
104745 +team_options_register_20091 team_options_register 3 20091 NULL
104746 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
104747 +read_int_20098 read_int 0 20098 NULL
104748 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
104749 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
104750 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
104751 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
104752 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
104753 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
104754 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
104755 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
104756 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
104757 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
104758 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
104759 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
104760 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
104761 +resource_size_20256 resource_size 0 20256 NULL
104762 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
104763 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
104764 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
104765 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
104766 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
104767 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
104768 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
104769 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
104770 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
104771 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
104772 +block_read_full_page_20380 block_read_full_page 0 20380 NULL
104773 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL nohasharray
104774 +read_7220_creg32_20394 read_7220_creg32 0 20394 &snd_nm256_readl_20394
104775 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
104776 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3-4 20399 &__kfifo_from_user_20399
104777 +btrfs_set_acl_20440 btrfs_set_acl 0 20440 NULL
104778 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
104779 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
104780 +read_buf_20469 read_buf 2 20469 NULL
104781 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
104782 +fast_user_write_20494 fast_user_write 5 20494 NULL
104783 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL
104784 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
104785 +link_free_space_20512 link_free_space 0 20512 NULL
104786 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 3-2 20517 NULL
104787 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
104788 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
104789 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
104790 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
104791 +venus_create_20555 venus_create 4 20555 NULL
104792 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
104793 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
104794 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL nohasharray
104795 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 &batadv_tt_append_diff_20588
104796 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
104797 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
104798 +lirc_write_20604 lirc_write 3 20604 NULL
104799 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
104800 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
104801 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
104802 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
104803 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
104804 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
104805 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
104806 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL nohasharray
104807 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 &snd_hdsp_playback_copy_20676
104808 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
104809 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
104810 +cpumask_size_20683 cpumask_size 0 20683 NULL
104811 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
104812 +gru_vtop_20689 gru_vtop 2 20689 NULL
104813 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
104814 +i915_gem_obj_ggtt_pin_20698 i915_gem_obj_ggtt_pin 0 20698 NULL
104815 +__maestro_read_20700 __maestro_read 0 20700 NULL
104816 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
104817 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
104818 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
104819 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
104820 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
104821 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
104822 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
104823 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
104824 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
104825 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
104826 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
104827 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
104828 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
104829 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
104830 +ext4_convert_unwritten_extents_endio_20812 ext4_convert_unwritten_extents_endio 0 20812 NULL
104831 +strndup_user_20819 strndup_user 2 20819 NULL
104832 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
104833 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
104834 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
104835 +btrfs_orphan_add_20840 btrfs_orphan_add 0 20840 NULL
104836 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
104837 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
104838 +get_name_20855 get_name 4 20855 NULL
104839 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
104840 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
104841 +srq_free_res_20868 srq_free_res 5 20868 NULL
104842 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
104843 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
104844 +rb_simple_write_20890 rb_simple_write 3 20890 NULL
104845 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
104846 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
104847 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
104848 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
104849 +htable_bits_20933 htable_bits 0 20933 NULL
104850 +check_eofblocks_fl_20942 check_eofblocks_fl 0 20942 NULL
104851 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
104852 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
104853 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
104854 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
104855 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
104856 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
104857 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
104858 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4-0 21001 NULL
104859 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
104860 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
104861 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
104862 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
104863 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
104864 +btrfs_insert_root_21061 btrfs_insert_root 0 21061 NULL
104865 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
104866 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
104867 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
104868 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094
104869 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
104870 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
104871 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
104872 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
104873 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
104874 +chunk_size_21146 chunk_size 0 21146 NULL
104875 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
104876 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
104877 +btrfs_add_root_ref_21186 btrfs_add_root_ref 0 21186 NULL
104878 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
104879 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
104880 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
104881 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4-0 21220 NULL
104882 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
104883 +SyS_mlock_21238 SyS_mlock 1-2 21238 NULL
104884 +input_ff_create_21240 input_ff_create 2 21240 NULL
104885 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
104886 +fru_length_21257 fru_length 0 21257 NULL
104887 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
104888 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
104889 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
104890 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
104891 +add_res_range_21310 add_res_range 4 21310 NULL
104892 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
104893 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
104894 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
104895 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
104896 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
104897 +split_leaf_21378 split_leaf 0 21378 NULL
104898 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
104899 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
104900 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
104901 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
104902 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
104903 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
104904 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
104905 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
104906 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
104907 +ReadISAR_21453 ReadISAR 0 21453 NULL
104908 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
104909 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
104910 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
104911 +dma_skb_copy_datagram_iovec_21516 dma_skb_copy_datagram_iovec 3-5 21516 NULL
104912 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
104913 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
104914 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
104915 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
104916 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
104917 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
104918 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
104919 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
104920 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
104921 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
104922 +pci_cardbus_resource_alignment_21625 pci_cardbus_resource_alignment 0 21625 NULL
104923 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
104924 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
104925 +validate_nnode_21638 validate_nnode 0 21638 NULL
104926 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-0-3 21639 NULL
104927 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
104928 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
104929 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
104930 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
104931 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
104932 +btrfs_find_all_leafs_21712 btrfs_find_all_leafs 0 21712 NULL
104933 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
104934 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
104935 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
104936 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL nohasharray
104937 +ext4_split_extent_at_21732 ext4_split_extent_at 0 21732 &reiserfs_allocate_list_bitmaps_21732
104938 +vm_brk_21739 vm_brk 1-2 21739 NULL
104939 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
104940 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
104941 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
104942 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
104943 +atomic64_cmpxchg_21782 atomic64_cmpxchg 0 21782 NULL
104944 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
104945 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
104946 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
104947 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
104948 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
104949 +gen_unique_name_21852 gen_unique_name 0 21852 NULL
104950 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
104951 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
104952 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
104953 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
104954 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 2-1 21895 NULL
104955 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
104956 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
104957 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
104958 +ast_ttm_tt_create_21917 ast_ttm_tt_create 2 21917 NULL
104959 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
104960 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
104961 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
104962 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
104963 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
104964 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
104965 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
104966 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
104967 +i915_gem_evict_something_22028 i915_gem_evict_something 0 22028 NULL
104968 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
104969 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
104970 +atalk_recvmsg_22053 atalk_recvmsg 4 22053 NULL
104971 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
104972 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
104973 +write_opcode_22082 write_opcode 2 22082 NULL
104974 +mem_rw_22085 mem_rw 3 22085 NULL
104975 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
104976 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104977 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
104978 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL
104979 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
104980 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
104981 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104982 +remap_pud_range_22164 remap_pud_range 3-4-5 22164 NULL
104983 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL nohasharray
104984 +vmci_qp_broker_map_22173 vmci_qp_broker_map 3 22173 &__kfifo_alloc_22173
104985 +fls_22210 fls 0 22210 NULL
104986 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL nohasharray
104987 +bitmap_clear_bits_22227 bitmap_clear_bits 3 22227 &rfcomm_sock_recvmsg_22227
104988 +mem_write_22232 mem_write 3 22232 NULL
104989 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104990 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
104991 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104992 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104993 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
104994 +add_res_tree_22263 add_res_tree 7 22263 NULL
104995 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104996 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104997 +i915_gem_execbuffer_relocate_22294 i915_gem_execbuffer_relocate 0 22294 NULL
104998 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104999 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
105000 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
105001 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
105002 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
105003 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
105004 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 3-2-0 22334 NULL
105005 +atomic_read_22342 atomic_read 0 22342 NULL
105006 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
105007 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
105008 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
105009 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
105010 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
105011 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
105012 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
105013 +alloc_large_system_hash_22391 alloc_large_system_hash 2-8-9 22391 NULL
105014 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
105015 +zoran_write_22404 zoran_write 3 22404 NULL
105016 +ATOMIC_ADD_RETURN_22413 ATOMIC_ADD_RETURN 2 22413 NULL
105017 +queue_reply_22416 queue_reply 3 22416 NULL
105018 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
105019 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
105020 +_rtw_vmalloc_22444 _rtw_vmalloc 1 22444 NULL
105021 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
105022 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
105023 +btrfs_write_out_cache_22471 btrfs_write_out_cache 0 22471 NULL nohasharray
105024 +dtf_write_device_22471 dtf_write_device 3 22471 &btrfs_write_out_cache_22471
105025 +source_sink_start_ep_22472 source_sink_start_ep 0 22472 NULL
105026 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
105027 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
105028 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
105029 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
105030 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
105031 +__btrfs_add_delayed_item_22511 __btrfs_add_delayed_item 0 22511 NULL
105032 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
105033 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
105034 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
105035 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
105036 +snd_pcm_hw_params_choose_22560 snd_pcm_hw_params_choose 0 22560 NULL
105037 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
105038 +snapshot_read_22601 snapshot_read 3 22601 NULL
105039 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
105040 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
105041 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
105042 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
105043 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
105044 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
105045 +sysfs_attr_ns_22645 sysfs_attr_ns 0 22645 NULL
105046 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
105047 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
105048 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL nohasharray
105049 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 &ubifs_leb_write_22679
105050 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
105051 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
105052 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
105053 +reg_umr_22686 reg_umr 5 22686 NULL
105054 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
105055 +map_22700 map 2 22700 NULL nohasharray
105056 +btrfs_del_inode_ref_in_log_22700 btrfs_del_inode_ref_in_log 0 22700 &map_22700
105057 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
105058 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
105059 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL
105060 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
105061 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
105062 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
105063 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
105064 +print_frame_22769 print_frame 0 22769 NULL
105065 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
105066 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
105067 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
105068 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
105069 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
105070 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
105071 +create_attr_set_22861 create_attr_set 1 22861 NULL
105072 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
105073 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
105074 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
105075 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
105076 +__btrfs_add_free_space_22917 __btrfs_add_free_space 0 22917 NULL
105077 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
105078 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
105079 +alloc_sglist_22960 alloc_sglist 3-2 22960 NULL
105080 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
105081 +vme_get_size_22964 vme_get_size 0 22964 NULL
105082 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
105083 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
105084 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
105085 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
105086 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
105087 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
105088 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
105089 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
105090 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 0-6-7 23029 NULL
105091 +st_status_23032 st_status 5 23032 NULL
105092 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
105093 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
105094 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
105095 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
105096 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
105097 +filp_close_23071 filp_close 0 23071 NULL
105098 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
105099 +raw_sendmsg_23078 raw_sendmsg 4 23078 NULL
105100 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
105101 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
105102 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
105103 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
105104 +__add_prelim_ref_23095 __add_prelim_ref 0 23095 NULL
105105 +fls_long_23096 fls_long 0 23096 NULL
105106 +ntfs_ucstonls_23097 ntfs_ucstonls 5-3 23097 NULL
105107 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
105108 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
105109 +ip_recv_error_23109 ip_recv_error 3 23109 NULL
105110 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
105111 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
105112 +__clear_user_23118 __clear_user 0-2 23118 NULL
105113 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
105114 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
105115 +ext3_listxattr_23137 ext3_listxattr 3 23137 NULL
105116 +read_file_ani_23161 read_file_ani 3 23161 NULL
105117 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
105118 +usblp_write_23178 usblp_write 3 23178 NULL
105119 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
105120 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
105121 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
105122 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
105123 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
105124 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
105125 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
105126 +__read_status_pci_23229 __read_status_pci 0 23229 NULL nohasharray
105127 +xlog_get_bp_23229 xlog_get_bp 2 23229 &__read_status_pci_23229
105128 +ft1000_read_dpram_mag_32_23232 ft1000_read_dpram_mag_32 0 23232 NULL
105129 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
105130 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
105131 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
105132 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
105133 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
105134 +gru_preload_tlb_23305 gru_preload_tlb 7-4 23305 NULL
105135 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
105136 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
105137 +__es_remove_extent_23323 __es_remove_extent 0 23323 NULL
105138 +page_readlink_23346 page_readlink 3 23346 NULL
105139 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
105140 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
105141 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
105142 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
105143 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
105144 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
105145 +__ctzsi2_23444 __ctzsi2 1 23444 NULL
105146 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
105147 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
105148 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3-0 23484 NULL
105149 +linear_conf_23485 linear_conf 2 23485 NULL
105150 +copy_module_from_user_23492 copy_module_from_user 2 23492 NULL
105151 +event_filter_read_23494 event_filter_read 3 23494 NULL
105152 +ext4_remove_blocks_23497 ext4_remove_blocks 0 23497 NULL
105153 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
105154 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
105155 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
105156 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
105157 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
105158 +__es_insert_extent_23543 __es_insert_extent 0 23543 NULL
105159 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
105160 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
105161 +dbg_leb_change_23555 dbg_leb_change 0-4 23555 NULL
105162 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
105163 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
105164 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
105165 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
105166 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
105167 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
105168 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
105169 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
105170 +alloc_pte_23642 alloc_pte 3 23642 NULL
105171 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
105172 +sInW_23663 sInW 0 23663 NULL
105173 +SyS_connect_23669 SyS_connect 3 23669 NULL
105174 +cx18_read_23699 cx18_read 3 23699 NULL
105175 +btrfs_insert_delayed_item_23705 btrfs_insert_delayed_item 0 23705 NULL
105176 +at_get_23708 at_get 0 23708 NULL
105177 +snd_pcm_hw_refine_23721 snd_pcm_hw_refine 0 23721 NULL
105178 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
105179 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
105180 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
105181 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
105182 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
105183 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
105184 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
105185 +map_write_23795 map_write 3 23795 NULL
105186 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
105187 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
105188 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
105189 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
105190 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
105191 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
105192 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
105193 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
105194 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
105195 +p54_init_common_23850 p54_init_common 1 23850 NULL
105196 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
105197 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
105198 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
105199 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
105200 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
105201 +_rtw_zvmalloc_23892 _rtw_zvmalloc 1 23892 NULL
105202 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
105203 +usbg_prepare_w_request_23895 usbg_prepare_w_request 0 23895 NULL
105204 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
105205 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
105206 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
105207 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
105208 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
105209 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
105210 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL nohasharray
105211 +intel_ring_alloc_seqno_23928 intel_ring_alloc_seqno 0 23928 &kvm_read_guest_23928
105212 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
105213 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
105214 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
105215 +vfs_write_23971 vfs_write 0-3 23971 NULL
105216 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
105217 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
105218 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
105219 +intel_ring_idle_24014 intel_ring_idle 0 24014 NULL
105220 +give_pages_24021 give_pages 3 24021 NULL
105221 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
105222 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
105223 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
105224 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
105225 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
105226 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
105227 +ocfs2_cannibalize_resv_24090 ocfs2_cannibalize_resv 3 24090 NULL
105228 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
105229 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
105230 +lov_brw_24122 lov_brw 4 24122 NULL
105231 +mpu401_read_24126 mpu401_read 3-0 24126 NULL
105232 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL
105233 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
105234 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
105235 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
105236 +set_discard_24162 set_discard 2 24162 NULL
105237 +__copy_user_zeroing_intel_nocache_24163 __copy_user_zeroing_intel_nocache 0-3 24163 NULL
105238 +adu_read_24177 adu_read 3 24177 NULL
105239 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
105240 +shrink_tnc_24190 shrink_tnc 0 24190 NULL
105241 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
105242 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
105243 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
105244 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
105245 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
105246 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 NULL nohasharray
105247 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
105248 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
105249 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
105250 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
105251 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
105252 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
105253 +thin_status_24278 thin_status 5 24278 NULL
105254 +msg_size_24288 msg_size 0 24288 NULL
105255 +ext2_free_blocks_24292 ext2_free_blocks 3-2 24292 NULL
105256 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
105257 +map_page_24298 map_page 3-4 24298 NULL
105258 +gserial_connect_24302 gserial_connect 0 24302 NULL
105259 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
105260 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3-0 24313 NULL
105261 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
105262 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
105263 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
105264 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
105265 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
105266 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
105267 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
105268 +igetword_24373 igetword 0 24373 NULL
105269 +max_io_len_24384 max_io_len 0-1 24384 NULL
105270 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
105271 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
105272 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
105273 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398 nohasharray
105274 +__btrfs_write_out_cache_24398 __btrfs_write_out_cache 0 24398 &getxattr_24398
105275 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
105276 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
105277 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
105278 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
105279 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
105280 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
105281 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 6-4 24439 NULL
105282 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
105283 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
105284 +__push_leaf_left_24456 __push_leaf_left 0 24456 NULL
105285 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
105286 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
105287 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL nohasharray
105288 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 6-5 24466 &skb_copy_and_csum_datagram_iovec_24466
105289 +snd_pcm_hw_param_first_24487 snd_pcm_hw_param_first 0 24487 NULL
105290 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
105291 +i915_gem_obj_offset_24494 i915_gem_obj_offset 0 24494 NULL
105292 +push_nodes_for_insert_24496 push_nodes_for_insert 0 24496 NULL
105293 +pd_video_read_24510 pd_video_read 3 24510 NULL
105294 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
105295 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
105296 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
105297 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
105298 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
105299 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
105300 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
105301 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
105302 +SyS_poll_24620 SyS_poll 2 24620 NULL
105303 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
105304 +context_alloc_24645 context_alloc 3 24645 NULL
105305 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
105306 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
105307 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
105308 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
105309 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
105310 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
105311 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
105312 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
105313 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
105314 +kempld_read8_24756 kempld_read8 0 24756 NULL
105315 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
105316 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
105317 +cache_read_24790 cache_read 3 24790 NULL
105318 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
105319 +i915_gem_check_wedge_24793 i915_gem_check_wedge 0 24793 NULL
105320 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
105321 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
105322 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
105323 +sb_set_blocksize_24807 sb_set_blocksize 0-2 24807 NULL
105324 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
105325 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
105326 +net2272_read_24825 net2272_read 0 24825 NULL
105327 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
105328 +btrfs_next_old_item_24843 btrfs_next_old_item 0 24843 NULL
105329 +xfs_free_file_space_24853 xfs_free_file_space 2-3 24853 NULL
105330 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
105331 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
105332 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
105333 +setup_buffering_24872 setup_buffering 3 24872 NULL
105334 +queues_read_24877 queues_read 3 24877 NULL
105335 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
105336 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
105337 +__btrfs_free_extent_24927 __btrfs_free_extent 7-0 24927 NULL nohasharray
105338 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
105339 +ocfs2_fiemap_24949 ocfs2_fiemap 4-3 24949 NULL
105340 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
105341 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
105342 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
105343 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
105344 +btrfs_update_delayed_inode_24988 btrfs_update_delayed_inode 0 24988 NULL
105345 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
105346 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
105347 +twl6030_irq_unmap_25014 twl6030_irq_unmap 2 25014 NULL
105348 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
105349 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
105350 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
105351 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
105352 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
105353 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
105354 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
105355 +iwl_dbgfs_tx_flush_write_25091 iwl_dbgfs_tx_flush_write 3 25091 NULL
105356 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL nohasharray
105357 +blkg_path_25099 blkg_path 3 25099 &gfs2_iter_unstuffed_25099
105358 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
105359 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
105360 +record_new_ref_25154 record_new_ref 0 25154 NULL
105361 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL nohasharray
105362 +btrfs_delete_delayed_items_25167 btrfs_delete_delayed_items 0 25167 &ipath_init_qp_table_25167
105363 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL
105364 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
105365 +res_counter_read_u64_25180 res_counter_read_u64 0 25180 NULL
105366 +send_create_inode_if_needed_25211 send_create_inode_if_needed 0 25211 NULL
105367 +security_socket_post_create_25221 security_socket_post_create 0 25221 NULL
105368 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
105369 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
105370 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
105371 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 5-3 25245 NULL
105372 +stripe_status_25259 stripe_status 5 25259 NULL
105373 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
105374 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
105375 +vfs_writev_25278 vfs_writev 3 25278 NULL
105376 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
105377 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
105378 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
105379 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
105380 +rio_destid_next_25368 rio_destid_next 2-0 25368 NULL nohasharray
105381 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
105382 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
105383 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
105384 +orphanize_inode_25382 orphanize_inode 0 25382 NULL
105385 +SyS_splice_25390 SyS_splice 5 25390 NULL
105386 +btrfs_update_reserved_bytes_25393 btrfs_update_reserved_bytes 0 25393 NULL
105387 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
105388 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
105389 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
105390 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
105391 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
105392 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
105393 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
105394 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
105395 +evm_init_hmac_25504 evm_init_hmac 0 25504 NULL
105396 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
105397 +sb_permission_25523 sb_permission 0 25523 NULL
105398 +down_read_failed_25532 down_read_failed 2 25532 NULL
105399 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
105400 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
105401 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
105402 +mgag200_ttm_tt_create_25550 mgag200_ttm_tt_create 2 25550 NULL
105403 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
105404 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
105405 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL nohasharray
105406 +find_extend_vma_25597 find_extend_vma 2 25597 &ping_recvmsg_25597
105407 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
105408 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
105409 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
105410 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
105411 +__direct_map_25647 __direct_map 6-5 25647 NULL
105412 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2-0 25667 NULL
105413 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
105414 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
105415 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
105416 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
105417 +wl1271_tx_enabled_rates_get_25712 wl1271_tx_enabled_rates_get 0 25712 NULL nohasharray
105418 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 &wl1271_tx_enabled_rates_get_25712
105419 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
105420 +ttm_tt_init_25717 ttm_tt_init 3 25717 NULL
105421 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
105422 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
105423 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
105424 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
105425 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
105426 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
105427 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
105428 +sg_read_25799 sg_read 3 25799 NULL
105429 +system_enable_read_25815 system_enable_read 3 25815 NULL
105430 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
105431 +ftrace_profile_init_25821 ftrace_profile_init 0 25821 NULL
105432 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
105433 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
105434 +parport_read_25855 parport_read 0 25855 NULL
105435 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
105436 +key_attr_size_25865 key_attr_size 0 25865 NULL
105437 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
105438 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
105439 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
105440 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
105441 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
105442 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
105443 +rcname_read_25919 rcname_read 3 25919 NULL
105444 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
105445 +key_flags_read_25931 key_flags_read 3 25931 NULL
105446 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
105447 +flush_25957 flush 2 25957 NULL
105448 +video_register_device_25971 video_register_device 3 25971 NULL
105449 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
105450 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
105451 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
105452 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
105453 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
105454 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
105455 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
105456 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
105457 +tun_do_read_26047 tun_do_read 5 26047 NULL
105458 +make_bfloat_26056 make_bfloat 2 26056 NULL
105459 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
105460 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
105461 +__add_inline_refs_26096 __add_inline_refs 0 26096 NULL
105462 +dup_ref_26100 dup_ref 0 26100 NULL
105463 +intel_wrap_ring_buffer_26117 intel_wrap_ring_buffer 0 26117 NULL
105464 +read_sb_page_26119 read_sb_page 5 26119 NULL
105465 +__fswab64_26155 __fswab64 0 26155 NULL
105466 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
105467 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
105468 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
105469 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
105470 +disk_devt_26180 disk_devt 0 26180 NULL
105471 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
105472 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
105473 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
105474 +mce_write_26201 mce_write 3 26201 NULL
105475 +SyS_splice_26206 SyS_splice 5 26206 NULL
105476 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
105477 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
105478 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
105479 +bio_split_26235 bio_split 2 26235 NULL
105480 +btrfs_delayed_inode_reserve_metadata_26236 btrfs_delayed_inode_reserve_metadata 0 26236 NULL
105481 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
105482 +do_setxattr_26264 do_setxattr 0 26264 NULL
105483 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
105484 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
105485 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
105486 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
105487 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
105488 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
105489 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
105490 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
105491 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
105492 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5-0-6-3 26357 NULL
105493 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
105494 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
105495 +ntty_write_26404 ntty_write 3 26404 NULL
105496 +pagemap_read_26441 pagemap_read 3 26441 NULL
105497 +tower_read_26461 tower_read 3 26461 NULL nohasharray
105498 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461 nohasharray
105499 +numa_cpu_node_26461 numa_cpu_node 0 26461 &enc_pools_add_pages_26461
105500 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
105501 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
105502 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
105503 +vfio_pin_pages_26494 vfio_pin_pages 1 26494 NULL
105504 +read_vmcore_26501 read_vmcore 3 26501 NULL
105505 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
105506 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
105507 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
105508 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
105509 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
105510 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
105511 +qgroup_account_ref_step3_26558 qgroup_account_ref_step3 0 26558 NULL
105512 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
105513 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
105514 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
105515 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
105516 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
105517 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
105518 +pack_value_26625 pack_value 1 26625 NULL
105519 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
105520 +drm_ht_find_item_26637 drm_ht_find_item 0 26637 NULL
105521 +process_extent_26646 process_extent 0 26646 NULL nohasharray
105522 +btrfs_lookup_inode_26646 btrfs_lookup_inode 0 26646 &process_extent_26646
105523 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
105524 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
105525 +usb_reset_device_26661 usb_reset_device 0 26661 NULL
105526 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
105527 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
105528 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
105529 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
105530 +bos_desc_26752 bos_desc 0 26752 NULL
105531 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
105532 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
105533 +cache_save_setup_26783 cache_save_setup 0 26783 NULL
105534 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
105535 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
105536 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
105537 +smk_write_load_26829 smk_write_load 3 26829 NULL
105538 +ept_get_level1_sp_gpa_26831 ept_get_level1_sp_gpa 0 26831 NULL
105539 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
105540 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
105541 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
105542 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
105543 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
105544 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
105545 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
105546 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
105547 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
105548 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
105549 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
105550 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
105551 +remove_from_bitmap_26939 remove_from_bitmap 0 26939 NULL
105552 +create_bm_block_list_26940 create_bm_block_list 0 26940 NULL
105553 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
105554 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
105555 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
105556 +xlog_grant_push_ail_26972 xlog_grant_push_ail 2 26972 NULL
105557 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
105558 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
105559 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
105560 +omfs_allocate_range_27034 omfs_allocate_range 3 27034 NULL
105561 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
105562 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
105563 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
105564 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
105565 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
105566 +snd_mixer_oss_set_recsrc_27080 snd_mixer_oss_set_recsrc 2 27080 NULL
105567 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
105568 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
105569 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
105570 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
105571 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
105572 +i915_gem_execbuffer_relocate_slow_27116 i915_gem_execbuffer_relocate_slow 0 27116 NULL
105573 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
105574 +__ext4_handle_dirty_metadata_27137 __ext4_handle_dirty_metadata 0 27137 NULL
105575 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
105576 +pms_capture_27142 pms_capture 4 27142 NULL
105577 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
105578 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
105579 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
105580 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
105581 +__intel_ring_begin_27197 __intel_ring_begin 0 27197 NULL
105582 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
105583 +ocfs2_read_blocks_sync_27210 ocfs2_read_blocks_sync 0 27210 NULL
105584 +write_kmem_27225 write_kmem 3 27225 NULL
105585 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
105586 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
105587 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
105588 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
105589 +qfq_unblock_groups_27269 qfq_unblock_groups 2 27269 NULL
105590 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
105591 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
105592 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
105593 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
105594 +write_buf_27316 write_buf 0-3 27316 NULL
105595 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
105596 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
105597 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
105598 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
105599 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
105600 +lz4_compress_crypto_27387 lz4_compress_crypto 3 27387 NULL
105601 +seq_read_27411 seq_read 3 27411 NULL
105602 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
105603 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
105604 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 0-3-4 27422 NULL nohasharray
105605 +evm_inode_init_security_27422 evm_inode_init_security 0 27422 &ocfs2_refcount_cal_cow_clusters_27422
105606 +cypress_write_27423 cypress_write 4 27423 NULL
105607 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
105608 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
105609 +sk_extract_addr_27474 sk_extract_addr 0 27474 NULL
105610 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
105611 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
105612 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
105613 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
105614 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
105615 +ept_walk_addr_generic_27501 ept_walk_addr_generic 4 27501 NULL
105616 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
105617 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
105618 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
105619 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
105620 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
105621 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
105622 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
105623 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
105624 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
105625 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
105626 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &ocfs2_direct_IO_27642
105627 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
105628 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
105629 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
105630 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
105631 +record_changed_ref_27665 record_changed_ref 0 27665 NULL
105632 +iommu_pgsize_27677 iommu_pgsize 2-0 27677 NULL
105633 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
105634 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4-0 27702 NULL
105635 +evm_write_key_27715 evm_write_key 3 27715 NULL
105636 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
105637 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
105638 +macvtap_skb_to_vnet_hdr_27747 macvtap_skb_to_vnet_hdr 0 27747 NULL
105639 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
105640 +gpiochip_export_27776 gpiochip_export 0 27776 NULL
105641 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
105642 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
105643 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
105644 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL nohasharray
105645 +SyS_readv_27804 SyS_readv 3 27804 &ttm_object_file_init_27804
105646 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
105647 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
105648 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
105649 +init_header_complete_27833 init_header_complete 0 27833 NULL
105650 +read_profile_27859 read_profile 3 27859 NULL
105651 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
105652 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
105653 +process_all_extents_27879 process_all_extents 0 27879 NULL
105654 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
105655 +gluebi_write_27905 gluebi_write 3-2 27905 NULL
105656 +SyS_ptrace_27924 SyS_ptrace 3 27924 NULL
105657 +bm_find_next_27929 bm_find_next 2 27929 NULL
105658 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
105659 +i915_gem_execbuffer_reserve_object_27956 i915_gem_execbuffer_reserve_object 0 27956 NULL
105660 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
105661 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
105662 +device_register_27972 device_register 0 27972 NULL nohasharray
105663 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
105664 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL
105665 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
105666 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
105667 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
105668 +remove_extent_data_ref_28023 remove_extent_data_ref 0 28023 NULL
105669 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
105670 +record_deleted_ref_28039 record_deleted_ref 0 28039 NULL
105671 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
105672 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
105673 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
105674 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
105675 +pool_status_28055 pool_status 5 28055 NULL
105676 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL
105677 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
105678 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
105679 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
105680 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
105681 +SyS_brk_28096 SyS_brk 1 28096 NULL
105682 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 2-3 28102 NULL
105683 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
105684 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
105685 +tipc_msg_init_28128 tipc_msg_init 4-2 28128 NULL
105686 +video_read_28148 video_read 3 28148 NULL
105687 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
105688 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
105689 +__add_reloc_root_28155 __add_reloc_root 0 28155 NULL
105690 +vread_28173 vread 0-3 28173 NULL
105691 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
105692 +counter_free_res_28187 counter_free_res 5 28187 NULL
105693 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
105694 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
105695 +__exclude_logged_extent_28212 __exclude_logged_extent 2-0 28212 NULL
105696 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
105697 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
105698 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
105699 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
105700 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
105701 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
105702 +usemap_size_28281 usemap_size 0 28281 NULL
105703 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
105704 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
105705 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
105706 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
105707 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
105708 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
105709 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3-0 28315 NULL
105710 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
105711 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
105712 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
105713 +cpuset_spread_node_28351 cpuset_spread_node 0 28351 NULL nohasharray
105714 +snapshot_write_28351 snapshot_write 3 28351 &cpuset_spread_node_28351
105715 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
105716 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
105717 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
105718 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
105719 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
105720 +get_extent_allocation_hint_28423 get_extent_allocation_hint 0 28423 NULL
105721 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
105722 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
105723 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
105724 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
105725 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
105726 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
105727 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
105728 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
105729 +clear_discard_28494 clear_discard 2 28494 NULL
105730 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
105731 +__next_node_28521 __next_node 1-0 28521 NULL
105732 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
105733 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
105734 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 NULL nohasharray
105735 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545 nohasharray
105736 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545
105737 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
105738 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
105739 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
105740 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
105741 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
105742 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
105743 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
105744 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
105745 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
105746 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
105747 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
105748 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
105749 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
105750 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
105751 +btrfs_previous_item_28667 btrfs_previous_item 0 28667 NULL
105752 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
105753 +__perf_sw_event_28684 __perf_sw_event 2 28684 NULL
105754 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
105755 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
105756 +balance_level_28707 balance_level 0 28707 NULL
105757 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
105758 +spi_execute_28736 spi_execute 5 28736 NULL
105759 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
105760 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
105761 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
105762 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
105763 +atomic_inc_return_unchecked_28778 atomic_inc_return_unchecked 0 28778 NULL
105764 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
105765 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
105766 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
105767 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
105768 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
105769 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
105770 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
105771 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
105772 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
105773 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
105774 +to_cblock_28899 to_cblock 0-1 28899 NULL
105775 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
105776 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
105777 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
105778 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
105779 +push_rx_28939 push_rx 3 28939 NULL
105780 +btrfs_trim_block_group_28963 btrfs_trim_block_group 4-3 28963 NULL
105781 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
105782 +remap_pfn_range_28976 remap_pfn_range 3-4-2 28976 NULL
105783 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
105784 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
105785 +bin_uuid_28999 bin_uuid 3 28999 NULL
105786 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL nohasharray
105787 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 &fd_execute_rw_29004
105788 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
105789 +i915_gem_object_bind_to_vm_29035 i915_gem_object_bind_to_vm 0 29035 NULL
105790 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
105791 +ProcessGetHostMibs_29049 ProcessGetHostMibs 0 29049 NULL nohasharray
105792 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 &ProcessGetHostMibs_29049
105793 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
105794 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
105795 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
105796 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
105797 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
105798 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
105799 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
105800 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
105801 +snprintf_29125 snprintf 0 29125 NULL
105802 +iov_shorten_29130 iov_shorten 0 29130 NULL
105803 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
105804 +alloc_irqs_from_29152 alloc_irqs_from 1-2-0 29152 NULL
105805 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
105806 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
105807 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
105808 +__mm_populate_29204 __mm_populate 1-2 29204 NULL
105809 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
105810 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
105811 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
105812 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
105813 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
105814 +recover_peb_29238 recover_peb 0-7-6 29238 NULL
105815 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
105816 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
105817 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
105818 +block_div_29268 block_div 0-1-2 29268 NULL
105819 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
105820 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
105821 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
105822 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
105823 +replace_file_extents_29312 replace_file_extents 0 29312 NULL
105824 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
105825 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
105826 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
105827 +tun_put_user_29337 tun_put_user 5 29337 NULL
105828 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
105829 +ide_read_altstatus_29343 ide_read_altstatus 0 29343 NULL
105830 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
105831 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
105832 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
105833 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
105834 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
105835 +btrfs_run_delayed_items_29428 btrfs_run_delayed_items 0 29428 NULL
105836 +mempool_create_29437 mempool_create 1 29437 NULL
105837 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
105838 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
105839 +ept_page_fault_29450 ept_page_fault 2 29450 NULL
105840 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
105841 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
105842 +do_register_entry_29478 do_register_entry 4 29478 NULL
105843 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
105844 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
105845 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
105846 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
105847 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
105848 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
105849 +_regmap_raw_write_29541 _regmap_raw_write 2-4 29541 NULL
105850 +vfs_read_29543 vfs_read 0-3 29543 NULL
105851 +set_brk_29551 set_brk 1-2 29551 NULL nohasharray
105852 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
105853 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
105854 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL
105855 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
105856 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
105857 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
105858 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
105859 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
105860 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
105861 +slots_per_page_29601 slots_per_page 0 29601 NULL
105862 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
105863 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
105864 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
105865 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
105866 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
105867 +tracepoint_probe_register_29688 tracepoint_probe_register 0 29688 NULL
105868 +__btrfs_setxattr_29689 __btrfs_setxattr 0 29689 NULL
105869 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
105870 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
105871 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
105872 +probes_write_29711 probes_write 3 29711 NULL
105873 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
105874 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
105875 +std_nic_write_29752 std_nic_write 3 29752 NULL
105876 +dbAlloc_29794 dbAlloc 0 29794 NULL
105877 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
105878 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
105879 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
105880 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
105881 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
105882 +count_partial_29850 count_partial 0 29850 NULL
105883 +radeon_ttm_tt_create_29859 radeon_ttm_tt_create 2 29859 NULL
105884 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
105885 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
105886 +tlv_put_29872 tlv_put 0 29872 NULL
105887 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
105888 +changed_extent_29881 changed_extent 0 29881 NULL
105889 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
105890 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
105891 +write_file_queue_29922 write_file_queue 3 29922 NULL
105892 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
105893 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
105894 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 NULL
105895 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
105896 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
105897 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
105898 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
105899 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
105900 +drp_wmove_30043 drp_wmove 4 30043 NULL nohasharray
105901 +wrmalt_30043 wrmalt 0 30043 &drp_wmove_30043
105902 +mem_cgroup_charge_common_30047 mem_cgroup_charge_common 0 30047 NULL
105903 +SyS_write_30059 SyS_write 3 30059 NULL
105904 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
105905 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
105906 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
105907 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
105908 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
105909 +calgary_unmap_page_30130 calgary_unmap_page 3-2 30130 NULL
105910 +recv_stream_30138 recv_stream 4 30138 NULL
105911 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
105912 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
105913 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
105914 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
105915 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
105916 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
105917 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
105918 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
105919 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
105920 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
105921 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
105922 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
105923 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
105924 +hfsplus_trusted_setxattr_30270 hfsplus_trusted_setxattr 4 30270 NULL
105925 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
105926 +compat_readv_30273 compat_readv 3 30273 NULL
105927 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
105928 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
105929 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
105930 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
105931 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
105932 +drm_core_get_reg_ofs_30309 drm_core_get_reg_ofs 0 30309 NULL
105933 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
105934 +i8254_read_30330 i8254_read 0 30330 NULL
105935 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
105936 +resource_from_user_30341 resource_from_user 3 30341 NULL
105937 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
105938 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
105939 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
105940 +inet_getid_30365 inet_getid 2 30365 NULL
105941 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
105942 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3-0 30392 NULL
105943 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
105944 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
105945 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
105946 +ext3_xattr_list_30419 ext3_xattr_list 3 30419 NULL
105947 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
105948 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
105949 +mq_create_30425 mq_create 1 30425 NULL nohasharray
105950 +lstcon_session_info_30425 lstcon_session_info 6 30425 &mq_create_30425
105951 +ext4_ext_create_new_leaf_30428 ext4_ext_create_new_leaf 0 30428 NULL
105952 +enable_write_30456 enable_write 3 30456 NULL
105953 +pci_resource_alignment_30457 pci_resource_alignment 0 30457 NULL
105954 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
105955 +urandom_read_30462 urandom_read 3 30462 NULL
105956 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
105957 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
105958 +send_rmdir_30470 send_rmdir 0 30470 NULL
105959 +i915_mutex_lock_interruptible_30474 i915_mutex_lock_interruptible 0 30474 NULL nohasharray
105960 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 &i915_mutex_lock_interruptible_30474
105961 +write_head_30481 write_head 4 30481 NULL
105962 +adu_write_30487 adu_write 3 30487 NULL
105963 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
105964 +btrfs_free_extent_30515 btrfs_free_extent 0 30515 NULL
105965 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
105966 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL nohasharray
105967 +set_config_30526 set_config 0 30526 &debug_debug2_read_30526
105968 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
105969 +set_le_30581 set_le 4 30581 NULL
105970 +from_cblock_30582 from_cblock 0-1 30582 NULL
105971 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
105972 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
105973 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
105974 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
105975 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
105976 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
105977 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
105978 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
105979 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
105980 +agp_remap_30665 agp_remap 2 30665 NULL
105981 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
105982 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
105983 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
105984 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
105985 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
105986 +__mutex_lock_common_30717 __mutex_lock_common 0 30717 NULL
105987 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
105988 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
105989 +snapshot_status_30744 snapshot_status 5 30744 NULL
105990 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
105991 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
105992 +btrfs_run_ordered_operations_30793 btrfs_run_ordered_operations 0 30793 NULL
105993 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
105994 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
105995 +xlog_grant_head_wait_30829 xlog_grant_head_wait 4 30829 NULL
105996 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
105997 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
105998 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
105999 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
106000 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
106001 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL
106002 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
106003 +find_free_dev_extent_30963 find_free_dev_extent 0 30963 NULL
106004 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
106005 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
106006 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL
106007 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
106008 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
106009 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
106010 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
106011 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
106012 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
106013 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
106014 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
106015 +si_calculate_power_efficiency_ratio_31111 si_calculate_power_efficiency_ratio 3-2 31111 NULL
106016 +depth_read_31112 depth_read 3 31112 NULL
106017 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
106018 +size_inside_page_31141 size_inside_page 0-1-2 31141 NULL
106019 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
106020 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
106021 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
106022 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
106023 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
106024 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
106025 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
106026 +__read_reg_31216 __read_reg 0 31216 NULL
106027 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
106028 +ulist_rbtree_insert_31235 ulist_rbtree_insert 0 31235 NULL
106029 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
106030 +cyy_readb_31240 cyy_readb 0 31240 NULL
106031 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
106032 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
106033 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
106034 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
106035 +push_leaf_left_31306 push_leaf_left 0 31306 NULL
106036 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
106037 +command_file_write_31318 command_file_write 3 31318 NULL
106038 +ext4_xattr_block_list_31325 ext4_xattr_block_list 3 31325 NULL
106039 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
106040 +radix_tree_insert_31336 radix_tree_insert 0 31336 NULL
106041 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
106042 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
106043 +outlen_write_31358 outlen_write 3 31358 NULL
106044 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
106045 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
106046 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 2-3 31374 NULL
106047 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
106048 +inb_31388 inb 0 31388 NULL
106049 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
106050 +i915_gem_object_put_fence_31413 i915_gem_object_put_fence 0 31413 NULL
106051 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
106052 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
106053 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
106054 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
106055 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
106056 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
106057 +register_ftrace_graph_31456 register_ftrace_graph 0 31456 NULL
106058 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
106059 +do_fcntl_31468 do_fcntl 3 31468 NULL
106060 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
106061 +__ext4_journal_get_write_access_31482 __ext4_journal_get_write_access 0 31482 NULL
106062 +alg_setkey_31485 alg_setkey 3 31485 NULL
106063 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
106064 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
106065 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
106066 +nouveau_mc_create__31513 nouveau_mc_create_ 5 31513 NULL
106067 +hidraw_write_31536 hidraw_write 3 31536 NULL
106068 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
106069 +usbvision_read_31555 usbvision_read 3 31555 NULL
106070 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
106071 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
106072 +osst_write_31581 osst_write 3 31581 NULL
106073 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
106074 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
106075 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
106076 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
106077 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
106078 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
106079 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
106080 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
106081 +__lgread_31668 __lgread 4 31668 NULL
106082 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
106083 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
106084 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
106085 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 NULL
106086 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
106087 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
106088 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
106089 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
106090 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
106091 +muldiv64_31743 muldiv64 3-2-0 31743 NULL
106092 +stmpe_set_altfunc_31750 stmpe_set_altfunc 2 31750 NULL nohasharray
106093 +bcm_char_read_31750 bcm_char_read 3 31750 &stmpe_set_altfunc_31750
106094 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
106095 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
106096 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
106097 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
106098 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
106099 +data_write_31805 data_write 3 31805 NULL
106100 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
106101 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
106102 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
106103 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
106104 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
106105 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
106106 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
106107 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
106108 +xattr_permission_31907 xattr_permission 0 31907 NULL
106109 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
106110 +new_dir_31919 new_dir 3 31919 NULL
106111 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
106112 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
106113 +process_recorded_refs_if_needed_31938 process_recorded_refs_if_needed 0 31938 NULL
106114 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
106115 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 NULL nohasharray
106116 +read_mem_31942 read_mem 3 31942 &iov_iter_copy_from_user_31942
106117 +vb2_write_31948 vb2_write 3 31948 NULL
106118 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
106119 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
106120 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
106121 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
106122 +btrfs_insert_empty_inode_31975 btrfs_insert_empty_inode 0 31975 NULL
106123 +vx_read_status_31982 vx_read_status 0 31982 NULL nohasharray
106124 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 &vx_read_status_31982
106125 +find_next_zero_bit_31990 find_next_zero_bit 3-2-0 31990 NULL
106126 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
106127 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
106128 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
106129 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
106130 +calc_hmac_32010 calc_hmac 3 32010 NULL
106131 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
106132 +resource_alignment_32020 resource_alignment 0 32020 NULL
106133 +aead_len_32021 aead_len 0 32021 NULL
106134 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3-0 32032 NULL
106135 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
106136 +stk_read_32038 stk_read 3 32038 NULL
106137 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
106138 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
106139 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
106140 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
106141 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
106142 +bio_alloc_32095 bio_alloc 2 32095 NULL
106143 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
106144 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
106145 +disk_status_32120 disk_status 4 32120 NULL
106146 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
106147 +btrfs_split_item_32164 btrfs_split_item 0 32164 NULL
106148 +venus_link_32165 venus_link 5 32165 NULL
106149 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
106150 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
106151 +load_header_32183 load_header 0 32183 NULL
106152 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
106153 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
106154 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
106155 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
106156 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
106157 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
106158 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
106159 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
106160 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
106161 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
106162 +SyS_select_32319 SyS_select 1 32319 NULL
106163 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
106164 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
106165 +apic_get_tmcct_32338 apic_get_tmcct 0 32338 NULL
106166 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
106167 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
106168 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
106169 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
106170 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
106171 +__wait_seqno_32370 __wait_seqno 0 32370 NULL
106172 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
106173 +cpuset_slab_spread_node_32376 cpuset_slab_spread_node 0 32376 NULL
106174 +intel_iommu_map_32384 intel_iommu_map 4-3 32384 NULL
106175 +local_clock_32385 local_clock 0 32385 NULL
106176 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
106177 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
106178 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
106179 +__add_missing_keys_32402 __add_missing_keys 0 32402 NULL
106180 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
106181 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
106182 +__ext4_handle_dirty_super_32458 __ext4_handle_dirty_super 0 32458 NULL
106183 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
106184 +cache_status_32462 cache_status 5 32462 NULL
106185 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
106186 +dgap_usertoboard_32490 dgap_usertoboard 4 32490 NULL
106187 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
106188 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
106189 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
106190 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
106191 +ocfs2_local_alloc_reserve_for_window_32518 ocfs2_local_alloc_reserve_for_window 0 32518 NULL
106192 +disconnect_32521 disconnect 4 32521 NULL
106193 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
106194 +audio_get_intf_req_32524 audio_get_intf_req 0 32524 NULL nohasharray
106195 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 &audio_get_intf_req_32524
106196 +ilo_read_32531 ilo_read 3 32531 NULL
106197 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
106198 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
106199 +__first_node_32558 __first_node 0 32558 NULL
106200 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
106201 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
106202 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
106203 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
106204 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
106205 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
106206 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
106207 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
106208 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
106209 +kvmalloc_32646 kvmalloc 1 32646 NULL
106210 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
106211 +generic_readlink_32654 generic_readlink 3 32654 NULL nohasharray
106212 +ftrace_startup_32654 ftrace_startup 0 32654 &generic_readlink_32654
106213 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
106214 +apei_res_add_32674 apei_res_add 0 32674 NULL
106215 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
106216 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
106217 +i40e_pci_sriov_enable_32742 i40e_pci_sriov_enable 2 32742 NULL
106218 +get_arg_page_32746 get_arg_page 2 32746 NULL
106219 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
106220 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
106221 +begin_cmd_32766 begin_cmd 0 32766 NULL
106222 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
106223 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
106224 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
106225 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
106226 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
106227 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
106228 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
106229 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
106230 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
106231 +ext4_get_group_number_32899 ext4_get_group_number 0-2 32899 NULL
106232 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
106233 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
106234 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
106235 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
106236 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
106237 +xfs_log_reserve_32959 xfs_log_reserve 2 32959 NULL
106238 +ext4_group_overhead_blocks_32971 ext4_group_overhead_blocks 0 32971 NULL
106239 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
106240 +compat_filldir_32999 compat_filldir 3 32999 NULL
106241 +btrfs_lookup_extent_info_33000 btrfs_lookup_extent_info 0 33000 NULL
106242 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3-0 33007 NULL nohasharray
106243 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
106244 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
106245 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
106246 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
106247 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
106248 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
106249 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
106250 +bitmap_resize_33054 bitmap_resize 2-3 33054 NULL
106251 +intel_ring_flush_all_caches_33059 intel_ring_flush_all_caches 0 33059 NULL
106252 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
106253 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
106254 +alloc_tio_33077 alloc_tio 3 33077 NULL
106255 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
106256 +write_node_33121 write_node 4 33121 NULL
106257 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
106258 +__len_within_target_33132 __len_within_target 0 33132 NULL
106259 +SyS_poll_33152 SyS_poll 2 33152 NULL
106260 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
106261 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
106262 +pp_read_33210 pp_read 3 33210 NULL
106263 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL nohasharray
106264 +i915_gem_object_wait_rendering__tail_33234 i915_gem_object_wait_rendering__tail 0 33234 &xfs_file_aio_write_33234
106265 +__vb2_wait_for_done_vb_33246 __vb2_wait_for_done_vb 0 33246 NULL
106266 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
106267 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
106268 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
106269 +btrfs_delete_one_dir_name_33303 btrfs_delete_one_dir_name 0 33303 NULL
106270 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
106271 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
106272 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
106273 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
106274 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
106275 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
106276 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
106277 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
106278 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
106279 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
106280 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
106281 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
106282 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 3-2 33394 NULL
106283 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
106284 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
106285 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
106286 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
106287 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
106288 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
106289 +ubh_scanc_33436 ubh_scanc 0-3-4 33436 NULL
106290 +message_stats_list_33440 message_stats_list 5 33440 NULL
106291 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
106292 +create_entry_33479 create_entry 2 33479 NULL
106293 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
106294 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
106295 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
106296 +res_counter_read_33499 res_counter_read 4 33499 NULL
106297 +fb_read_33506 fb_read 3 33506 NULL
106298 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
106299 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
106300 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
106301 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
106302 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
106303 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 NULL nohasharray
106304 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 &osc_max_rpcs_in_flight_seq_write_33539
106305 +read_symlink_33572 read_symlink 0 33572 NULL
106306 +count_subheaders_33591 count_subheaders 0 33591 NULL
106307 +scsi_execute_33596 scsi_execute 5 33596 NULL
106308 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
106309 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
106310 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
106311 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
106312 +do_sync_write_33624 do_sync_write 0 33624 NULL
106313 +stride_page_count_33641 stride_page_count 2 33641 NULL
106314 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
106315 +inw_p_33668 inw_p 0 33668 NULL
106316 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
106317 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
106318 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
106319 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
106320 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
106321 +ext4_wb_update_i_disksize_33717 ext4_wb_update_i_disksize 2 33717 NULL
106322 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
106323 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
106324 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL nohasharray
106325 +ocfs2_lock_allocators_move_extents_33723 ocfs2_lock_allocators_move_extents 0 33723 &write_file_spectral_count_33723
106326 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
106327 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
106328 +hashtab_create_33769 hashtab_create 3 33769 NULL
106329 +btrfs_delayed_refs_qgroup_accounting_33775 btrfs_delayed_refs_qgroup_accounting 0 33775 NULL
106330 +irq_map_generic_chip_33793 irq_map_generic_chip 2 33793 NULL
106331 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
106332 +find_next_offset_33804 find_next_offset 3-0 33804 NULL
106333 +filter_write_33819 filter_write 3 33819 NULL
106334 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
106335 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
106336 +ext4_journal_extend_33835 ext4_journal_extend 2-0 33835 NULL
106337 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
106338 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
106339 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
106340 +bin_string_33884 bin_string 3-5 33884 NULL
106341 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
106342 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
106343 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
106344 +atomic64_add_return_33927 atomic64_add_return 0-1 33927 NULL
106345 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
106346 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
106347 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL nohasharray
106348 +btrfs_uuid_tree_rem_33944 btrfs_uuid_tree_rem 0 33944 &read_file_tgt_rx_stats_33944
106349 +hfsplus_osx_setxattr_33952 hfsplus_osx_setxattr 4 33952 NULL
106350 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
106351 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
106352 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
106353 +snd_interval_refine_33987 snd_interval_refine 0 33987 NULL
106354 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
106355 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
106356 +ppp_write_34034 ppp_write 3 34034 NULL
106357 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
106358 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
106359 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
106360 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
106361 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
106362 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
106363 +i915_gem_object_set_cache_level_34107 i915_gem_object_set_cache_level 0 34107 NULL nohasharray
106364 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 &i915_gem_object_set_cache_level_34107
106365 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
106366 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
106367 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
106368 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
106369 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
106370 +ext4_xattr_list_34162 ext4_xattr_list 3 34162 NULL
106371 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
106372 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
106373 +dtf_write_run_34196 dtf_write_run 3 34196 NULL
106374 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
106375 +i915_gem_execbuffer_reserve_object_34224 i915_gem_execbuffer_reserve_object 0 34224 NULL
106376 +setup_nodes_for_search_34248 setup_nodes_for_search 0 34248 NULL
106377 +numa_migrate_prep_34256 numa_migrate_prep 0 34256 NULL
106378 +btrfs_bitmap_cluster_34257 btrfs_bitmap_cluster 4 34257 NULL
106379 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
106380 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
106381 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
106382 +device_private_init_34279 device_private_init 0 34279 NULL
106383 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
106384 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
106385 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
106386 +SYSC_brk_34331 SYSC_brk 1 34331 NULL
106387 +__insert_34349 __insert 2-3 34349 NULL
106388 +sync_page_io_34363 sync_page_io 3 34363 NULL nohasharray
106389 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 &sync_page_io_34363
106390 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
106391 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
106392 +ea_read_34378 ea_read 0 34378 NULL
106393 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
106394 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
106395 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
106396 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
106397 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
106398 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
106399 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
106400 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
106401 +security_socket_create_34439 security_socket_create 0 34439 NULL
106402 +usbtest_alloc_urb_34446 usbtest_alloc_urb 5-3 34446 NULL
106403 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
106404 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
106405 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
106406 +ocfs2_block_group_clear_bits_34484 ocfs2_block_group_clear_bits 0 34484 NULL
106407 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
106408 +SyS_pwritev_34494 SyS_pwritev 3 34494 NULL nohasharray
106409 +__ffs64_34494 __ffs64 1-0 34494 &SyS_pwritev_34494
106410 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
106411 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
106412 +snd_pcm_hw_param_value_34525 snd_pcm_hw_param_value 0 34525 NULL
106413 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 NULL nohasharray
106414 +tracing_stats_read_34537 tracing_stats_read 3 34537 &ext4_fallocate_34537
106415 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
106416 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
106417 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL nohasharray
106418 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 &alloc_ieee80211_rsl_34564
106419 +i915_gem_execbuffer_relocate_object_34575 i915_gem_execbuffer_relocate_object 0 34575 NULL
106420 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
106421 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
106422 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
106423 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
106424 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
106425 +__add_prelim_ref_34600 __add_prelim_ref 0 34600 NULL
106426 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
106427 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL nohasharray
106428 +mtd_write_34609 mtd_write 0 34609 &__jffs2_ref_totlen_34609
106429 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
106430 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
106431 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
106432 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
106433 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
106434 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
106435 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
106436 +port_print_34704 port_print 3 34704 NULL
106437 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
106438 +ext4_listxattr_34712 ext4_listxattr 3 34712 NULL
106439 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
106440 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
106441 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
106442 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
106443 +device_add_34766 device_add 0 34766 NULL
106444 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
106445 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
106446 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
106447 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
106448 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
106449 +file_page_index_34820 file_page_index 0-2 34820 NULL
106450 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
106451 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
106452 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
106453 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
106454 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
106455 +msg_print_text_34889 msg_print_text 0 34889 NULL
106456 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
106457 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
106458 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
106459 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
106460 +ODM_AllocateMemory_34929 ODM_AllocateMemory 3 34929 NULL
106461 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
106462 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
106463 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
106464 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
106465 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
106466 +mq_lookup_34990 mq_lookup 2 34990 NULL
106467 +i915_gem_gtt_prepare_object_34991 i915_gem_gtt_prepare_object 0 34991 NULL
106468 +schedule_erase_34996 schedule_erase 0 34996 NULL
106469 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
106470 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
106471 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
106472 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
106473 +snd_pcm_hw_params_35020 snd_pcm_hw_params 0 35020 NULL
106474 +process_changed_xattr_35025 process_changed_xattr 0 35025 NULL
106475 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
106476 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
106477 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
106478 +ext4_split_unwritten_extents_35063 ext4_split_unwritten_extents 0 35063 NULL
106479 +store_ifalias_35088 store_ifalias 4 35088 NULL
106480 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
106481 +capi_write_35104 capi_write 3 35104 NULL nohasharray
106482 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
106483 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
106484 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
106485 +message_stats_print_35158 message_stats_print 6 35158 NULL
106486 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
106487 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
106488 +relocate_entry_cpu_35176 relocate_entry_cpu 0 35176 NULL
106489 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
106490 +SyS_init_module_35180 SyS_init_module 2 35180 NULL
106491 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
106492 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
106493 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
106494 +striped_read_35218 striped_read 0-3-2 35218 NULL nohasharray
106495 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
106496 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
106497 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
106498 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL nohasharray
106499 +may_commit_transaction_35234 may_commit_transaction 0 35234 &gfn_to_page_many_atomic_35234
106500 +SYSC_madvise_35241 SYSC_madvise 1-2 35241 NULL
106501 +set_fd_set_35249 set_fd_set 1 35249 NULL
106502 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
106503 +alloc_thread_groups_35256 alloc_thread_groups 2 35256 NULL
106504 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
106505 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
106506 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
106507 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
106508 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
106509 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
106510 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
106511 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
106512 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
106513 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
106514 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
106515 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
106516 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
106517 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
106518 +amd_iommu_map_35355 amd_iommu_map 4 35355 NULL
106519 +read_kmem_35372 read_kmem 3 35372 NULL
106520 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
106521 +create_pending_snapshots_35402 create_pending_snapshots 0 35402 NULL
106522 +btrfs_search_old_slot_35406 btrfs_search_old_slot 0 35406 NULL
106523 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
106524 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
106525 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
106526 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
106527 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
106528 +memcg_memory_allocated_read_35469 memcg_memory_allocated_read 0 35469 NULL
106529 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
106530 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4-0 35500 NULL
106531 +async_setkey_35521 async_setkey 3 35521 NULL
106532 +inet_mask_len_35527 inet_mask_len 1 35527 NULL
106533 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
106534 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
106535 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
106536 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
106537 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
106538 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
106539 +send_update_extent_35556 send_update_extent 0 35556 NULL
106540 +vb2_dqbuf_35559 vb2_dqbuf 0 35559 NULL
106541 +sysfs_create_subdir_35567 sysfs_create_subdir 0 35567 NULL
106542 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
106543 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
106544 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
106545 +kernel_readv_35617 kernel_readv 3 35617 NULL
106546 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
106547 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
106548 +nv50_vm_create_35643 nv50_vm_create 2-3 35643 NULL
106549 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
106550 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
106551 +ext3_mark_iloc_dirty_35686 ext3_mark_iloc_dirty 0 35686 NULL
106552 +dm_table_create_35687 dm_table_create 3 35687 NULL
106553 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
106554 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
106555 +md_super_write_35703 md_super_write 4 35703 NULL
106556 +btrfs_commit_transaction_35725 btrfs_commit_transaction 0 35725 NULL
106557 +rtw_IOL_cmd_tx_pkt_buf_dump_35732 rtw_IOL_cmd_tx_pkt_buf_dump 2 35732 NULL
106558 +ext4_truncate_restart_trans_35750 ext4_truncate_restart_trans 0 35750 NULL
106559 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
106560 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
106561 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
106562 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
106563 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
106564 +changed_xattr_35860 changed_xattr 0 35860 NULL
106565 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
106566 +fls64_35862 fls64 0 35862 NULL
106567 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
106568 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
106569 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
106570 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
106571 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
106572 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
106573 +balance_node_right_35920 balance_node_right 0 35920 NULL
106574 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
106575 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
106576 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
106577 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
106578 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
106579 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
106580 +acl_alloc_35979 acl_alloc 1 35979 NULL
106581 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
106582 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
106583 +write_file_antenna_35998 write_file_antenna 3 35998 NULL nohasharray
106584 +kuc_alloc_35998 kuc_alloc 1 35998 &write_file_antenna_35998
106585 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
106586 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
106587 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0-6-5 36029 NULL
106588 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
106589 +account_shadowed_36048 account_shadowed 2 36048 NULL
106590 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
106591 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
106592 +did_create_dir_36062 did_create_dir 0 36062 NULL
106593 +write_emulate_36065 write_emulate 2-4 36065 NULL
106594 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
106595 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
106596 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
106597 +ext3_new_blocks_36073 ext3_new_blocks 3-0 36073 NULL
106598 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
106599 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
106600 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
106601 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
106602 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
106603 +compat_ptrace_request_36131 compat_ptrace_request 3 36131 NULL
106604 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
106605 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
106606 +set_flexbg_block_bitmap_36136 set_flexbg_block_bitmap 0-4-5 36136 NULL
106607 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
106608 +twl_set_36154 twl_set 2 36154 NULL
106609 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
106610 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
106611 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
106612 +wm8994_edge_irq_map_36170 wm8994_edge_irq_map 2 36170 NULL
106613 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
106614 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
106615 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
106616 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 5-3 36216 NULL
106617 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
106618 +is_dirty_36223 is_dirty 2 36223 NULL
106619 +ept_walk_addr_36226 ept_walk_addr 3 36226 NULL
106620 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
106621 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
106622 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
106623 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
106624 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
106625 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
106626 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
106627 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276
106628 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
106629 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
106630 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
106631 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
106632 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
106633 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
106634 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
106635 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
106636 +lc_create_36332 lc_create 4 36332 NULL
106637 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
106638 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
106639 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
106640 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
106641 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
106642 +to_sector_36361 to_sector 0-1 36361 NULL
106643 +irq_domain_disassociate_36367 irq_domain_disassociate 2 36367 NULL
106644 +posix_acl_create_36383 posix_acl_create 0 36383 NULL
106645 +tunables_read_36385 tunables_read 3 36385 NULL
106646 +afs_alloc_flat_call_36399 afs_alloc_flat_call 3-2 36399 NULL
106647 +sierra_write_36402 sierra_write 4 36402 NULL
106648 +msb_update_block_36412 msb_update_block 2 36412 NULL
106649 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
106650 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
106651 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
106652 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
106653 +check_extent_in_eb_36467 check_extent_in_eb 0 36467 NULL
106654 +SyS_process_vm_writev_36476 SyS_process_vm_writev 5-3 36476 NULL
106655 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
106656 +set_var_mtrr_range_36483 set_var_mtrr_range 2 36483 NULL
106657 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
106658 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
106659 +cmd_loop_36491 cmd_loop 0 36491 NULL
106660 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
106661 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
106662 +get_param_l_36518 get_param_l 0 36518 NULL
106663 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
106664 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
106665 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
106666 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
106667 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL nohasharray
106668 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
106669 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
106670 +__erst_read_36579 __erst_read 0 36579 NULL
106671 +put_cmsg_36589 put_cmsg 4 36589 NULL
106672 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
106673 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
106674 +i915_gem_execbuffer_relocate_slow_36634 i915_gem_execbuffer_relocate_slow 0 36634 NULL
106675 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
106676 +convert_extent_item_v0_36645 convert_extent_item_v0 4-0 36645 NULL
106677 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
106678 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
106679 +perf_calculate_period_36662 perf_calculate_period 2-3 36662 NULL
106680 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
106681 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
106682 +xillybus_read_36678 xillybus_read 3 36678 NULL
106683 +tlv_put_btrfs_timespec_36685 tlv_put_btrfs_timespec 0 36685 NULL nohasharray
106684 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 &tlv_put_btrfs_timespec_36685
106685 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
106686 +sched_clock_36717 sched_clock 0 36717 NULL
106687 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
106688 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
106689 +cxgbi_device_register_36746 cxgbi_device_register 2-1 36746 NULL
106690 +fc_exch_mgr_alloc_36751 fc_exch_mgr_alloc 3-4 36751 NULL
106691 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
106692 +ext4_ext_convert_to_initialized_36765 ext4_ext_convert_to_initialized 0 36765 NULL
106693 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
106694 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
106695 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
106696 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
106697 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
106698 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
106699 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
106700 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
106701 +cm_write_36858 cm_write 3 36858 NULL
106702 +range_to_mtrr_with_hole_36861 range_to_mtrr_with_hole 2 36861 NULL
106703 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
106704 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
106705 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
106706 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
106707 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
106708 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
106709 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
106710 +audio_set_endpoint_req_36918 audio_set_endpoint_req 0 36918 NULL
106711 +build_key_36931 build_key 1 36931 NULL
106712 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
106713 +div_u64_36951 div_u64 0 36951 NULL
106714 +write_leb_36957 write_leb 0-5 36957 NULL
106715 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
106716 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
106717 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
106718 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
106719 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
106720 +setxattr_37006 setxattr 4 37006 NULL
106721 +btrfs_update_root_37035 btrfs_update_root 0 37035 NULL
106722 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
106723 +command_file_read_37038 command_file_read 3 37038 NULL
106724 +__hfsplus_brec_find_37048 __hfsplus_brec_find 0 37048 NULL
106725 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
106726 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
106727 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
106728 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
106729 +parse_command_37079 parse_command 2 37079 NULL
106730 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
106731 +tun_get_user_37094 tun_get_user 5 37094 NULL
106732 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
106733 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
106734 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
106735 +msg_word_37164 msg_word 0 37164 NULL
106736 +BeceemNVMRead_37166 BeceemNVMRead 0 37166 NULL
106737 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
106738 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
106739 +btrfs_insert_delayed_items_37191 btrfs_insert_delayed_items 0 37191 NULL
106740 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
106741 +sysfs_add_file_37200 sysfs_add_file 0 37200 NULL
106742 +mpol_misplaced_37205 mpol_misplaced 0 37205 NULL
106743 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
106744 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
106745 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 0-4 37212 &crypto_shash_descsize_37212
106746 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 2-0 37213 NULL
106747 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
106748 +__do_replace_37227 __do_replace 5 37227 NULL
106749 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
106750 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
106751 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
106752 +BeceemFlashBulkWrite_37255 BeceemFlashBulkWrite 0 37255 NULL
106753 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
106754 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
106755 +__add_keyed_refs_37264 __add_keyed_refs 0 37264 NULL
106756 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
106757 +create_cq_user_37278 create_cq_user 5 37278 NULL
106758 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
106759 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
106760 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
106761 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
106762 +send_msg_37323 send_msg 4 37323 NULL
106763 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
106764 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
106765 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
106766 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
106767 +lz4_compressbound_37337 lz4_compressbound 0-1 37337 NULL
106768 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
106769 +cl_io_submit_rw_37374 cl_io_submit_rw 0 37374 NULL
106770 +iterate_leaf_refs_37385 iterate_leaf_refs 0 37385 NULL
106771 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
106772 +btrfs_find_free_objectid_37412 btrfs_find_free_objectid 0 37412 NULL
106773 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
106774 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
106775 +find_next_bit_37422 find_next_bit 0-3-2 37422 &acpi_os_allocate_zeroed_37422
106776 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
106777 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
106778 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
106779 +fru_alloc_37442 fru_alloc 1 37442 NULL
106780 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
106781 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
106782 +__remove_37457 __remove 2 37457 NULL
106783 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
106784 +get_est_timing_37484 get_est_timing 0 37484 NULL
106785 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
106786 +__hfsplus_setxattr_37499 __hfsplus_setxattr 4 37499 NULL
106787 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
106788 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
106789 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
106790 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 &bdev_writeseg_37519
106791 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL
106792 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
106793 +hdr_size_37536 hdr_size 0 37536 NULL
106794 +extent_map_end_37550 extent_map_end 0 37550 NULL
106795 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
106796 +ioat_chansts_37558 ioat_chansts 0 37558 NULL
106797 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
106798 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
106799 +alloc_descs_37593 alloc_descs 0-1 37593 NULL
106800 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
106801 +find_extent_clone_37603 find_extent_clone 0 37603 NULL
106802 +btrfs_write_and_wait_marked_extents_37604 btrfs_write_and_wait_marked_extents 0 37604 NULL
106803 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
106804 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
106805 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
106806 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
106807 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
106808 +alloc_fd_37637 alloc_fd 1 37637 NULL
106809 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
106810 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
106811 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
106812 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
106813 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
106814 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
106815 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
106816 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
106817 +page_chain_free_37697 page_chain_free 0 37697 NULL
106818 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
106819 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
106820 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
106821 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
106822 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
106823 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
106824 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 5-4-6 37749 NULL
106825 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
106826 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
106827 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
106828 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
106829 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
106830 +deny_write_access_37813 deny_write_access 0 37813 NULL
106831 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
106832 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
106833 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-0-5-4 37827 NULL
106834 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
106835 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
106836 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
106837 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
106838 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
106839 +set_registers_37883 set_registers 4 37883 NULL
106840 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
106841 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
106842 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
106843 +_rtw_malloc_37928 _rtw_malloc 1 37928 NULL nohasharray
106844 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 &_rtw_malloc_37928
106845 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
106846 +write_file_bool_37957 write_file_bool 3 37957 NULL
106847 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
106848 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 4-3 37967 NULL
106849 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
106850 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
106851 +vfs_readv_38011 vfs_readv 3 38011 NULL
106852 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
106853 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
106854 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
106855 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
106856 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
106857 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
106858 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
106859 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
106860 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
106861 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
106862 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
106863 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
106864 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
106865 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
106866 +ep0_read_38095 ep0_read 3 38095 NULL
106867 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
106868 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
106869 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
106870 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
106871 +_get_val_38115 _get_val 2 38115 NULL
106872 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
106873 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 0-4-3 38153 NULL
106874 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
106875 +cirrus_ttm_tt_create_38167 cirrus_ttm_tt_create 2 38167 NULL
106876 +send_rename_38170 send_rename 0 38170 NULL
106877 +cdev_add_38176 cdev_add 2-3 38176 NULL
106878 +create_srq_user_38191 create_srq_user 5 38191 NULL
106879 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
106880 +do_chunk_alloc_38200 do_chunk_alloc 0 38200 NULL
106881 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
106882 +ext3_new_block_38208 ext3_new_block 3-0 38208 NULL
106883 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
106884 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
106885 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
106886 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
106887 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
106888 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
106889 +from_dblock_38256 from_dblock 0-1 38256 NULL
106890 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 3-2 38260 NULL
106891 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 NULL nohasharray
106892 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 &SYSC_msgrcv_38268 nohasharray
106893 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
106894 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 NULL nohasharray
106895 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 &xfs_bmdr_to_bmbt_38275
106896 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
106897 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
106898 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
106899 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
106900 +ida_simple_get_38326 ida_simple_get 2-0 38326 NULL
106901 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
106902 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
106903 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
106904 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL
106905 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
106906 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
106907 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 0-2 38413 NULL
106908 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
106909 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
106910 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
106911 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
106912 +btrfs_next_old_leaf_38465 btrfs_next_old_leaf 0 38465 NULL
106913 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
106914 +blk_end_bidi_request_38482 blk_end_bidi_request 4-3 38482 NULL
106915 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
106916 +dev_names_read_38509 dev_names_read 3 38509 NULL
106917 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
106918 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
106919 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
106920 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
106921 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
106922 +kuc_len_38557 kuc_len 0-1 38557 NULL
106923 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
106924 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
106925 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
106926 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
106927 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
106928 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
106929 +compat_sys_ptrace_38595 compat_sys_ptrace 3 38595 NULL
106930 +blkg_stat_read_38612 blkg_stat_read 0 38612 NULL
106931 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
106932 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
106933 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
106934 +cma_create_area_38642 cma_create_area 2 38642 NULL
106935 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
106936 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
106937 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
106938 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
106939 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
106940 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
106941 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
106942 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
106943 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
106944 +find_next_usable_block_38716 find_next_usable_block 3-1-0 38716 NULL
106945 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
106946 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
106947 +udf_readpages_38761 udf_readpages 4 38761 NULL
106948 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
106949 +bcache_device_init_38781 bcache_device_init 3 38781 NULL
106950 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
106951 +slab_order_38794 slab_order 0 38794 NULL
106952 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
106953 +err_decode_38804 err_decode 2 38804 NULL
106954 +btrfs_find_space_cluster_38812 btrfs_find_space_cluster 4-0 38812 NULL
106955 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
106956 +direct_entry_38836 direct_entry 3 38836 NULL
106957 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
106958 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
106959 +interfaces_38859 interfaces 2 38859 NULL
106960 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
106961 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
106962 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
106963 +traverse_38897 traverse 0 38897 NULL
106964 +__fswab16_38898 __fswab16 0 38898 NULL
106965 +ext3_trim_all_free_38929 ext3_trim_all_free 4-3-2 38929 NULL
106966 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
106967 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
106968 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
106969 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
106970 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
106971 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
106972 +udf_new_block_38999 udf_new_block 4 38999 NULL
106973 +get_nodes_39012 get_nodes 3 39012 NULL
106974 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
106975 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3-0 39020 NULL
106976 +qgroup_account_ref_step1_39024 qgroup_account_ref_step1 0 39024 NULL
106977 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
106978 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
106979 +do_write_kmem_39051 do_write_kmem 1-3-0 39051 NULL
106980 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
106981 +atomic64_add_negative_39098 atomic64_add_negative 1 39098 NULL
106982 +ReadHFC_39104 ReadHFC 0 39104 NULL
106983 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
106984 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
106985 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
106986 +ttm_mem_global_alloc_zone_39125 ttm_mem_global_alloc_zone 0 39125 NULL
106987 +ea_foreach_39133 ea_foreach 0 39133 NULL
106988 +generic_permission_39150 generic_permission 0 39150 NULL
106989 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
106990 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
106991 +btrfs_start_delalloc_flush_39173 btrfs_start_delalloc_flush 0 39173 NULL
106992 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
106993 +ubi_more_update_data_39189 ubi_more_update_data 4-0 39189 NULL
106994 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
106995 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
106996 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
106997 +drm_order_39244 drm_order 0 39244 NULL
106998 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
106999 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
107000 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
107001 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
107002 +bitmap_set_bits_39272 bitmap_set_bits 3 39272 NULL
107003 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
107004 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
107005 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
107006 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3-0 39327 NULL
107007 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
107008 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3-0 39351 NULL
107009 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
107010 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
107011 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
107012 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
107013 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
107014 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
107015 +__send_to_port_39386 __send_to_port 3 39386 NULL
107016 +perf_trace_buf_submit_39413 perf_trace_buf_submit 5 39413 NULL
107017 +user_power_read_39414 user_power_read 3 39414 NULL
107018 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
107019 +__vb2_get_done_vb_39448 __vb2_get_done_vb 0 39448 NULL
107020 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
107021 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
107022 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
107023 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
107024 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
107025 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
107026 +int_proc_write_39542 int_proc_write 3 39542 NULL
107027 +pp_write_39554 pp_write 3 39554 NULL
107028 +ol_dqblk_block_39558 ol_dqblk_block 2-0-3 39558 NULL
107029 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
107030 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
107031 +ext_depth_39607 ext_depth 0 39607 NULL
107032 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
107033 +sdio_readb_39618 sdio_readb 0 39618 NULL
107034 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
107035 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
107036 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
107037 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
107038 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
107039 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
107040 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
107041 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
107042 +vmx_set_cr3_39688 vmx_set_cr3 2 39688 NULL
107043 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
107044 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
107045 +test_add_free_space_entry_39754 test_add_free_space_entry 2-3 39754 NULL
107046 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
107047 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
107048 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
107049 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
107050 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
107051 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
107052 +can_rmdir_39890 can_rmdir 0 39890 NULL
107053 +pkt_add_39897 pkt_add 3 39897 NULL
107054 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
107055 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
107056 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
107057 +dma_to_mm_pfn_39916 dma_to_mm_pfn 0-1 39916 NULL
107058 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
107059 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
107060 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
107061 +__spi_async_39932 __spi_async 0 39932 NULL
107062 +__get_order_39935 __get_order 0 39935 NULL
107063 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
107064 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
107065 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
107066 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
107067 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
107068 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
107069 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
107070 +server_name2svname_39998 server_name2svname 4 39998 NULL
107071 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
107072 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
107073 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
107074 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
107075 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
107076 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
107077 +ocfs2_claim_clusters_40050 ocfs2_claim_clusters 0 40050 NULL
107078 +add_tty_40055 add_tty 1 40055 NULL nohasharray
107079 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
107080 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
107081 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
107082 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
107083 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
107084 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
107085 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
107086 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
107087 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
107088 +clone_backref_node_40154 clone_backref_node 0 40154 NULL
107089 +pt_write_40159 pt_write 3 40159 NULL
107090 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
107091 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
107092 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
107093 +allocate_probes_40204 allocate_probes 1 40204 NULL
107094 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
107095 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
107096 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
107097 +osst_read_40237 osst_read 3 40237 NULL
107098 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
107099 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
107100 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
107101 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
107102 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
107103 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
107104 +vfio_unmap_unpin_40284 vfio_unmap_unpin 3 40284 NULL
107105 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
107106 +SyS_bind_40303 SyS_bind 3 40303 NULL
107107 +ubi_io_write_data_40305 ubi_io_write_data 0-5-4 40305 NULL
107108 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
107109 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
107110 +mmio_read_40348 mmio_read 4 40348 NULL
107111 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4-0 40355 NULL
107112 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
107113 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 3-2 40365 NULL
107114 +get_chars_40373 get_chars 3 40373 NULL
107115 +submit_page_section_40408 submit_page_section 0 40408 NULL
107116 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
107117 +slab_node_40421 slab_node 0 40421 NULL
107118 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
107119 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
107120 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
107121 +SyS_writev_40467 SyS_writev 3 40467 NULL
107122 +__i915_add_request_40469 __i915_add_request 0 40469 NULL
107123 +SyS_select_40473 SyS_select 1 40473 NULL
107124 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
107125 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
107126 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
107127 +drm_vma_node_start_40500 drm_vma_node_start 0 40500 NULL
107128 +sg_phys_40507 sg_phys 0 40507 NULL
107129 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
107130 +TSS_checkhmac2_40520 TSS_checkhmac2 7-5 40520 NULL
107131 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
107132 +i915_gem_execbuffer_relocate_object_slow_40546 i915_gem_execbuffer_relocate_object_slow 0 40546 NULL
107133 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
107134 +btrfs_flush_all_pending_stuffs_40553 btrfs_flush_all_pending_stuffs 0 40553 NULL
107135 +esp_alloc_tmp_40558 esp_alloc_tmp 2-3 40558 NULL
107136 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
107137 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
107138 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
107139 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
107140 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
107141 +qla8044_rd_reg_40652 qla8044_rd_reg 0 40652 NULL
107142 +pid_nr_ns_40654 pid_nr_ns 0 40654 NULL
107143 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
107144 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
107145 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
107146 +fops_read_40672 fops_read 3 40672 NULL
107147 +ext4_mark_inode_dirty_40673 ext4_mark_inode_dirty 0 40673 NULL
107148 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
107149 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
107150 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3-4 40678 NULL
107151 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
107152 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
107153 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
107154 +btrfs_find_one_extref_40724 btrfs_find_one_extref 0 40724 NULL
107155 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
107156 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
107157 +find_next_zero_bit_le_40744 find_next_zero_bit_le 2-3-0 40744 &xfs_iext_remove_direct_40744
107158 +i915_gem_execbuffer_relocate_entry_40750 i915_gem_execbuffer_relocate_entry 0 40750 NULL
107159 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
107160 +card_send_command_40757 card_send_command 3 40757 NULL
107161 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
107162 +pg_write_40766 pg_write 3 40766 NULL
107163 +show_list_40775 show_list 3-0 40775 NULL
107164 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
107165 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
107166 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
107167 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
107168 +add_action_40811 add_action 4 40811 NULL
107169 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
107170 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
107171 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
107172 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
107173 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
107174 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
107175 +read_file_queue_40895 read_file_queue 3 40895 NULL
107176 +btrfs_set_inode_index_count_40901 btrfs_set_inode_index_count 0 40901 NULL
107177 +waiters_read_40902 waiters_read 3 40902 NULL
107178 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
107179 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
107180 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
107181 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
107182 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
107183 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
107184 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
107185 +btrfs_find_orphan_item_40977 btrfs_find_orphan_item 0 40977 NULL
107186 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
107187 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
107188 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
107189 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
107190 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
107191 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
107192 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
107193 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
107194 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
107195 +BcmFlash2xBulkWrite_41054 BcmFlash2xBulkWrite 0 41054 NULL
107196 +calculate_order_41061 calculate_order 0 41061 NULL
107197 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
107198 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
107199 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
107200 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
107201 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 &roccat_read_41093
107202 +dma_attach_41094 dma_attach 6-5 41094 NULL
107203 +provide_user_output_41105 provide_user_output 3 41105 NULL
107204 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
107205 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
107206 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
107207 +btrfs_subvolume_reserve_metadata_41130 btrfs_subvolume_reserve_metadata 3 41130 NULL
107208 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
107209 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
107210 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
107211 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
107212 +dgap_driver_kzmalloc_41189 dgap_driver_kzmalloc 1 41189 NULL
107213 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
107214 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
107215 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
107216 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
107217 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
107218 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
107219 +create_dir_41256 create_dir 0 41256 NULL
107220 +erst_read_41260 erst_read 0 41260 NULL
107221 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4-0 41270 NULL
107222 +alloc_context_41283 alloc_context 1 41283 NULL
107223 +objio_alloc_io_state_41316 objio_alloc_io_state 7-6 41316 NULL
107224 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
107225 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
107226 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
107227 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
107228 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
107229 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
107230 +kmp_init_41373 kmp_init 2 41373 NULL
107231 +netlink_alloc_large_skb_41375 netlink_alloc_large_skb 1 41375 NULL
107232 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
107233 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
107234 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
107235 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
107236 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
107237 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
107238 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
107239 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4 41442 NULL
107240 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
107241 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
107242 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
107243 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
107244 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
107245 +split_item_41483 split_item 0 41483 NULL
107246 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 3-2 41484 NULL
107247 +ipath_user_sdma_page_length_41490 ipath_user_sdma_page_length 0-2-1 41490 NULL
107248 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
107249 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
107250 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
107251 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
107252 +perf_sw_event_41517 perf_sw_event 2 41517 NULL
107253 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
107254 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
107255 +add_excluded_extent_41547 add_excluded_extent 0 41547 NULL
107256 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
107257 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
107258 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 NULL nohasharray
107259 +nr_status_frames_41559 nr_status_frames 0-1 41559 &si476x_radio_fops_read_41559
107260 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
107261 +vga_io_r_41609 vga_io_r 0 41609 NULL
107262 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
107263 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
107264 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
107265 +a2mp_send_41615 a2mp_send 4 41615 NULL
107266 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
107267 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
107268 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
107269 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
107270 +get_std_timing_41654 get_std_timing 0 41654 NULL
107271 +start_graph_tracing_41656 start_graph_tracing 0 41656 NULL
107272 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
107273 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
107274 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
107275 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
107276 +__ext3_journal_get_write_access_41705 __ext3_journal_get_write_access 0 41705 NULL
107277 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
107278 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
107279 +ocfs2_block_group_fill_41744 ocfs2_block_group_fill 0 41744 NULL
107280 +fillonedir_41746 fillonedir 3 41746 NULL
107281 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
107282 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
107283 +remap_pte_range_41800 remap_pte_range 5 41800 NULL
107284 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
107285 +regcache_sync_block_raw_41803 regcache_sync_block_raw 4-3 41803 NULL
107286 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL
107287 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
107288 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
107289 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
107290 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
107291 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
107292 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
107293 +pci_map_single_41869 pci_map_single 0 41869 NULL
107294 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
107295 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
107296 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
107297 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
107298 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
107299 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
107300 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
107301 +read_gssp_41947 read_gssp 3 41947 NULL
107302 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
107303 +portnames_read_41958 portnames_read 3 41958 NULL
107304 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0-4 41959 NULL
107305 +dst_mtu_41969 dst_mtu 0 41969 NULL
107306 +btrfs_check_trunc_cache_free_space_41973 btrfs_check_trunc_cache_free_space 0 41973 NULL
107307 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
107308 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
107309 +pool_allocate_42012 pool_allocate 3 42012 NULL
107310 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
107311 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
107312 +nouveau_ttm_tt_create_42026 nouveau_ttm_tt_create 2 42026 NULL
107313 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
107314 +__btrfs_drop_extents_42032 __btrfs_drop_extents 5-0 42032 NULL
107315 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
107316 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
107317 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
107318 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
107319 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
107320 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
107321 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
107322 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
107323 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
107324 +send_truncate_42107 send_truncate 0 42107 NULL
107325 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
107326 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
107327 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
107328 +__btrfs_unlink_inode_42114 __btrfs_unlink_inode 0 42114 NULL
107329 +ext4_do_update_inode_42127 ext4_do_update_inode 0 42127 NULL
107330 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
107331 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
107332 +kvm_lapic_get_cr8_42166 kvm_lapic_get_cr8 0 42166 NULL
107333 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
107334 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
107335 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
107336 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
107337 +ocfs2_resv_window_bits_42207 ocfs2_resv_window_bits 0 42207 NULL
107338 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
107339 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
107340 +vfio_remove_dma_overlap_42255 vfio_remove_dma_overlap 2 42255 NULL
107341 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
107342 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
107343 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
107344 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
107345 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
107346 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
107347 +gfn_to_hva_42305 gfn_to_hva 2-0 42305 NULL
107348 +close_cur_inode_file_42308 close_cur_inode_file 0 42308 NULL nohasharray
107349 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 &close_cur_inode_file_42308
107350 +free_cblock_42318 free_cblock 2 42318 NULL
107351 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
107352 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
107353 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
107354 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
107355 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
107356 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
107357 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
107358 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
107359 +krng_get_random_42420 krng_get_random 3 42420 NULL
107360 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
107361 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
107362 +alloc_request_42448 alloc_request 0 42448 NULL
107363 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
107364 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
107365 +kuc_free_42455 kuc_free 2 42455 NULL
107366 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
107367 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
107368 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
107369 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
107370 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
107371 +bypass_write_42498 bypass_write 3 42498 NULL
107372 +SyS_mincore_42511 SyS_mincore 1-2 42511 NULL
107373 +jbd2_log_wait_commit_42519 jbd2_log_wait_commit 0 42519 NULL
107374 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
107375 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
107376 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
107377 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
107378 +__register_ftrace_function_42543 __register_ftrace_function 0 42543 NULL
107379 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
107380 +inorder_next_42548 inorder_next 1-0 42548 NULL
107381 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
107382 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
107383 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
107384 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
107385 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
107386 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
107387 +map_state_42602 map_state 1 42602 NULL
107388 +resp_write_42628 resp_write 2 42628 NULL
107389 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
107390 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
107391 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
107392 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
107393 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
107394 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
107395 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
107396 +vb2_read_42703 vb2_read 3 42703 NULL
107397 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 5-4-0 42717 NULL
107398 +read_status_42722 read_status 0 42722 NULL
107399 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
107400 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
107401 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
107402 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
107403 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
107404 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
107405 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
107406 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
107407 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
107408 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
107409 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
107410 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
107411 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL
107412 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
107413 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
107414 +xfs_iomap_eof_prealloc_initial_size_42822 xfs_iomap_eof_prealloc_initial_size 0-3 42822 NULL
107415 +set_arg_42824 set_arg 3 42824 NULL
107416 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
107417 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
107418 +prandom_u32_42853 prandom_u32 0 42853 NULL
107419 +ntfs_mapping_pairs_build_42859 ntfs_mapping_pairs_build 0 42859 NULL
107420 +nouveau_vm_create_42869 nouveau_vm_create 3-2 42869 NULL
107421 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
107422 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
107423 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
107424 +hd_end_request_42904 hd_end_request 2 42904 NULL
107425 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
107426 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
107427 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
107428 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
107429 +send_link_42948 send_link 0 42948 NULL
107430 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
107431 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
107432 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
107433 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 2-4 42990 NULL nohasharray
107434 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
107435 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
107436 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
107437 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0-3-4 43026 NULL
107438 +init_phys_status_page_43028 init_phys_status_page 0 43028 NULL
107439 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
107440 +send_to_group_43051 send_to_group 0 43051 NULL
107441 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
107442 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
107443 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
107444 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
107445 +cow_file_range_inline_43132 cow_file_range_inline 4 43132 NULL
107446 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
107447 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
107448 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
107449 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
107450 +send_cmd_43168 send_cmd 0 43168 NULL
107451 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
107452 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
107453 +uio_write_43202 uio_write 3 43202 NULL
107454 +iso_callback_43208 iso_callback 3 43208 NULL
107455 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
107456 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
107457 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
107458 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
107459 +fixup_leb_43256 fixup_leb 3 43256 NULL
107460 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
107461 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
107462 +mlx5_ib_reg_user_mr_43275 mlx5_ib_reg_user_mr 2-3 43275 NULL
107463 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 NULL nohasharray
107464 +evtchn_write_43278 evtchn_write 3 43278 &parport_pc_ecp_write_block_pio_43278
107465 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
107466 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
107467 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
107468 +mmu_set_spte_43327 mmu_set_spte 7-6 43327 NULL
107469 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
107470 +kvm_host_page_size_43348 kvm_host_page_size 2-0 43348 NULL
107471 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
107472 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
107473 +xenfb_write_43412 xenfb_write 3 43412 NULL
107474 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL
107475 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
107476 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
107477 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
107478 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
107479 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
107480 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
107481 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
107482 +calculate_discard_block_size_43480 calculate_discard_block_size 0 43480 NULL nohasharray
107483 +alloc_new_reservation_43480 alloc_new_reservation 4-0-2 43480 &calculate_discard_block_size_43480
107484 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
107485 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
107486 +do_readlink_43518 do_readlink 2 43518 NULL
107487 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
107488 +read_events_43534 read_events 3 43534 NULL
107489 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
107490 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
107491 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
107492 +request_resource_43548 request_resource 0 43548 NULL
107493 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
107494 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
107495 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
107496 +proc_read_43614 proc_read 3 43614 NULL
107497 +i915_gem_execbuffer_relocate_object_slow_43618 i915_gem_execbuffer_relocate_object_slow 0 43618 NULL nohasharray
107498 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 &i915_gem_execbuffer_relocate_object_slow_43618
107499 +random_write_43656 random_write 3 43656 NULL
107500 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
107501 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
107502 +fs_path_copy_43673 fs_path_copy 0 43673 NULL
107503 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
107504 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
107505 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
107506 +wait_for_completion_interruptible_43723 wait_for_completion_interruptible 0 43723 NULL
107507 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
107508 +reset_card_proc_43731 reset_card_proc 0 43731 NULL
107509 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
107510 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5-0 43733 NULL
107511 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
107512 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
107513 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
107514 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
107515 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
107516 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
107517 +btrfs_copy_from_user_43806 btrfs_copy_from_user 0-3-1 43806 NULL
107518 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
107519 +div64_u64_safe_43815 div64_u64_safe 2-1 43815 NULL
107520 +ext4_split_extent_43818 ext4_split_extent 0 43818 NULL
107521 +i915_gem_execbuffer_relocate_entry_43822 i915_gem_execbuffer_relocate_entry 0 43822 NULL
107522 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
107523 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
107524 +read_flush_43851 read_flush 3 43851 NULL
107525 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
107526 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
107527 +SendString_43928 SendString 3 43928 NULL
107528 +xen_register_gsi_43946 xen_register_gsi 2-1 43946 NULL
107529 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
107530 +perf_tp_event_43971 perf_tp_event 2 43971 NULL
107531 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
107532 +nla_reserve_43984 nla_reserve 3 43984 NULL
107533 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
107534 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
107535 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
107536 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
107537 +ulist_add_43994 ulist_add 0 43994 NULL
107538 +emit_flags_44006 emit_flags 4-3 44006 NULL
107539 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
107540 +fru_strlen_44046 fru_strlen 0 44046 NULL
107541 +tree_insert_offset_44069 tree_insert_offset 0 44069 NULL
107542 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
107543 +btrfs_prev_leaf_44083 btrfs_prev_leaf 0 44083 NULL nohasharray
107544 +load_discard_44083 load_discard 3 44083 &btrfs_prev_leaf_44083
107545 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 NULL
107546 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
107547 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
107548 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
107549 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
107550 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
107551 +lookup_extent_data_ref_44136 lookup_extent_data_ref 0 44136 NULL
107552 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
107553 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
107554 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
107555 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
107556 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
107557 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
107558 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
107559 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
107560 +__set_free_44211 __set_free 2 44211 NULL
107561 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
107562 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
107563 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
107564 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
107565 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
107566 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
107567 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
107568 +byt_gpio_irq_map_44275 byt_gpio_irq_map 2 44275 NULL
107569 +device_create_file_44285 device_create_file 0 44285 NULL
107570 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
107571 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
107572 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
107573 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
107574 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
107575 +rs_init_44327 rs_init 1 44327 NULL
107576 +create_free_space_inode_44332 create_free_space_inode 0 44332 NULL
107577 +insert_into_bitmap_44340 insert_into_bitmap 0 44340 NULL
107578 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 0-5 44343 NULL
107579 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
107580 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
107581 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
107582 +__is_discarded_44359 __is_discarded 2 44359 NULL
107583 +ipx_recvmsg_44366 ipx_recvmsg 4 44366 NULL
107584 +alloc_requests_44372 alloc_requests 0 44372 NULL
107585 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
107586 +iterate_dir_item_44386 iterate_dir_item 0 44386 NULL
107587 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
107588 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
107589 +strlcpy_44400 strlcpy 3 44400 NULL
107590 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
107591 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
107592 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
107593 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
107594 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
107595 +iwl_dbgfs_bf_params_write_44450 iwl_dbgfs_bf_params_write 3 44450 NULL
107596 +write_file_debug_44476 write_file_debug 3 44476 NULL
107597 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
107598 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
107599 +bio_advance_44496 bio_advance 2 44496 NULL
107600 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
107601 +ac_register_board_44504 ac_register_board 3 44504 NULL
107602 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
107603 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
107604 +spidev_write_44510 spidev_write 3 44510 NULL
107605 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
107606 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
107607 +comm_write_44537 comm_write 3 44537 NULL
107608 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
107609 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
107610 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
107611 +shmem_getpage_gfp_44556 shmem_getpage_gfp 0 44556 NULL
107612 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
107613 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
107614 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
107615 +btrfs_qgroup_account_ref_44604 btrfs_qgroup_account_ref 0 44604 NULL
107616 +huge_page_shift_44618 huge_page_shift 0 44618 NULL
107617 +sysfs_add_one_44629 sysfs_add_one 0 44629 NULL
107618 +msb_get_free_block_44633 msb_get_free_block 2 44633 NULL
107619 +ext2_new_block_44645 ext2_new_block 2-0 44645 NULL
107620 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
107621 +mpi_resize_44674 mpi_resize 2 44674 NULL
107622 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
107623 +__copy_user_intel_nocache_44685 __copy_user_intel_nocache 0-3 44685 &sysfs_create_link_44685
107624 +ts_read_44687 ts_read 3 44687 NULL
107625 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
107626 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
107627 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
107628 +xfer_to_user_44713 xfer_to_user 3 44713 NULL nohasharray
107629 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 &xfer_to_user_44713
107630 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
107631 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
107632 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
107633 +SyS_read_44732 SyS_read 3 44732 NULL
107634 +vm_insert_mixed_44738 vm_insert_mixed 3 44738 NULL
107635 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
107636 +set_brk_44749 set_brk 1-2 44749 NULL
107637 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
107638 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
107639 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
107640 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
107641 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
107642 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
107643 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
107644 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
107645 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
107646 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
107647 +sisusb_write_44834 sisusb_write 3 44834 NULL
107648 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
107649 +cubic_root_44848 cubic_root 1 44848 NULL
107650 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
107651 +copydesc_user_44855 copydesc_user 3 44855 NULL
107652 +i915_gem_execbuffer_relocate_44868 i915_gem_execbuffer_relocate 0 44868 NULL
107653 +init_rs_44873 init_rs 1 44873 NULL
107654 +skb_availroom_44883 skb_availroom 0 44883 NULL
107655 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
107656 +do_tty_write_44896 do_tty_write 5 44896 NULL
107657 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
107658 +_snd_pcm_hw_param_last_44947 _snd_pcm_hw_param_last 0 44947 NULL
107659 +__add_delayed_refs_44977 __add_delayed_refs 0 44977 NULL
107660 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
107661 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
107662 +send_chmod_45011 send_chmod 0 45011 NULL
107663 +i915_gem_do_execbuffer_45012 i915_gem_do_execbuffer 0 45012 NULL
107664 +bytepos_delta_45017 bytepos_delta 0-2 45017 NULL
107665 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
107666 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
107667 +dm_kvzalloc_45025 dm_kvzalloc 1 45025 NULL
107668 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
107669 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
107670 +remap_oldmem_pfn_range_45060 remap_oldmem_pfn_range 2-3-4 45060 NULL nohasharray
107671 +sel_write_user_45060 sel_write_user 3 45060 &remap_oldmem_pfn_range_45060
107672 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
107673 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
107674 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
107675 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
107676 +usbdev_read_45114 usbdev_read 3 45114 NULL
107677 +send_to_tty_45141 send_to_tty 3 45141 NULL
107678 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
107679 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
107680 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
107681 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
107682 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
107683 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
107684 +SYSC_write_45160 SYSC_write 3 45160 NULL
107685 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
107686 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
107687 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
107688 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
107689 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
107690 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
107691 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
107692 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
107693 +__dirty_45228 __dirty 2 45228 NULL
107694 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
107695 +event_enable_write_45238 event_enable_write 3 45238 NULL
107696 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
107697 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
107698 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
107699 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
107700 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
107701 +pte_val_45313 pte_val 0 45313 NULL
107702 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
107703 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
107704 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
107705 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
107706 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
107707 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
107708 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
107709 +SYSC_mremap_45446 SYSC_mremap 5-1-2-3 45446 NULL
107710 +__node_remap_45458 __node_remap 4 45458 NULL
107711 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
107712 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
107713 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
107714 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
107715 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
107716 +i40e_alloc_vfs_45511 i40e_alloc_vfs 2 45511 NULL
107717 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
107718 +copy_macs_45534 copy_macs 4 45534 NULL
107719 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
107720 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
107721 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
107722 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
107723 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
107724 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
107725 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
107726 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
107727 +btrfs_find_free_ino_45585 btrfs_find_free_ino 0 45585 NULL
107728 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
107729 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
107730 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
107731 +commit_cowonly_roots_45640 commit_cowonly_roots 0 45640 NULL
107732 +ebitmap_next_positive_45651 ebitmap_next_positive 3-0 45651 NULL
107733 +ext4_reserve_inode_write_45654 ext4_reserve_inode_write 0 45654 NULL
107734 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
107735 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
107736 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
107737 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
107738 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
107739 +bscnl_emit_45699 bscnl_emit 0-2-5 45699 &unix_dgram_sendmsg_45699
107740 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
107741 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL nohasharray
107742 +task_cgroup_path_45734 task_cgroup_path 3 45734 &snd_cs46xx_io_read_45734
107743 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
107744 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
107745 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
107746 +btrfs_delete_delayed_dir_index_45757 btrfs_delete_delayed_dir_index 0 45757 NULL
107747 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
107748 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
107749 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
107750 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
107751 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
107752 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
107753 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
107754 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
107755 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
107756 +task_state_char_45839 task_state_char 1 45839 NULL
107757 +__ip_select_ident_45851 __ip_select_ident 3 45851 NULL
107758 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
107759 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
107760 +isdn_write_45863 isdn_write 3 45863 NULL
107761 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
107762 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
107763 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
107764 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
107765 +online_page_cgroup_45894 online_page_cgroup 3 45894 NULL
107766 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
107767 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
107768 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
107769 +alloc_mr_45935 alloc_mr 1 45935 NULL
107770 +copy_to_45969 copy_to 3 45969 NULL
107771 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
107772 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
107773 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
107774 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
107775 +get_free_entries_46030 get_free_entries 1 46030 NULL
107776 +__access_remote_vm_46031 __access_remote_vm 0-3-5 46031 NULL
107777 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
107778 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
107779 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6-4-0-3 46060 NULL nohasharray
107780 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
107781 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
107782 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
107783 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
107784 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
107785 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
107786 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
107787 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
107788 +replay_dir_deletes_46136 replay_dir_deletes 0 46136 NULL
107789 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
107790 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2-3 46146 NULL
107791 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
107792 +alloc_iova_46160 alloc_iova 2 46160 NULL
107793 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
107794 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
107795 +fq_resize_46195 fq_resize 2 46195 NULL
107796 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
107797 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
107798 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
107799 +dsp_write_46218 dsp_write 2 46218 NULL
107800 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
107801 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
107802 +ReadReg_46277 ReadReg 0 46277 NULL
107803 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
107804 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL nohasharray
107805 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 &__hwahc_dev_set_key_46328
107806 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
107807 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
107808 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
107809 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
107810 +mmap_ureg_46388 mmap_ureg 3 46388 NULL
107811 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
107812 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
107813 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
107814 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
107815 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
107816 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
107817 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
107818 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
107819 +filldir64_46469 filldir64 3 46469 NULL
107820 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
107821 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
107822 +p9pdu_vreadf_46500 p9pdu_vreadf 0 46500 NULL
107823 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
107824 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
107825 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 NULL nohasharray
107826 +kmsg_read_46514 kmsg_read 3 46514 &nouveau_drm_ioctl_46514
107827 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
107828 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
107829 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
107830 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
107831 +dn_current_mss_46574 dn_current_mss 0 46574 NULL nohasharray
107832 +blk_flush_complete_seq_46574 blk_flush_complete_seq 2 46574 &dn_current_mss_46574
107833 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
107834 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
107835 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
107836 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
107837 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
107838 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
107839 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
107840 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
107841 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
107842 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
107843 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
107844 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
107845 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
107846 +ide_read_status_46719 ide_read_status 0 46719 NULL
107847 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
107848 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
107849 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
107850 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
107851 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
107852 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
107853 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
107854 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
107855 +btrfs_insert_empty_items_46822 btrfs_insert_empty_items 0 46822 NULL
107856 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
107857 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
107858 +readreg_46845 readreg 0 46845 NULL
107859 +spi_async_46857 spi_async 0 46857 NULL
107860 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
107861 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
107862 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
107863 +rvmalloc_46873 rvmalloc 1 46873 NULL
107864 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
107865 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
107866 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
107867 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
107868 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
107869 +ol_dqblk_off_46904 ol_dqblk_off 2-3 46904 NULL
107870 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
107871 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
107872 +fb_write_46924 fb_write 3 46924 NULL
107873 +i915_gem_check_olr_46925 i915_gem_check_olr 0 46925 NULL
107874 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
107875 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
107876 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
107877 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
107878 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
107879 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
107880 +strlcat_46985 strlcat 3 46985 NULL
107881 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
107882 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
107883 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
107884 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
107885 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
107886 +__map_single_47020 __map_single 3-4-7-0 47020 NULL
107887 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
107888 +fs_path_len_47060 fs_path_len 0 47060 NULL
107889 +ufs_new_fragments_47070 ufs_new_fragments 4-3-5 47070 NULL nohasharray
107890 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0-4 47070 &ufs_new_fragments_47070
107891 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
107892 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
107893 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
107894 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL
107895 +tboot_log_read_47110 tboot_log_read 3 47110 NULL
107896 +mousedev_read_47123 mousedev_read 3 47123 NULL
107897 +ubi_compare_lebs_47141 ubi_compare_lebs 0 47141 NULL
107898 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
107899 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
107900 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
107901 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
107902 +bpf_alloc_binary_47170 bpf_alloc_binary 1 47170 NULL
107903 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
107904 +btrfs_del_inode_ref_47181 btrfs_del_inode_ref 0 47181 NULL
107905 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
107906 +options_write_47243 options_write 3 47243 NULL
107907 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
107908 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
107909 +p9pdu_readf_47269 p9pdu_readf 0 47269 NULL
107910 +ablkcipher_next_slow_47274 ablkcipher_next_slow 3-4 47274 NULL
107911 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
107912 +vsnprintf_47291 vsnprintf 0 47291 NULL
107913 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
107914 +iterate_inode_ref_47322 iterate_inode_ref 0 47322 NULL
107915 +SyS_madvise_47354 SyS_madvise 1-2 47354 NULL
107916 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
107917 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
107918 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
107919 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
107920 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
107921 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
107922 +nametbl_list_47391 nametbl_list 2 47391 NULL
107923 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
107924 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
107925 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
107926 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
107927 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
107928 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
107929 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
107930 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
107931 +vzalloc_47421 vzalloc 1 47421 NULL
107932 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
107933 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
107934 +numaq_apicid_to_cpu_present_47449 numaq_apicid_to_cpu_present 1 47449 NULL
107935 +environ_read_47451 environ_read 3 47451 NULL
107936 +__load_mapping_47460 __load_mapping 2 47460 NULL
107937 +try_lock_extent_47465 try_lock_extent 0 47465 NULL
107938 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
107939 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
107940 +newpart_47485 newpart 6-4 47485 &wb_force_mapping_47485
107941 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
107942 +core_sys_select_47494 core_sys_select 1 47494 NULL
107943 +read_block_for_search_47502 read_block_for_search 0 47502 NULL
107944 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL nohasharray
107945 +btrfs_init_inode_security_47505 btrfs_init_inode_security 0 47505 &alloc_arraycache_47505
107946 +unlink_simple_47506 unlink_simple 3 47506 NULL
107947 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
107948 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
107949 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
107950 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
107951 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
107952 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
107953 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
107954 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
107955 +ocfs2_resv_find_window_47557 ocfs2_resv_find_window 3 47557 NULL
107956 +read_ldt_47570 read_ldt 2 47570 NULL
107957 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
107958 +rpipe_get_idx_47579 rpipe_get_idx 2-0 47579 NULL
107959 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
107960 +vendorextnReadSection_47583 vendorextnReadSection 0 47583 NULL
107961 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
107962 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
107963 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
107964 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
107965 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
107966 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
107967 +get_size_47644 get_size 1-2 47644 NULL
107968 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
107969 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
107970 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
107971 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
107972 +save_microcode_47717 save_microcode 3 47717 NULL
107973 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
107974 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
107975 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
107976 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
107977 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
107978 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
107979 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
107980 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
107981 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
107982 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
107983 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
107984 +lov_packmd_47810 lov_packmd 0 47810 NULL
107985 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
107986 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
107987 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
107988 +vhci_read_47878 vhci_read 3 47878 NULL
107989 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
107990 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
107991 +load_mapping_47904 load_mapping 3 47904 NULL
107992 +btrfs_duplicate_item_47910 btrfs_duplicate_item 0 47910 NULL
107993 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
107994 +comedi_write_47926 comedi_write 3 47926 NULL
107995 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
107996 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
107997 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
107998 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
107999 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
108000 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
108001 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
108002 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
108003 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
108004 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
108005 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
108006 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
108007 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
108008 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
108009 +btrfs_reserve_extent_48044 btrfs_reserve_extent 6 48044 NULL
108010 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
108011 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
108012 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
108013 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
108014 +disc_write_48070 disc_write 3 48070 NULL
108015 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
108016 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5-0 48102 NULL
108017 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
108018 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
108019 +set_discoverable_48141 set_discoverable 4 48141 NULL
108020 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
108021 +get_cur_inode_state_48149 get_cur_inode_state 0 48149 NULL
108022 +_add_to_r4w_48152 _add_to_r4w 4 48152 NULL nohasharray
108023 +bitmap_onto_48152 bitmap_onto 4 48152 &_add_to_r4w_48152
108024 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
108025 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
108026 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
108027 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
108028 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
108029 +init_ipath_48187 init_ipath 1 48187 NULL
108030 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
108031 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
108032 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
108033 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
108034 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
108035 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
108036 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
108037 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
108038 +read_file_recv_48232 read_file_recv 3 48232 NULL
108039 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
108040 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
108041 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
108042 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
108043 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
108044 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
108045 +trace_options_write_48275 trace_options_write 3 48275 NULL
108046 +send_set_info_48288 send_set_info 7 48288 NULL
108047 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
108048 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
108049 +hash_setkey_48310 hash_setkey 3 48310 NULL
108050 +audio_set_intf_req_48319 audio_set_intf_req 0 48319 NULL
108051 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
108052 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
108053 +skb_add_data_48363 skb_add_data 3 48363 NULL
108054 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
108055 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
108056 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
108057 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
108058 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
108059 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
108060 +print_filtered_48442 print_filtered 2-0 48442 NULL
108061 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
108062 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
108063 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
108064 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
108065 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
108066 +send_control_msg_48498 send_control_msg 6 48498 NULL
108067 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
108068 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
108069 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
108070 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
108071 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
108072 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
108073 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
108074 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
108075 +llog_data_len_48607 llog_data_len 1 48607 NULL
108076 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
108077 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
108078 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
108079 +mtd_read_48655 mtd_read 0 48655 NULL
108080 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
108081 +ore_get_rw_state_48667 ore_get_rw_state 5-4 48667 NULL
108082 +sm501_create_subdev_48668 sm501_create_subdev 4-3 48668 NULL
108083 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
108084 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
108085 +altera_drscan_48698 altera_drscan 2 48698 NULL
108086 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
108087 +recv_msg_48709 recv_msg 4 48709 NULL
108088 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
108089 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
108090 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
108091 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
108092 +event_buffer_read_48772 event_buffer_read 3 48772 NULL nohasharray
108093 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 &event_buffer_read_48772
108094 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
108095 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
108096 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
108097 +register_ftrace_profiler_48816 register_ftrace_profiler 0 48816 NULL
108098 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
108099 +azx_get_position_48841 azx_get_position 0 48841 NULL
108100 +vc_do_resize_48842 vc_do_resize 4-3 48842 NULL
108101 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
108102 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
108103 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
108104 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
108105 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
108106 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
108107 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
108108 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL
108109 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
108110 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
108111 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
108112 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
108113 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
108114 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
108115 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
108116 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
108117 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
108118 +btrfs_delete_delayed_insertion_item_48981 btrfs_delete_delayed_insertion_item 0 48981 NULL
108119 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
108120 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
108121 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL
108122 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
108123 +aic_inb_49023 aic_inb 0 49023 NULL
108124 +transient_status_49027 transient_status 4 49027 NULL
108125 +iwl_mvm_power_legacy_dbgfs_read_49038 iwl_mvm_power_legacy_dbgfs_read 4 49038 NULL nohasharray
108126 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 &iwl_mvm_power_legacy_dbgfs_read_49038
108127 +aic7xxx_rem_scb_from_disc_list_49041 aic7xxx_rem_scb_from_disc_list 0 49041 NULL
108128 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
108129 +ubi_read_49061 ubi_read 0 49061 NULL
108130 +scsi_register_49094 scsi_register 2 49094 NULL
108131 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
108132 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
108133 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
108134 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
108135 +qib_user_sdma_pin_pages_49136 qib_user_sdma_pin_pages 4-5-6 49136 NULL nohasharray
108136 +pt_read_49136 pt_read 3 49136 &qib_user_sdma_pin_pages_49136
108137 +read_file_49137 read_file 4 49137 NULL
108138 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
108139 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
108140 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
108141 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
108142 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
108143 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
108144 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
108145 +print_queue_49191 print_queue 0 49191 NULL
108146 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
108147 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
108148 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
108149 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
108150 +resp_write_same_49217 resp_write_same 2 49217 NULL
108151 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
108152 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
108153 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
108154 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
108155 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
108156 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
108157 +__ext4_ext_dirty_49284 __ext4_ext_dirty 0 49284 NULL
108158 +ext4_xattr_ibody_list_49287 ext4_xattr_ibody_list 3-0 49287 NULL
108159 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
108160 +uio_read_49300 uio_read 3 49300 NULL
108161 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
108162 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
108163 +update_ref_for_cow_49313 update_ref_for_cow 0 49313 NULL
108164 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
108165 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
108166 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
108167 +__intel_map_single_49338 __intel_map_single 3-2 49338 NULL
108168 +intel_ring_invalidate_all_caches_49346 intel_ring_invalidate_all_caches 0 49346 NULL
108169 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
108170 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-3-5 49370 NULL
108171 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
108172 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
108173 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
108174 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
108175 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
108176 +ubi_add_to_av_49432 ubi_add_to_av 0 49432 NULL nohasharray
108177 +md_domain_init_49432 md_domain_init 2 49432 &ubi_add_to_av_49432
108178 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
108179 +get_lru_size_49441 get_lru_size 0 49441 NULL
108180 +i915_gem_object_set_to_gtt_domain_49450 i915_gem_object_set_to_gtt_domain 0 49450 NULL
108181 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
108182 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
108183 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
108184 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
108185 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
108186 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
108187 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
108188 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
108189 +btrfs_add_free_space_49524 btrfs_add_free_space 0 49524 NULL
108190 +smk_write_access_49561 smk_write_access 3 49561 NULL
108191 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
108192 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
108193 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
108194 +readfifo_49583 readfifo 1 49583 NULL
108195 +tap_write_49595 tap_write 3 49595 NULL
108196 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
108197 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
108198 +heap_init_49617 heap_init 2 49617 NULL
108199 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
108200 +port_fops_read_49626 port_fops_read 3 49626 NULL
108201 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
108202 +__swab32p_49657 __swab32p 0 49657 NULL
108203 +ubi_wl_flush_49682 ubi_wl_flush 0 49682 NULL
108204 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
108205 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
108206 +__setup_irq_49696 __setup_irq 0 49696 NULL
108207 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
108208 +do_splice_to_49714 do_splice_to 4 49714 NULL
108209 +write_pool_49718 write_pool 3 49718 NULL
108210 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
108211 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
108212 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
108213 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
108214 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
108215 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
108216 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
108217 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
108218 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
108219 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
108220 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
108221 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
108222 +add_uuid_49831 add_uuid 4 49831 NULL
108223 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
108224 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
108225 +twl4030_write_49846 twl4030_write 2 49846 NULL
108226 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
108227 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
108228 +ubifs_destroy_tnc_subtree_49853 ubifs_destroy_tnc_subtree 0 49853 NULL
108229 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
108230 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
108231 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
108232 +snd_mask_eq_49889 snd_mask_eq 0 49889 NULL
108233 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
108234 +osc_brw_49896 osc_brw 4 49896 NULL
108235 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
108236 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
108237 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
108238 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
108239 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
108240 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
108241 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
108242 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
108243 +__module_alloc_50004 __module_alloc 1 50004 NULL
108244 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
108245 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
108246 +isdn_read_50021 isdn_read 3 50021 NULL
108247 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL
108248 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
108249 +ioread8_50049 ioread8 0 50049 NULL
108250 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
108251 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
108252 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
108253 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
108254 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
108255 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
108256 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
108257 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
108258 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
108259 +process_recorded_refs_50110 process_recorded_refs 0 50110 NULL
108260 +read_file_slot_50111 read_file_slot 3 50111 NULL
108261 +xfs_dir3_sf_entsize_50112 xfs_dir3_sf_entsize 0-3 50112 NULL
108262 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
108263 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 NULL nohasharray
108264 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 &ocfs2_search_one_group_50125
108265 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
108266 +copy_items_50140 copy_items 6 50140 NULL
108267 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
108268 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
108269 +kmalloc_node_50163 kmalloc_node 1 50163 NULL
108270 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
108271 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
108272 +odev_update_50169 odev_update 2 50169 NULL
108273 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
108274 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 nohasharray
108275 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &xfs_get_blocks_direct_50172
108276 +ext3_do_update_inode_50178 ext3_do_update_inode 0 50178 NULL
108277 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 6-4 50198 NULL
108278 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
108279 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
108280 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 NULL nohasharray
108281 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 &compat_SyS_sendfile_50206
108282 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
108283 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
108284 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
108285 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
108286 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
108287 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
108288 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
108289 +iterate_irefs_50313 iterate_irefs 0 50313 NULL
108290 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
108291 +do_launder_page_50329 do_launder_page 0 50329 NULL
108292 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
108293 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
108294 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
108295 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
108296 +tpm_read_50344 tpm_read 3 50344 NULL
108297 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
108298 +efx_nic_update_stats_50352 efx_nic_update_stats 2 50352 NULL
108299 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
108300 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
108301 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 NULL nohasharray
108302 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 &ocfs2_figure_insert_type_50362
108303 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
108304 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
108305 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
108306 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
108307 +snd_mask_refine_last_50406 snd_mask_refine_last 0 50406 NULL
108308 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
108309 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
108310 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
108311 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
108312 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
108313 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
108314 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
108315 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
108316 +force_mapping_50464 force_mapping 2 50464 NULL
108317 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
108318 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
108319 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
108320 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
108321 +__ctzdi2_50536 __ctzdi2 1 50536 NULL
108322 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
108323 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
108324 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL nohasharray
108325 +ttm_agp_tt_create_50563 ttm_agp_tt_create 3 50563 &self_check_peb_vid_hdr_50563
108326 +fat_readpages_50582 fat_readpages 4 50582 NULL
108327 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
108328 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
108329 +xillybus_write_50605 xillybus_write 3 50605 NULL
108330 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
108331 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
108332 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
108333 +__ffs_50625 __ffs 0-1 50625 NULL
108334 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
108335 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
108336 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
108337 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
108338 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
108339 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2-0 50669 NULL
108340 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
108341 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
108342 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
108343 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
108344 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
108345 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
108346 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
108347 +btrfs_truncate_free_space_cache_50769 btrfs_truncate_free_space_cache 0 50769 NULL
108348 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
108349 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
108350 +bio_alloc_map_data_50782 bio_alloc_map_data 2-1 50782 NULL
108351 +tpm_write_50798 tpm_write 3 50798 NULL
108352 +write_flush_50803 write_flush 3 50803 NULL
108353 +dvb_play_50814 dvb_play 3 50814 NULL
108354 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
108355 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
108356 +SetArea_50835 SetArea 4 50835 NULL nohasharray
108357 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835 nohasharray
108358 +mask_from_50835 mask_from 0-1-2 50835 &create_mem_extents_50835
108359 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3-4 50839 NULL
108360 +btrfs_search_slot_for_read_50843 btrfs_search_slot_for_read 0 50843 NULL
108361 +self_check_write_50856 self_check_write 0-5 50856 NULL
108362 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
108363 +__percpu_counter_init_50878 __percpu_counter_init 0 50878 NULL
108364 +btrfs_insert_inode_ref_50884 btrfs_insert_inode_ref 0 50884 NULL
108365 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
108366 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
108367 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
108368 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
108369 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
108370 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
108371 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
108372 +show_device_status_50947 show_device_status 0 50947 NULL
108373 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
108374 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
108375 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
108376 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
108377 +btrfs_del_csums_50969 btrfs_del_csums 0 50969 NULL
108378 +__btrfs_mod_ref_50973 __btrfs_mod_ref 0 50973 NULL
108379 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
108380 +timeout_write_50991 timeout_write 3 50991 NULL
108381 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
108382 +proc_write_51003 proc_write 3 51003 NULL
108383 +jbd2_journal_extend_51012 jbd2_journal_extend 2-0 51012 NULL
108384 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
108385 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
108386 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
108387 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
108388 +dump_midi_51040 dump_midi 3 51040 NULL
108389 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
108390 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
108391 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
108392 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
108393 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
108394 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
108395 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
108396 +btrfs_del_item_51110 btrfs_del_item 0 51110 NULL nohasharray
108397 +ti_recv_51110 ti_recv 3 51110 &btrfs_del_item_51110
108398 +uasp_prepare_r_request_51124 uasp_prepare_r_request 0 51124 NULL
108399 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
108400 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
108401 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
108402 +set_dirty_51144 set_dirty 3 51144 NULL
108403 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
108404 +walk_page_buffers_51170 walk_page_buffers 0 51170 NULL
108405 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
108406 +uhci_frame_skel_link_51213 uhci_frame_skel_link 2 51213 NULL
108407 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
108408 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
108409 +tipc_send_51238 tipc_send 4 51238 NULL
108410 +drm_property_create_51239 drm_property_create 4 51239 NULL
108411 +__mxt_read_reg_51249 __mxt_read_reg 0 51249 NULL
108412 +st_read_51251 st_read 3 51251 NULL
108413 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
108414 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
108415 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
108416 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
108417 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL nohasharray
108418 +__get_cur_name_and_parent_51283 __get_cur_name_and_parent 0 51283 &zone_reclaimable_pages_51283
108419 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
108420 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
108421 +get_cell_51316 get_cell 2 51316 NULL
108422 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
108423 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
108424 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
108425 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
108426 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
108427 +compat_arch_ptrace_51337 compat_arch_ptrace 3 51337 &alloc_smp_req_51337
108428 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
108429 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
108430 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
108431 +pci_sriov_resource_alignment_51406 pci_sriov_resource_alignment 0 51406 NULL
108432 +ceph_sync_read_51410 ceph_sync_read 3-0 51410 NULL
108433 +get_first_ref_51413 get_first_ref 0 51413 NULL
108434 +__btrfs_end_transaction_51420 __btrfs_end_transaction 0 51420 NULL
108435 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
108436 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
108437 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
108438 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
108439 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
108440 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
108441 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
108442 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 NULL
108443 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
108444 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
108445 +key_search_51533 key_search 0 51533 NULL
108446 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
108447 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
108448 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
108449 +get_cur_path_51589 get_cur_path 0 51589 NULL nohasharray
108450 +snd_interval_refine_first_51589 snd_interval_refine_first 0 51589 &get_cur_path_51589
108451 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
108452 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
108453 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
108454 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
108455 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
108456 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
108457 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
108458 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
108459 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
108460 +sel_write_access_51704 sel_write_access 3 51704 NULL
108461 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
108462 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
108463 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
108464 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
108465 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
108466 +cm4040_read_51732 cm4040_read 3 51732 NULL
108467 +get_user_pages_fast_51751 get_user_pages_fast 1-2-0 51751 NULL
108468 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
108469 +if_write_51756 if_write 3 51756 NULL
108470 +ext4_ext_create_new_leaf_51763 ext4_ext_create_new_leaf 0 51763 NULL
108471 +__fswab32_51781 __fswab32 0 51781 NULL
108472 +to_ratio_51809 to_ratio 1-2 51809 NULL
108473 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
108474 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
108475 +max732x_irq_pending_51840 max732x_irq_pending 0 51840 NULL
108476 +ioread32_51847 ioread32 0 51847 NULL nohasharray
108477 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
108478 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
108479 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
108480 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
108481 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
108482 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
108483 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
108484 +user_read_51881 user_read 3 51881 NULL
108485 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
108486 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 NULL nohasharray
108487 +virt_to_phys_51896 virt_to_phys 0 51896 &SyS_mq_timedsend_51896
108488 +commit_fs_roots_51898 commit_fs_roots 0 51898 NULL
108489 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
108490 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
108491 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
108492 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
108493 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
108494 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
108495 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
108496 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
108497 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
108498 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
108499 +get_zone_51981 get_zone 0-1 51981 NULL
108500 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
108501 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
108502 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
108503 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
108504 +rdmalt_52022 rdmalt 0 52022 NULL
108505 +override_release_52032 override_release 2 52032 NULL
108506 +end_port_52042 end_port 0 52042 NULL
108507 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
108508 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
108509 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
108510 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
108511 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
108512 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
108513 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
108514 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
108515 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
108516 +retry_count_read_52129 retry_count_read 3 52129 NULL
108517 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
108518 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
108519 +sub_alloc_52140 sub_alloc 0 52140 NULL nohasharray
108520 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 &sub_alloc_52140
108521 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
108522 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2-0 52145 &hysdn_conf_write_52145
108523 +htable_size_52148 htable_size 0-1 52148 NULL
108524 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
108525 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
108526 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
108527 +print_prefix_52176 print_prefix 0 52176 NULL
108528 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
108529 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
108530 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
108531 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
108532 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 3 52243 &fuse_request_alloc_52243
108533 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
108534 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
108535 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
108536 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
108537 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
108538 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
108539 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
108540 +atomic64_read_52300 atomic64_read 0 52300 NULL
108541 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
108542 +read_file_reset_52310 read_file_reset 3 52310 NULL
108543 +request_asymmetric_key_52317 request_asymmetric_key 4-2 52317 NULL
108544 +hwflags_read_52318 hwflags_read 3 52318 NULL
108545 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
108546 +ntfs_rl_split_52328 ntfs_rl_split 4-2 52328 NULL
108547 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
108548 +hur_len_52339 hur_len 0 52339 NULL
108549 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
108550 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
108551 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
108552 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
108553 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
108554 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
108555 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
108556 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
108557 +aer_inject_write_52399 aer_inject_write 3 52399 NULL nohasharray
108558 +cl_page_own_52399 cl_page_own 0 52399 &aer_inject_write_52399
108559 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
108560 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
108561 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
108562 +delay_status_52431 delay_status 5 52431 NULL
108563 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
108564 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
108565 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
108566 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
108567 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
108568 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
108569 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
108570 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
108571 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5-4 52498 NULL
108572 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
108573 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
108574 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
108575 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
108576 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
108577 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
108578 +from_oblock_52546 from_oblock 0-1 52546 NULL
108579 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
108580 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
108581 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
108582 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
108583 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
108584 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
108585 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
108586 +affs_set_blocksize_52625 affs_set_blocksize 2 52625 NULL
108587 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
108588 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
108589 +perf_trace_sched_stat_template_52656 perf_trace_sched_stat_template 3 52656 NULL
108590 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
108591 +htb_add_class_to_row_52663 htb_add_class_to_row 3 52663 NULL
108592 +posix_acl_equiv_mode_52666 posix_acl_equiv_mode 0 52666 NULL
108593 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
108594 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
108595 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
108596 +vendorextnWriteSection_52698 vendorextnWriteSection 0 52698 NULL
108597 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
108598 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
108599 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
108600 +blkcipher_next_slow_52733 blkcipher_next_slow 4-3 52733 NULL
108601 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
108602 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
108603 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
108604 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
108605 +radeon_get_ib_value_52757 radeon_get_ib_value 0 52757 NULL
108606 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
108607 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
108608 +map_try_harder_52846 map_try_harder 2-3 52846 NULL
108609 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
108610 +process_deleted_xattr_52861 process_deleted_xattr 0 52861 NULL
108611 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
108612 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
108613 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
108614 +twlreg_write_52880 twlreg_write 3 52880 NULL
108615 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
108616 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
108617 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
108618 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
108619 +create_vtbl_52909 create_vtbl 0 52909 NULL
108620 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
108621 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
108622 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
108623 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
108624 +send_packet_52960 send_packet 4 52960 NULL
108625 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
108626 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
108627 +num_node_state_52989 num_node_state 0 52989 NULL
108628 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
108629 +uasp_alloc_stream_res_53015 uasp_alloc_stream_res 0 53015 NULL
108630 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
108631 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
108632 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
108633 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
108634 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
108635 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
108636 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
108637 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
108638 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
108639 +page_to_nid_53085 page_to_nid 0 53085 NULL
108640 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
108641 +insert_new_root_53097 insert_new_root 0 53097 NULL
108642 +verity_status_53120 verity_status 5 53120 NULL
108643 +__copy_from_user_ll_nocache_nozero_53123 __copy_from_user_ll_nocache_nozero 0-3 53123 NULL
108644 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
108645 +btrfs_search_forward_53137 btrfs_search_forward 0 53137 NULL
108646 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
108647 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
108648 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
108649 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
108650 +SyS_init_module_53202 SyS_init_module 2 53202 NULL
108651 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
108652 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
108653 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
108654 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
108655 +hfsplus_xattr_set_posix_acl_53249 hfsplus_xattr_set_posix_acl 4 53249 NULL
108656 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
108657 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
108658 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
108659 +btrfs_find_highest_objectid_53284 btrfs_find_highest_objectid 0 53284 NULL
108660 +setup_leaf_for_split_53312 setup_leaf_for_split 0 53312 NULL
108661 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
108662 +setup_cluster_no_bitmap_53328 setup_cluster_no_bitmap 0 53328 NULL
108663 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
108664 +vm_mmap_53339 vm_mmap 0 53339 NULL
108665 +vendorextnIoctl_53350 vendorextnIoctl 0 53350 NULL nohasharray
108666 +btrfs_find_all_roots_53350 btrfs_find_all_roots 0 53350 &vendorextnIoctl_53350
108667 +read_6120_creg32_53363 read_6120_creg32 0 53363 NULL
108668 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
108669 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
108670 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
108671 +i915_gem_execbuffer_relocate_object_53435 i915_gem_execbuffer_relocate_object 0 53435 NULL
108672 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
108673 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
108674 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
108675 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
108676 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
108677 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
108678 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
108679 +ext4_ext_grow_indepth_53503 ext4_ext_grow_indepth 0 53503 NULL
108680 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
108681 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
108682 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
108683 +check_acl_53512 check_acl 0 53512 NULL
108684 +send_utimes_53516 send_utimes 0 53516 NULL
108685 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
108686 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
108687 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
108688 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
108689 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
108690 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
108691 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
108692 +stmpe_gpio_request_53634 stmpe_gpio_request 2 53634 NULL nohasharray
108693 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 &stmpe_gpio_request_53634
108694 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
108695 +fuse_fill_write_pages_53682 fuse_fill_write_pages 0-4 53682 NULL
108696 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
108697 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
108698 +igb_alloc_q_vector_53690 igb_alloc_q_vector 6-4 53690 &bdev_logical_block_size_53690
108699 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
108700 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
108701 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
108702 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
108703 +wdm_write_53735 wdm_write 3 53735 NULL
108704 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3-0 53737 NULL
108705 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
108706 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
108707 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
108708 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
108709 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
108710 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
108711 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
108712 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
108713 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
108714 +insert_pfn_53816 insert_pfn 3-0 53816 NULL
108715 +setup_data_read_53822 setup_data_read 3 53822 NULL
108716 +pms_read_53873 pms_read 3 53873 NULL
108717 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
108718 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 4-5-3 53900 NULL nohasharray
108719 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
108720 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
108721 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
108722 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 5-4-0 53938 NULL
108723 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
108724 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
108725 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
108726 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
108727 +send_clone_54011 send_clone 0 54011 NULL
108728 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
108729 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
108730 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
108731 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
108732 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
108733 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
108734 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
108735 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
108736 +_malloc_54077 _malloc 1 54077 NULL
108737 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
108738 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
108739 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
108740 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
108741 +strn_len_54122 strn_len 0 54122 NULL
108742 +isku_receive_54130 isku_receive 4 54130 NULL
108743 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
108744 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
108745 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
108746 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
108747 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
108748 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
108749 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
108750 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
108751 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
108752 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 NULL
108753 +reada_add_block_54247 reada_add_block 2 54247 NULL
108754 +write_file_spec_scan_ctl_54248 write_file_spec_scan_ctl 3 54248 NULL
108755 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
108756 +barrier_all_devices_54254 barrier_all_devices 0 54254 NULL nohasharray
108757 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 &barrier_all_devices_54254
108758 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
108759 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
108760 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
108761 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
108762 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
108763 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
108764 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
108765 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
108766 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
108767 +ttm_mem_global_alloc_54299 ttm_mem_global_alloc 0 54299 NULL
108768 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
108769 +sprintf_54306 sprintf 0 54306 NULL
108770 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
108771 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
108772 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
108773 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
108774 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
108775 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
108776 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
108777 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
108778 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
108779 +ah_alloc_tmp_54378 ah_alloc_tmp 2-3 54378 NULL
108780 +gart_unmap_page_54379 gart_unmap_page 3-2 54379 NULL
108781 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 3-0 54387 NULL
108782 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
108783 +efx_nic_describe_stats_54407 efx_nic_describe_stats 2 54407 NULL
108784 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
108785 +copy_gadget_strings_54417 copy_gadget_strings 3-2 54417 NULL
108786 +btrfs_inc_extent_ref_54442 btrfs_inc_extent_ref 0 54442 NULL
108787 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4 54485 NULL
108788 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
108789 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
108790 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
108791 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
108792 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
108793 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
108794 +viacam_read_54526 viacam_read 3 54526 NULL
108795 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
108796 +setsockopt_54539 setsockopt 5 54539 NULL
108797 +i915_reset_gen7_sol_offsets_54547 i915_reset_gen7_sol_offsets 0 54547 NULL
108798 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
108799 +i915_gem_get_seqno_54555 i915_gem_get_seqno 0 54555 NULL
108800 +btrfs_update_inode_item_54561 btrfs_update_inode_item 0 54561 NULL nohasharray
108801 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 &btrfs_update_inode_item_54561
108802 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
108803 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
108804 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
108805 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
108806 +port_fops_write_54627 port_fops_write 3 54627 NULL
108807 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
108808 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
108809 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
108810 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
108811 +bus_add_device_54665 bus_add_device 0 54665 NULL
108812 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
108813 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
108814 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
108815 +evm_read_key_54674 evm_read_key 3 54674 NULL
108816 +fs_path_add_path_54680 fs_path_add_path 0 54680 NULL
108817 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
108818 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7-0 54706 NULL
108819 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
108820 +clk_divider_set_rate_54726 clk_divider_set_rate 3-2 54726 NULL
108821 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
108822 +kzalloc_54740 kzalloc 1 54740 NULL
108823 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
108824 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
108825 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
108826 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
108827 +ldsem_atomic_update_54774 ldsem_atomic_update 1-0 54774 NULL
108828 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
108829 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
108830 +domain_init_54797 domain_init 2 54797 NULL
108831 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
108832 +get_dev_size_54807 get_dev_size 0 54807 NULL
108833 +nfsd_write_54809 nfsd_write 6 54809 NULL
108834 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
108835 +kvzalloc_54815 kvzalloc 1 54815 &aes_decrypt_fail_read_54815 nohasharray
108836 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &kvzalloc_54815
108837 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
108838 +write_rio_54837 write_rio 3 54837 NULL
108839 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
108840 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
108841 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
108842 +printer_read_54851 printer_read 3 54851 NULL
108843 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
108844 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
108845 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
108846 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
108847 +iscsi_pool_init_54913 iscsi_pool_init 4-2 54913 NULL nohasharray
108848 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
108849 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
108850 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
108851 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
108852 +add_port_54941 add_port 2 54941 NULL
108853 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
108854 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
108855 +c4_add_card_54968 c4_add_card 3 54968 NULL
108856 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
108857 +ubi_change_vtbl_record_54979 ubi_change_vtbl_record 0 54979 NULL
108858 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
108859 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
108860 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
108861 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
108862 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
108863 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
108864 +dgap_do_bios_load_55025 dgap_do_bios_load 3 55025 NULL
108865 +btrfs_init_acl_55028 btrfs_init_acl 0 55028 NULL
108866 +write_ctree_super_55039 write_ctree_super 0 55039 NULL
108867 +ext4_ext_handle_uninitialized_extents_55059 ext4_ext_handle_uninitialized_extents 0-6 55059 NULL
108868 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
108869 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
108870 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
108871 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
108872 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
108873 +corrupt_data_55120 corrupt_data 0-3 55120 NULL
108874 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
108875 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3-0 55137 NULL nohasharray
108876 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
108877 +validate_vid_hdr_55145 validate_vid_hdr 0 55145 NULL
108878 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
108879 +npages_to_npools_55149 npages_to_npools 0-1 55149 NULL
108880 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
108881 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
108882 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
108883 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
108884 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
108885 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
108886 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
108887 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
108888 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
108889 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
108890 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
108891 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
108892 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
108893 +ptrace_request_55288 ptrace_request 3 55288 NULL
108894 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
108895 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
108896 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
108897 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
108898 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 NULL
108899 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
108900 +do_shmat_55336 do_shmat 5 55336 NULL
108901 +vme_user_read_55338 vme_user_read 3 55338 NULL
108902 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
108903 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
108904 +iterate_inode_extrefs_55362 iterate_inode_extrefs 0 55362 NULL nohasharray
108905 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 &iterate_inode_extrefs_55362
108906 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
108907 +__domain_mapping_55393 __domain_mapping 5 55393 NULL
108908 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
108909 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
108910 +SyS_read_55449 SyS_read 3 55449 NULL
108911 +add_relation_rb_55451 add_relation_rb 0 55451 NULL
108912 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
108913 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
108914 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
108915 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
108916 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL nohasharray
108917 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 &ocfs2_rec_clusters_55501
108918 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
108919 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
108920 +ea_get_55522 ea_get 3-0 55522 NULL
108921 +buffer_size_55534 buffer_size 0 55534 NULL
108922 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
108923 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
108924 +dgap_do_config_load_55548 dgap_do_config_load 2 55548 NULL
108925 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
108926 +gfs2_bitfit_55566 gfs2_bitfit 2-3-0 55566 NULL
108927 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
108928 +add_partition_55588 add_partition 2 55588 NULL
108929 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
108930 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
108931 +allocate_without_wrapping_disk_55607 allocate_without_wrapping_disk 4 55607 NULL
108932 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
108933 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
108934 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
108935 +snd_pcm_hw_param_last_55624 snd_pcm_hw_param_last 0 55624 NULL
108936 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
108937 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
108938 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
108939 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
108940 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
108941 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
108942 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
108943 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
108944 +btrfs_reloc_cow_block_55672 btrfs_reloc_cow_block 0 55672 NULL
108945 +get_info_55681 get_info 3 55681 NULL
108946 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
108947 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
108948 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL nohasharray
108949 +mtdswap_init_55719 mtdswap_init 2 55719 &ocfs2_lock_refcount_tree_55719
108950 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
108951 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
108952 +set_local_name_55757 set_local_name 4 55757 NULL
108953 +strlen_55778 strlen 0 55778 NULL nohasharray
108954 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
108955 +set_spte_55783 set_spte 4-5 55783 NULL
108956 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
108957 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
108958 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
108959 +sb16_copy_from_user_55836 sb16_copy_from_user 7-6-10 55836 NULL
108960 +ept_gva_to_gpa_55848 ept_gva_to_gpa 2 55848 NULL
108961 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
108962 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
108963 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
108964 +__check_block_validity_55869 __check_block_validity 0 55869 NULL
108965 +hsc_write_55875 hsc_write 3 55875 NULL
108966 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
108967 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
108968 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
108969 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
108970 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
108971 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
108972 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
108973 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
108974 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
108975 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 2-3 55992 NULL
108976 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
108977 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
108978 +__set_discard_56081 __set_discard 2 56081 NULL
108979 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
108980 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
108981 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
108982 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
108983 +add_extent_mapping_56157 add_extent_mapping 0 56157 NULL
108984 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
108985 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
108986 +create_irq_nr_56180 create_irq_nr 1-0 56180 NULL
108987 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
108988 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
108989 +update_space_info_56213 update_space_info 0 56213 NULL
108990 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
108991 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
108992 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
108993 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
108994 +fd_copyin_56247 fd_copyin 3 56247 NULL
108995 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
108996 +p9pdu_vreadf_56271 p9pdu_vreadf 0 56271 NULL
108997 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
108998 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
108999 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
109000 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
109001 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
109002 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
109003 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
109004 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
109005 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
109006 +ipv6_recv_error_56347 ipv6_recv_error 3 56347 NULL
109007 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
109008 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
109009 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 0-4 56368 NULL
109010 +dev_read_56369 dev_read 3 56369 NULL
109011 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
109012 +ata_qc_complete_multiple_56376 ata_qc_complete_multiple 2 56376 NULL
109013 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
109014 +write_gssp_56404 write_gssp 3 56404 NULL
109015 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
109016 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
109017 +i915_gem_object_sync_56417 i915_gem_object_sync 0 56417 NULL nohasharray
109018 +store_msg_56417 store_msg 3 56417 &i915_gem_object_sync_56417
109019 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
109020 +fl_create_56435 fl_create 5 56435 NULL
109021 +gnttab_map_56439 gnttab_map 2 56439 NULL
109022 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
109023 +set_connectable_56458 set_connectable 4 56458 NULL
109024 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
109025 +putused_user_56467 putused_user 3 56467 NULL
109026 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
109027 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
109028 +global_rt_period_56476 global_rt_period 0 56476 NULL
109029 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
109030 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
109031 +cfs_access_process_vm_56503 cfs_access_process_vm 2-4-0 56503 NULL
109032 +init_map_ip_56508 init_map_ip 5 56508 NULL
109033 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
109034 +ext4_zeroout_es_56514 ext4_zeroout_es 0 56514 NULL
109035 +cfg80211_connect_result_56515 cfg80211_connect_result 6-4 56515 NULL
109036 +ip_options_get_56538 ip_options_get 4 56538 NULL
109037 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
109038 +vb2_queue_or_prepare_buf_56547 vb2_queue_or_prepare_buf 0 56547 NULL
109039 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
109040 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
109041 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
109042 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
109043 +event_filter_write_56609 event_filter_write 3 56609 NULL
109044 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
109045 +gather_array_56641 gather_array 3 56641 NULL
109046 +lookup_extent_backref_56644 lookup_extent_backref 9-0 56644 NULL
109047 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
109048 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
109049 +btrfs_cow_block_56678 btrfs_cow_block 0 56678 NULL
109050 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
109051 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
109052 +build_map_info_56696 build_map_info 2 56696 NULL
109053 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
109054 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
109055 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
109056 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
109057 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
109058 +pcpu_populate_chunk_56741 pcpu_populate_chunk 3-2 56741 NULL
109059 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
109060 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
109061 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
109062 +hash_lookup_56792 hash_lookup 2 56792 NULL nohasharray
109063 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 &hash_lookup_56792
109064 +do_syslog_56807 do_syslog 3 56807 NULL
109065 +ext4_ext_rm_idx_56827 ext4_ext_rm_idx 0 56827 NULL
109066 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
109067 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
109068 +sysctl_sync_threshold_56835 sysctl_sync_threshold 0 56835 NULL
109069 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
109070 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
109071 +wb_lookup_56858 wb_lookup 2 56858 NULL
109072 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
109073 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
109074 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
109075 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
109076 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
109077 +hfsplus_setxattr_56902 hfsplus_setxattr 4 56902 NULL
109078 +__bitmap_clear_bits_56912 __bitmap_clear_bits 3 56912 NULL
109079 +strcspn_56913 strcspn 0 56913 NULL
109080 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
109081 +CopyBufferToControlPacket_56933 CopyBufferToControlPacket 0 56933 NULL nohasharray
109082 +journal_init_revoke_56933 journal_init_revoke 2 56933 &CopyBufferToControlPacket_56933
109083 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
109084 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
109085 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
109086 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
109087 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
109088 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
109089 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
109090 +i915_gem_evict_everything_57038 i915_gem_evict_everything 0 57038 NULL
109091 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
109092 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
109093 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
109094 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
109095 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
109096 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
109097 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
109098 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
109099 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
109100 +altera_get_note_57099 altera_get_note 6 57099 NULL
109101 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
109102 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
109103 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
109104 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
109105 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
109106 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
109107 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
109108 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
109109 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
109110 +changed_inode_57156 changed_inode 0 57156 NULL
109111 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
109112 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
109113 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
109114 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
109115 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
109116 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
109117 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
109118 +flush_space_57241 flush_space 3-0 57241 NULL
109119 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
109120 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
109121 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
109122 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
109123 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
109124 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
109125 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
109126 +fw_file_size_57307 fw_file_size 0 57307 NULL
109127 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
109128 +write_file_regval_57313 write_file_regval 3 57313 NULL
109129 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
109130 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
109131 +usblp_read_57342 usblp_read 3 57342 NULL
109132 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
109133 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
109134 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
109135 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
109136 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
109137 +read_file_blob_57406 read_file_blob 3 57406 NULL
109138 +enclosure_register_57412 enclosure_register 3 57412 NULL
109139 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
109140 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
109141 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
109142 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL
109143 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
109144 +blk_flush_cur_seq_57467 blk_flush_cur_seq 0 57467 NULL
109145 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
109146 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
109147 +ocfs2_write_cluster_57483 ocfs2_write_cluster 9-8-2 57483 NULL
109148 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
109149 +skb_headlen_57501 skb_headlen 0 57501 NULL
109150 +copy_in_user_57502 copy_in_user 3 57502 NULL
109151 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL
109152 +init_tag_map_57515 init_tag_map 3 57515 NULL
109153 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
109154 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517 nohasharray
109155 +btrfs_insert_inode_extref_57517 btrfs_insert_inode_extref 0 57517 &il_dbgfs_force_reset_read_57517
109156 +cmm_read_57520 cmm_read 3 57520 NULL
109157 +inode_permission_57531 inode_permission 0 57531 NULL
109158 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
109159 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL
109160 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL nohasharray
109161 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 &ReadHDLCPnP_57559
109162 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
109163 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
109164 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL
109165 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
109166 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
109167 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
109168 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
109169 +vma_kernel_pagesize_57616 vma_kernel_pagesize 0 57616 NULL
109170 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
109171 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
109172 +mem_read_57631 mem_read 3 57631 NULL
109173 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
109174 +r3964_write_57662 r3964_write 4 57662 NULL
109175 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
109176 +__lgwrite_57669 __lgwrite 4 57669 NULL
109177 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
109178 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
109179 +snd_interval_value_57713 snd_interval_value 0 57713 NULL
109180 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
109181 +i915_gem_object_get_pages_57734 i915_gem_object_get_pages 0 57734 NULL
109182 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
109183 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL nohasharray
109184 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 &compat_sys_set_mempolicy_57742
109185 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
109186 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 5-3 57776 NULL
109187 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
109188 +ld2_57794 ld2 0 57794 NULL
109189 +ivtv_read_57796 ivtv_read 3 57796 NULL
109190 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
109191 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
109192 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
109193 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
109194 +flash_read_57843 flash_read 3 57843 NULL
109195 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
109196 +process_all_new_xattrs_57881 process_all_new_xattrs 0 57881 NULL
109197 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
109198 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL nohasharray
109199 +atomic_add_return_unchecked_57910 atomic_add_return_unchecked 0-1 57910 &iio_read_first_n_kfifo_57910
109200 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
109201 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
109202 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
109203 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
109204 +nvc0_vm_create_57942 nvc0_vm_create 2-3 57942 NULL
109205 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
109206 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
109207 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
109208 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
109209 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
109210 +interleave_nodes_57992 interleave_nodes 0 57992 NULL
109211 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
109212 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
109213 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
109214 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
109215 +ext4_block_bitmap_58033 ext4_block_bitmap 0 58033 NULL
109216 +mce_async_out_58056 mce_async_out 3 58056 NULL
109217 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
109218 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
109219 +cm4040_write_58079 cm4040_write 3 58079 NULL
109220 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
109221 +slhc_init_58135 slhc_init 2-1 58135 &ipv6_flowlabel_opt_58135
109222 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
109223 +ext4_bg_num_gdb_58171 ext4_bg_num_gdb 0 58171 NULL
109224 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
109225 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
109226 +sysfs_add_file_mode_58222 sysfs_add_file_mode 0 58222 NULL
109227 +hva_to_pfn_58241 hva_to_pfn 1-0 58241 NULL
109228 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
109229 +read_file_debug_58256 read_file_debug 3 58256 NULL
109230 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
109231 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
109232 +profile_load_58267 profile_load 3 58267 NULL
109233 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
109234 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
109235 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
109236 +intel_alloc_coherent_58302 intel_alloc_coherent 2 58302 NULL
109237 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
109238 +i915_wait_seqno_58309 i915_wait_seqno 0 58309 NULL
109239 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
109240 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3 58331 NULL
109241 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
109242 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
109243 +next_pidmap_58347 next_pidmap 2-0 58347 NULL
109244 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
109245 +save_hint_58359 save_hint 2 58359 NULL
109246 +vmw_ttm_tt_create_58369 vmw_ttm_tt_create 2 58369 NULL nohasharray
109247 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 &vmw_ttm_tt_create_58369
109248 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
109249 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
109250 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
109251 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3-4 58406 NULL nohasharray
109252 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
109253 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
109254 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
109255 +capabilities_read_58457 capabilities_read 3 58457 NULL
109256 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
109257 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
109258 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
109259 +nv_rd08_58472 nv_rd08 0 58472 NULL
109260 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
109261 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
109262 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3 58498 NULL
109263 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
109264 +__clear_discard_58546 __clear_discard 2 58546 NULL
109265 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
109266 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
109267 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
109268 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
109269 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
109270 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
109271 +xip_file_read_58592 xip_file_read 3 58592 NULL
109272 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
109273 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
109274 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
109275 +xfs_iomap_write_delay_58616 xfs_iomap_write_delay 2 58616 NULL
109276 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
109277 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
109278 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL
109279 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
109280 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
109281 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
109282 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
109283 +find_zero_58685 find_zero 0-1 58685 NULL
109284 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
109285 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
109286 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
109287 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
109288 +i915_gem_execbuffer_reserve_58722 i915_gem_execbuffer_reserve 0 58722 NULL
109289 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
109290 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
109291 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
109292 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
109293 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
109294 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
109295 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
109296 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
109297 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
109298 +write_file_58812 write_file 4 58812 NULL
109299 +ep_read_58813 ep_read 3 58813 NULL
109300 +command_write_58841 command_write 3 58841 NULL
109301 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3-0 58850 NULL
109302 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
109303 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
109304 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
109305 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
109306 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
109307 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
109308 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
109309 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
109310 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
109311 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
109312 +__mem_cgroup_try_charge_58976 __mem_cgroup_try_charge 0 58976 NULL
109313 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
109314 +ep_write_59008 ep_write 3 59008 NULL
109315 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
109316 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
109317 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
109318 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
109319 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
109320 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL
109321 +sysfs_link_sibling_59078 sysfs_link_sibling 0 59078 NULL
109322 +do_perf_sw_event_59099 do_perf_sw_event 3 59099 NULL
109323 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
109324 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
109325 +init_status_page_59124 init_status_page 0 59124 NULL
109326 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
109327 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
109328 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
109329 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
109330 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
109331 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
109332 +ksize_59176 ksize 0 59176 NULL
109333 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
109334 +ocfs2_move_extent_59187 ocfs2_move_extent 3-5-2 59187 NULL
109335 +validate_exec_list_59204 validate_exec_list 0 59204 NULL
109336 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
109337 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
109338 +dt3155_read_59226 dt3155_read 3 59226 NULL
109339 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
109340 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
109341 +nla_len_59258 nla_len 0 59258 NULL
109342 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
109343 +__push_leaf_right_59302 __push_leaf_right 0 59302 NULL
109344 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4-0 59304 NULL
109345 +fd_copyout_59323 fd_copyout 3 59323 NULL
109346 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
109347 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
109348 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
109349 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
109350 +__map_request_59350 __map_request 0 59350 NULL
109351 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
109352 +blk_flush_policy_59368 blk_flush_policy 0 59368 NULL
109353 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
109354 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
109355 +ocfs2_replay_truncate_records_59382 ocfs2_replay_truncate_records 0 59382 NULL
109356 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
109357 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
109358 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
109359 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
109360 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
109361 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
109362 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2-0 59445 NULL
109363 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
109364 +block_rsv_use_bytes_59464 block_rsv_use_bytes 0 59464 NULL
109365 +shrink_tnc_trees_59481 shrink_tnc_trees 0 59481 NULL
109366 +btrfs_del_dir_entries_in_log_59490 btrfs_del_dir_entries_in_log 0 59490 NULL
109367 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
109368 +rds_pin_pages_59507 rds_pin_pages 1-2 59507 NULL
109369 +ext4_resize_fs_59543 ext4_resize_fs 2 59543 NULL
109370 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
109371 +tunables_write_59563 tunables_write 3 59563 NULL
109372 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
109373 +write_pbl_59583 write_pbl 4 59583 NULL
109374 +memdup_user_59590 memdup_user 2 59590 NULL
109375 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
109376 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL nohasharray
109377 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 &mem_fwlog_free_mem_blks_read_59616
109378 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
109379 +mtrr_write_59622 mtrr_write 3 59622 NULL
109380 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
109381 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
109382 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
109383 +hidraw_read_59650 hidraw_read 3 59650 NULL
109384 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
109385 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
109386 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
109387 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
109388 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
109389 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
109390 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
109391 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
109392 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
109393 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
109394 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
109395 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
109396 +strnlen_59746 strnlen 0 59746 NULL
109397 +process_all_refs_59754 process_all_refs 0 59754 NULL nohasharray
109398 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 &process_all_refs_59754
109399 +process_new_xattr_59755 process_new_xattr 0 59755 NULL
109400 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
109401 +venus_remove_59781 venus_remove 4 59781 NULL
109402 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
109403 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
109404 +msb_get_zone_from_lba_59800 msb_get_zone_from_lba 0-1 59800 NULL
109405 +ipw_write_59807 ipw_write 3 59807 NULL
109406 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
109407 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
109408 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
109409 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
109410 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
109411 +intel_ring_wait_request_59865 intel_ring_wait_request 0 59865 NULL
109412 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
109413 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
109414 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
109415 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
109416 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
109417 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
109418 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
109419 +aic7xxx_abort_waiting_scb_59932 aic7xxx_abort_waiting_scb 0 59932 NULL
109420 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
109421 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
109422 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
109423 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
109424 +lookup_node_59953 lookup_node 2 59953 NULL
109425 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
109426 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
109427 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
109428 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
109429 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
109430 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
109431 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
109432 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
109433 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
109434 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
109435 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
109436 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
109437 +vcs_size_60050 vcs_size 0 60050 NULL nohasharray
109438 +pin_2_irq_60050 pin_2_irq 0-3 60050 &vcs_size_60050
109439 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
109440 +open_cur_inode_file_60057 open_cur_inode_file 0 60057 NULL
109441 +compat_writev_60063 compat_writev 3 60063 NULL
109442 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
109443 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
109444 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
109445 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
109446 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
109447 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
109448 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
109449 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
109450 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
109451 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
109452 +init_state_60165 init_state 2 60165 NULL
109453 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
109454 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
109455 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
109456 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
109457 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
109458 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
109459 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
109460 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0 60230 &arizona_map_irq_60230
109461 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
109462 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 3-2 60264 NULL
109463 +printer_write_60276 printer_write 3 60276 NULL
109464 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
109465 +getDataLength_60301 getDataLength 0 60301 NULL
109466 +xfs_next_bit_60322 xfs_next_bit 0-3 60322 NULL
109467 +inorder_to_tree_60331 inorder_to_tree 1-0 60331 NULL
109468 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
109469 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
109470 +max_unfragmented_pages_60362 max_unfragmented_pages 0 60362 NULL
109471 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
109472 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0-5 60379 NULL
109473 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
109474 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
109475 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
109476 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
109477 +driver_names_read_60399 driver_names_read 3 60399 NULL
109478 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
109479 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
109480 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
109481 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
109482 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
109483 +scaled_div32_60442 scaled_div32 2-1-0 60442 NULL
109484 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
109485 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
109486 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
109487 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
109488 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
109489 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
109490 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
109491 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
109492 +btrfs_add_delayed_tree_ref_60602 btrfs_add_delayed_tree_ref 0 60602 NULL
109493 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
109494 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
109495 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
109496 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
109497 +free_dind_blocks_60635 free_dind_blocks 0 60635 NULL
109498 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
109499 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
109500 +mv_ffc64_60648 mv_ffc64 1 60648 NULL
109501 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
109502 +run_clustered_refs_60668 run_clustered_refs 0 60668 NULL
109503 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
109504 +btrfs_reserve_extent_60674 btrfs_reserve_extent 5-0 60674 NULL
109505 +init_data_container_60709 init_data_container 1 60709 NULL
109506 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
109507 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
109508 +raid_status_60755 raid_status 5 60755 NULL
109509 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
109510 +opticon_write_60775 opticon_write 4 60775 NULL
109511 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
109512 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
109513 +block_rsv_migrate_bytes_60843 block_rsv_migrate_bytes 0 60843 NULL
109514 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
109515 +alloc_buf_60864 alloc_buf 2-3 60864 NULL
109516 +generic_writepages_60871 generic_writepages 0 60871 NULL
109517 +tipc_createport_60875 tipc_createport 4 60875 NULL
109518 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
109519 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
109520 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
109521 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
109522 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
109523 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
109524 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
109525 +pti_char_write_60960 pti_char_write 3 60960 NULL
109526 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 3-2 60961 NULL
109527 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
109528 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
109529 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
109530 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
109531 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
109532 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
109533 +symtab_init_61050 symtab_init 2 61050 NULL
109534 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
109535 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
109536 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
109537 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
109538 +journal_stop_61080 journal_stop 0 61080 NULL
109539 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
109540 +get_derived_key_61100 get_derived_key 4 61100 NULL
109541 +mem_cgroup_cache_charge_61101 mem_cgroup_cache_charge 0 61101 NULL
109542 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
109543 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
109544 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
109545 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
109546 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
109547 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
109548 +__vmalloc_61168 __vmalloc 1 61168 NULL
109549 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
109550 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
109551 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
109552 +btrfs_reloc_post_snapshot_61189 btrfs_reloc_post_snapshot 0 61189 NULL
109553 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
109554 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
109555 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
109556 +__verify_planes_array_61249 __verify_planes_array 0 61249 NULL
109557 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 NULL nohasharray
109558 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270 nohasharray
109559 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 &ifalias_store_61270
109560 +kick_a_thread_61273 kick_a_thread 0 61273 NULL
109561 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 NULL nohasharray
109562 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 &hfsplus_getxattr_finder_info_61283
109563 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
109564 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
109565 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
109566 +ocfs2_get_sector_61309 ocfs2_get_sector 4 61309 NULL
109567 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
109568 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
109569 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
109570 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
109571 +__fls_61340 __fls 0 61340 NULL nohasharray
109572 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 &__fls_61340
109573 +do_splice_direct_61341 do_splice_direct 5 61341 NULL nohasharray
109574 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 &do_splice_direct_61341
109575 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-2-3 61342 NULL
109576 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
109577 +kvm_apic_id_61363 kvm_apic_id 0 61363 NULL
109578 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
109579 +get_inode_info_61387 get_inode_info 0 61387 NULL
109580 +system_enable_write_61396 system_enable_write 3 61396 NULL
109581 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
109582 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
109583 +i915_emit_box_61436 i915_emit_box 0 61436 NULL
109584 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5-0 61440 NULL
109585 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
109586 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
109587 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
109588 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
109589 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
109590 +erst_errno_61526 erst_errno 0 61526 NULL
109591 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
109592 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
109593 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
109594 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
109595 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
109596 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
109597 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
109598 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
109599 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
109600 +seq_open_private_61589 seq_open_private 3 61589 NULL
109601 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
109602 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
109603 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
109604 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
109605 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
109606 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
109607 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
109608 +resize_stripes_61650 resize_stripes 2 61650 NULL
109609 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
109610 +insert_one_name_61668 insert_one_name 7 61668 NULL
109611 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
109612 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
109613 +lock_loop_61681 lock_loop 1 61681 NULL
109614 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
109615 +filter_read_61692 filter_read 3 61692 NULL
109616 +prog_page_61711 prog_page 2 61711 NULL
109617 +iov_length_61716 iov_length 0 61716 NULL
109618 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
109619 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
109620 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
109621 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
109622 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
109623 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
109624 +num_counter_active_61789 num_counter_active 0 61789 NULL
109625 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
109626 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
109627 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
109628 +regcache_sync_block_61846 regcache_sync_block 4-5 61846 NULL
109629 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2-0 61854 NULL
109630 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
109631 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
109632 +get_fw_name_61874 get_fw_name 3 61874 NULL
109633 +twl4030_sih_setup_61878 twl4030_sih_setup 3-0 61878 NULL
109634 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 4-3-5 61886 NULL
109635 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
109636 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
109637 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
109638 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
109639 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
109640 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
109641 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
109642 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
109643 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
109644 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
109645 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
109646 +fix_read_error_61965 fix_read_error 4 61965 NULL
109647 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
109648 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
109649 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
109650 +cow_file_range_61979 cow_file_range 3 61979 NULL
109651 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
109652 +dequeue_event_62000 dequeue_event 3 62000 NULL
109653 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
109654 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
109655 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
109656 +SYSC_select_62024 SYSC_select 1 62024 NULL
109657 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
109658 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
109659 +do_pselect_62061 do_pselect 1 62061 NULL
109660 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
109661 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
109662 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5-4 62100 NULL
109663 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
109664 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
109665 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
109666 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
109667 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
109668 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
109669 +ql_status_62135 ql_status 5 62135 NULL nohasharray
109670 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
109671 +video_usercopy_62151 video_usercopy 2 62151 NULL
109672 +wrmWithLock_62164 wrmWithLock 0 62164 NULL
109673 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
109674 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
109675 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
109676 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
109677 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
109678 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
109679 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
109680 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
109681 +allocate_partition_62245 allocate_partition 4 62245 NULL
109682 +security_file_permission_62278 security_file_permission 0 62278 NULL
109683 +get_random_int_62279 get_random_int 0 62279 NULL
109684 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
109685 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
109686 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
109687 +ocfs2_find_victim_alloc_group_62306 ocfs2_find_victim_alloc_group 0 62306 NULL
109688 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
109689 +timespec_to_jiffies_62321 timespec_to_jiffies 0 62321 NULL
109690 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
109691 +subseq_list_62332 subseq_list 3-0 62332 NULL
109692 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
109693 +flash_write_62354 flash_write 3 62354 NULL
109694 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
109695 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
109696 +altera_irscan_62396 altera_irscan 2 62396 NULL
109697 +set_ssp_62411 set_ssp 4 62411 NULL
109698 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
109699 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
109700 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
109701 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
109702 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
109703 +debugfs_read_62535 debugfs_read 3 62535 NULL
109704 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
109705 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
109706 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
109707 +get_subdir_62581 get_subdir 3 62581 NULL
109708 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
109709 +get_desc_base_62617 get_desc_base 0 62617 NULL
109710 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7-0 62619 NULL
109711 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
109712 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
109713 +write_62671 write 3 62671 NULL
109714 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
109715 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
109716 +ext4_ind_map_blocks_62690 ext4_ind_map_blocks 0 62690 NULL
109717 +htb_remove_class_from_row_62692 htb_remove_class_from_row 3 62692 NULL
109718 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
109719 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
109720 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
109721 +rdm_62719 rdm 0 62719 NULL
109722 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
109723 +key_replays_read_62746 key_replays_read 3 62746 NULL
109724 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
109725 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
109726 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
109727 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
109728 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
109729 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
109730 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
109731 +posix_acl_valid_62788 posix_acl_valid 0 62788 NULL
109732 +is_first_ref_62805 is_first_ref 0 62805 NULL
109733 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
109734 +name_cache_insert_62822 name_cache_insert 0 62822 NULL
109735 +BeceemEEPROMBulkRead_62835 BeceemEEPROMBulkRead 0 62835 NULL
109736 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
109737 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
109738 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
109739 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
109740 +set_swbp_62853 set_swbp 3 62853 NULL
109741 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
109742 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
109743 +aoechr_write_62883 aoechr_write 3 62883 NULL
109744 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
109745 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
109746 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
109747 +getdqbuf_62908 getdqbuf 1 62908 NULL
109748 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
109749 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1-2 62914 &try_async_pf_62914
109750 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL
109751 +atomic64_sub_return_62941 atomic64_sub_return 1 62941 NULL
109752 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
109753 +send_write_62969 send_write 0-3 62969 NULL
109754 +__ext3_journal_stop_63017 __ext3_journal_stop 0 63017 NULL
109755 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL
109756 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
109757 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
109758 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
109759 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
109760 +run_delayed_tree_ref_63042 run_delayed_tree_ref 0 63042 NULL
109761 +unlink1_63059 unlink1 3 63059 NULL
109762 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
109763 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
109764 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 4-3-0 63078 NULL
109765 +find_extent_in_eb_63082 find_extent_in_eb 0 63082 NULL
109766 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-3-2 63087 NULL
109767 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
109768 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
109769 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
109770 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
109771 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
109772 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
109773 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
109774 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
109775 +security_policydb_len_63198 security_policydb_len 0 63198 NULL
109776 +vme_master_read_63221 vme_master_read 0 63221 NULL
109777 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
109778 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
109779 +ptp_read_63251 ptp_read 4 63251 NULL
109780 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
109781 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
109782 +raid5_resize_63306 raid5_resize 2 63306 NULL
109783 +proc_info_read_63344 proc_info_read 3 63344 NULL
109784 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
109785 +idmouse_read_63374 idmouse_read 3 63374 NULL
109786 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
109787 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
109788 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
109789 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
109790 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
109791 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 3-4-2 63429 NULL
109792 +gfn_to_hva_many_63437 gfn_to_hva_many 2-0 63437 NULL
109793 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
109794 +lookup_dir_item_inode_63447 lookup_dir_item_inode 0 63447 NULL
109795 +i915_gem_object_get_fence_63455 i915_gem_object_get_fence 0 63455 NULL
109796 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
109797 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
109798 +do_work_63483 do_work 0 63483 NULL
109799 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
109800 +__copy_from_user_ll_nocache_63487 __copy_from_user_ll_nocache 0-3 63487 NULL
109801 +read_kcore_63488 read_kcore 3 63488 NULL nohasharray
109802 +alloc_reserved_tree_block_63488 alloc_reserved_tree_block 0 63488 &read_kcore_63488
109803 +save_hint_63497 save_hint 2 63497 NULL
109804 +wl1271_tx_min_rate_get_63498 wl1271_tx_min_rate_get 2 63498 NULL
109805 +sis_voice_irq_63501 sis_voice_irq 1 63501 NULL
109806 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
109807 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 5-4 63529 NULL
109808 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4-0 63534 NULL
109809 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
109810 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
109811 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
109812 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
109813 +kvm_write_guest_page_63555 kvm_write_guest_page 2-5 63555 &dbg_leb_write_63555
109814 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
109815 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
109816 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
109817 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
109818 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
109819 +write_debug_level_63613 write_debug_level 3 63613 NULL
109820 +module_alloc_63630 module_alloc 1 63630 NULL
109821 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
109822 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
109823 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 3-5-4 63640 NULL
109824 +ext4_ext_get_access_63642 ext4_ext_get_access 0 63642 NULL
109825 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
109826 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
109827 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
109828 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
109829 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
109830 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
109831 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
109832 +bin_search_63697 bin_search 0 63697 NULL
109833 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
109834 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
109835 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
109836 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4-0 63720 NULL
109837 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
109838 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
109839 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
109840 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
109841 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
109842 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
109843 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
109844 +prepare_copy_63826 prepare_copy 2 63826 NULL
109845 +sel_write_load_63830 sel_write_load 3 63830 NULL
109846 +ll_readlink_63836 ll_readlink 3 63836 NULL
109847 +IsSectionWritable_63842 IsSectionWritable 0 63842 NULL
109848 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
109849 +divas_write_63901 divas_write 3 63901 NULL
109850 +IsOffsetWritable_63902 IsOffsetWritable 0 63902 NULL nohasharray
109851 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 &IsOffsetWritable_63902
109852 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
109853 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
109854 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
109855 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
109856 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
109857 +__team_options_register_63941 __team_options_register 3 63941 NULL
109858 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
109859 +generic_acl_init_63955 generic_acl_init 0 63955 NULL
109860 +domain_pfn_mapping_63957 domain_pfn_mapping 4 63957 NULL
109861 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
109862 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
109863 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
109864 +hfsplus_security_setxattr_64009 hfsplus_security_setxattr 4 64009 NULL
109865 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
109866 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
109867 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL
109868 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
109869 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
109870 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
109871 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
109872 +__sock_create_64069 __sock_create 0 64069 NULL
109873 +get_u8_64076 get_u8 0 64076 NULL
109874 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
109875 +btrfs_copy_root_64079 btrfs_copy_root 0 64079 NULL
109876 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
109877 +clear_update_marker_64088 clear_update_marker 0 64088 NULL nohasharray
109878 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 &clear_update_marker_64088
109879 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
109880 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL
109881 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
109882 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
109883 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
109884 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
109885 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
109886 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
109887 +init_bch_64130 init_bch 2-1 64130 NULL
109888 +SYSC_ptrace_64136 SYSC_ptrace 3 64136 NULL
109889 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
109890 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
109891 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
109892 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
109893 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
109894 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
109895 +read_pulse_64227 read_pulse 0-3 64227 NULL
109896 +ea_len_64229 ea_len 0 64229 NULL
109897 +btrfs_make_block_group_64241 btrfs_make_block_group 0 64241 NULL
109898 +__btrfs_update_delayed_inode_64248 __btrfs_update_delayed_inode 0 64248 NULL
109899 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
109900 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
109901 +btrfs_next_item_64285 btrfs_next_item 0 64285 NULL
109902 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
109903 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
109904 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
109905 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
109906 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
109907 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
109908 +ffz_64324 ffz 0-1 64324 NULL
109909 +map_region_64328 map_region 1 64328 NULL
109910 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
109911 +ts_write_64336 ts_write 3 64336 NULL
109912 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
109913 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
109914 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
109915 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
109916 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
109917 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
109918 +reg_create_64372 reg_create 5 64372 NULL
109919 +ilo_write_64378 ilo_write 3 64378 NULL
109920 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
109921 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
109922 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
109923 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
109924 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
109925 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
109926 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
109927 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
109928 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
109929 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
109930 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
109931 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
109932 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
109933 +single_open_size_64483 single_open_size 4 64483 NULL
109934 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
109935 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
109936 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
109937 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
109938 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
109939 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
109940 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
109941 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
109942 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
109943 +SyS_bind_64544 SyS_bind 3 64544 NULL
109944 +rbd_obj_read_sync_64554 rbd_obj_read_sync 4-3 64554 NULL
109945 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3-0 64557 NULL
109946 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
109947 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
109948 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
109949 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
109950 +do_erase_64574 do_erase 4 64574 NULL
109951 +fanotify_write_64623 fanotify_write 3 64623 NULL
109952 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
109953 +to_dblock_64655 to_dblock 0-1 64655 NULL
109954 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
109955 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
109956 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661 nohasharray
109957 +pool_create_64661 pool_create 3 64661 &tlbflush_read_file_64661
109958 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
109959 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
109960 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
109961 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
109962 +pfn_to_hpa_64703 pfn_to_hpa 0-1 64703 NULL
109963 +ip_select_ident_more_64707 ip_select_ident_more 4 64707 NULL
109964 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
109965 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
109966 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
109967 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
109968 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
109969 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
109970 +perf_swevent_event_64745 perf_swevent_event 2 64745 NULL
109971 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
109972 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
109973 +message_for_md_64777 message_for_md 5 64777 NULL
109974 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
109975 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
109976 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
109977 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
109978 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
109979 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
109980 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
109981 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
109982 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
109983 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
109984 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
109985 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
109986 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
109987 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
109988 +mk_pid_64894 mk_pid 0-3 64894 NULL
109989 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
109990 +usb_reset_and_verify_device_64933 usb_reset_and_verify_device 0 64933 NULL
109991 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
109992 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
109993 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
109994 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
109995 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
109996 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
109997 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
109998 +insert_dent_65034 insert_dent 7 65034 NULL
109999 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
110000 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL
110001 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
110002 +make_idx_node_65068 make_idx_node 0 65068 NULL
110003 +count_run_65072 count_run 0-2-4-5 65072 NULL
110004 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
110005 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
110006 +send_create_inode_65090 send_create_inode 0 65090 NULL nohasharray
110007 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 &send_create_inode_65090
110008 +uasp_alloc_cmd_65097 uasp_alloc_cmd 0 65097 NULL
110009 +__ext3_journal_dirty_metadata_65103 __ext3_journal_dirty_metadata 0 65103 NULL
110010 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
110011 +kswapd_shrink_zone_65174 kswapd_shrink_zone 4 65174 NULL
110012 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
110013 +btrfs_run_delayed_items_nr_65204 btrfs_run_delayed_items_nr 0 65204 NULL
110014 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
110015 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
110016 +journal_get_write_access_65243 journal_get_write_access 0 65243 NULL
110017 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
110018 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
110019 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
110020 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
110021 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
110022 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
110023 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
110024 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
110025 +get_var_len_65304 get_var_len 0 65304 NULL
110026 +unpack_array_65318 unpack_array 0 65318 NULL
110027 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
110028 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
110029 +init_list_set_65351 init_list_set 3-2 65351 NULL
110030 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
110031 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
110032 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
110033 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
110034 +SyS_writev_65372 SyS_writev 3 65372 NULL
110035 +mi_set_context_65395 mi_set_context 0 65395 NULL
110036 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
110037 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
110038 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
110039 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
110040 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
110041 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 4-3 65410 NULL
110042 +drm_calloc_large_65421 drm_calloc_large 2-1 65421 NULL
110043 +device_add_groups_65423 device_add_groups 0 65423 NULL
110044 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
110045 +vmalloc_to_pfn_65437 vmalloc_to_pfn 0 65437 NULL
110046 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
110047 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
110048 +ext4_es_zeroout_65465 ext4_es_zeroout 0 65465 NULL
110049 +clear_user_65470 clear_user 2 65470 NULL
110050 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
110051 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9-0 65493 NULL
110052 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
110053 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
110054 new file mode 100644
110055 index 0000000..87dd5e2
110056 --- /dev/null
110057 +++ b/tools/gcc/size_overflow_plugin.c
110058 @@ -0,0 +1,3840 @@
110059 +/*
110060 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
110061 + * Licensed under the GPL v2, or (at your option) v3
110062 + *
110063 + * Homepage:
110064 + * http://www.grsecurity.net/~ephox/overflow_plugin/
110065 + *
110066 + * Documentation:
110067 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
110068 + *
110069 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
110070 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
110071 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
110072 + *
110073 + * Usage:
110074 + * $ 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
110075 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
110076 + */
110077 +
110078 +#include "gcc-plugin.h"
110079 +#include "config.h"
110080 +#include "system.h"
110081 +#include "coretypes.h"
110082 +#include "tree.h"
110083 +#include "tree-pass.h"
110084 +#include "intl.h"
110085 +#include "plugin-version.h"
110086 +#include "tm.h"
110087 +#include "toplev.h"
110088 +#include "function.h"
110089 +#include "tree-flow.h"
110090 +#include "plugin.h"
110091 +#include "gimple.h"
110092 +#include "diagnostic.h"
110093 +#include "cfgloop.h"
110094 +
110095 +#if BUILDING_GCC_VERSION >= 4008
110096 +#define TODO_dump_func 0
110097 +#define TODO_dump_cgraph 0
110098 +#endif
110099 +
110100 +#define __unused __attribute__((__unused__))
110101 +#define ASM_NAME(node) IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node))
110102 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110103 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
110104 +#define BEFORE_STMT true
110105 +#define AFTER_STMT false
110106 +#define CREATE_NEW_VAR NULL_TREE
110107 +#define CODES_LIMIT 32
110108 +#define MAX_PARAM 31
110109 +#define VEC_LEN 128
110110 +#define MY_STMT GF_PLF_1
110111 +#define NO_CAST_CHECK GF_PLF_2
110112 +#define RET_CHECK NULL_TREE
110113 +#define CANNOT_FIND_ARG 32
110114 +#define WRONG_NODE 32
110115 +#define NOT_INTENTIONAL_ASM NULL
110116 +#define MIN_CHECK true
110117 +#define MAX_CHECK false
110118 +
110119 +#if BUILDING_GCC_VERSION == 4005
110120 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
110121 +#endif
110122 +
110123 +struct size_overflow_hash {
110124 + const struct size_overflow_hash * const next;
110125 + const char * const name;
110126 + const unsigned int param;
110127 +};
110128 +
110129 +#include "size_overflow_hash.h"
110130 +
110131 +enum mark {
110132 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
110133 +};
110134 +
110135 +static unsigned int call_count;
110136 +
110137 +struct visited {
110138 + struct visited *next;
110139 + const_tree fndecl;
110140 + unsigned int num;
110141 + const_gimple first_stmt;
110142 +};
110143 +
110144 +struct next_cgraph_node {
110145 + struct next_cgraph_node *next;
110146 + struct cgraph_node *current_function;
110147 + tree callee_fndecl;
110148 + unsigned int num;
110149 +};
110150 +
110151 +struct interesting_node {
110152 + struct interesting_node *next;
110153 + gimple first_stmt;
110154 + const_tree fndecl;
110155 + tree node;
110156 +#if BUILDING_GCC_VERSION <= 4007
110157 + VEC(tree, gc) *last_nodes;
110158 +#else
110159 + vec<tree, va_gc> *last_nodes;
110160 +#endif
110161 + unsigned int num;
110162 + enum mark intentional_attr_decl;
110163 + enum mark intentional_attr_cur_fndecl;
110164 + gimple intentional_mark_from_gimple;
110165 +};
110166 +
110167 +int plugin_is_GPL_compatible;
110168 +void debug_gimple_stmt(gimple gs);
110169 +
110170 +static tree report_size_overflow_decl;
110171 +static const_tree const_char_ptr_type_node;
110172 +
110173 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs);
110174 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
110175 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
110176 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
110177 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
110178 +
110179 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
110180 +static tree get_size_overflow_type(gimple stmt, const_tree node);
110181 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
110182 +
110183 +static struct plugin_info size_overflow_plugin_info = {
110184 + .version = "20131120beta",
110185 + .help = "no-size-overflow\tturn off size overflow checking\n",
110186 +};
110187 +
110188 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110189 +{
110190 + unsigned int arg_count;
110191 + enum tree_code code = TREE_CODE(*node);
110192 +
110193 + switch (code) {
110194 + case FUNCTION_DECL:
110195 + arg_count = type_num_arguments(TREE_TYPE(*node));
110196 + break;
110197 + case FUNCTION_TYPE:
110198 + case METHOD_TYPE:
110199 + arg_count = type_num_arguments(*node);
110200 + break;
110201 + default:
110202 + *no_add_attrs = true;
110203 + error("%s: %qE attribute only applies to functions", __func__, name);
110204 + return NULL_TREE;
110205 + }
110206 +
110207 + for (; args; args = TREE_CHAIN(args)) {
110208 + tree position = TREE_VALUE(args);
110209 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110210 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110211 + *no_add_attrs = true;
110212 + }
110213 + }
110214 + return NULL_TREE;
110215 +}
110216 +
110217 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110218 +{
110219 + unsigned int arg_count;
110220 + enum tree_code code = TREE_CODE(*node);
110221 +
110222 + switch (code) {
110223 + case FUNCTION_DECL:
110224 + arg_count = type_num_arguments(TREE_TYPE(*node));
110225 + break;
110226 + case FUNCTION_TYPE:
110227 + case METHOD_TYPE:
110228 + arg_count = type_num_arguments(*node);
110229 + break;
110230 + case FIELD_DECL:
110231 + return NULL_TREE;
110232 + default:
110233 + *no_add_attrs = true;
110234 + error("%qE attribute only applies to functions", name);
110235 + return NULL_TREE;
110236 + }
110237 +
110238 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
110239 + return NULL_TREE;
110240 +
110241 + for (; args; args = TREE_CHAIN(args)) {
110242 + tree position = TREE_VALUE(args);
110243 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110244 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110245 + *no_add_attrs = true;
110246 + }
110247 + }
110248 + return NULL_TREE;
110249 +}
110250 +
110251 +static struct attribute_spec size_overflow_attr = {
110252 + .name = "size_overflow",
110253 + .min_length = 1,
110254 + .max_length = -1,
110255 + .decl_required = true,
110256 + .type_required = false,
110257 + .function_type_required = false,
110258 + .handler = handle_size_overflow_attribute,
110259 +#if BUILDING_GCC_VERSION >= 4007
110260 + .affects_type_identity = false
110261 +#endif
110262 +};
110263 +
110264 +static struct attribute_spec intentional_overflow_attr = {
110265 + .name = "intentional_overflow",
110266 + .min_length = 1,
110267 + .max_length = -1,
110268 + .decl_required = true,
110269 + .type_required = false,
110270 + .function_type_required = false,
110271 + .handler = handle_intentional_overflow_attribute,
110272 +#if BUILDING_GCC_VERSION >= 4007
110273 + .affects_type_identity = false
110274 +#endif
110275 +};
110276 +
110277 +static void register_attributes(void __unused *event_data, void __unused *data)
110278 +{
110279 + register_attribute(&size_overflow_attr);
110280 + register_attribute(&intentional_overflow_attr);
110281 +}
110282 +
110283 +static bool is_bool(const_tree node)
110284 +{
110285 + const_tree type;
110286 +
110287 + if (node == NULL_TREE)
110288 + return false;
110289 +
110290 + type = TREE_TYPE(node);
110291 + if (!INTEGRAL_TYPE_P(type))
110292 + return false;
110293 + if (TREE_CODE(type) == BOOLEAN_TYPE)
110294 + return true;
110295 + if (TYPE_PRECISION(type) == 1)
110296 + return true;
110297 + return false;
110298 +}
110299 +
110300 +static bool skip_types(const_tree var)
110301 +{
110302 + tree type;
110303 + enum tree_code code;
110304 +
110305 + if (is_gimple_constant(var))
110306 + return true;
110307 +
110308 + switch (TREE_CODE(var)) {
110309 + case ADDR_EXPR:
110310 +#if BUILDING_GCC_VERSION >= 4006
110311 + case MEM_REF:
110312 +#endif
110313 + case ARRAY_REF:
110314 + case BIT_FIELD_REF:
110315 + case INDIRECT_REF:
110316 + case TARGET_MEM_REF:
110317 + case COMPONENT_REF:
110318 + case VAR_DECL:
110319 + case VIEW_CONVERT_EXPR:
110320 + return true;
110321 + default:
110322 + break;
110323 + }
110324 +
110325 + code = TREE_CODE(var);
110326 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
110327 +
110328 + type = TREE_TYPE(var);
110329 + switch (TREE_CODE(type)) {
110330 + case INTEGER_TYPE:
110331 + case ENUMERAL_TYPE:
110332 + return false;
110333 + case BOOLEAN_TYPE:
110334 + return is_bool(var);
110335 + default:
110336 + return true;
110337 + }
110338 +}
110339 +
110340 +static inline gimple get_def_stmt(const_tree node)
110341 +{
110342 + gcc_assert(node != NULL_TREE);
110343 +
110344 + if (skip_types(node))
110345 + return NULL;
110346 +
110347 + if (TREE_CODE(node) != SSA_NAME)
110348 + return NULL;
110349 + return SSA_NAME_DEF_STMT(node);
110350 +}
110351 +
110352 +static unsigned char get_tree_code(const_tree type)
110353 +{
110354 + switch (TREE_CODE(type)) {
110355 + case ARRAY_TYPE:
110356 + return 0;
110357 + case BOOLEAN_TYPE:
110358 + return 1;
110359 + case ENUMERAL_TYPE:
110360 + return 2;
110361 + case FUNCTION_TYPE:
110362 + return 3;
110363 + case INTEGER_TYPE:
110364 + return 4;
110365 + case POINTER_TYPE:
110366 + return 5;
110367 + case RECORD_TYPE:
110368 + return 6;
110369 + case UNION_TYPE:
110370 + return 7;
110371 + case VOID_TYPE:
110372 + return 8;
110373 + case REAL_TYPE:
110374 + return 9;
110375 + case VECTOR_TYPE:
110376 + return 10;
110377 + case REFERENCE_TYPE:
110378 + return 11;
110379 + case OFFSET_TYPE:
110380 + return 12;
110381 + case COMPLEX_TYPE:
110382 + return 13;
110383 + default:
110384 + debug_tree((tree)type);
110385 + gcc_unreachable();
110386 + }
110387 +}
110388 +
110389 +struct function_hash {
110390 + size_t tree_codes_len;
110391 + unsigned char tree_codes[CODES_LIMIT];
110392 + tree fndecl;
110393 + unsigned int hash;
110394 +};
110395 +
110396 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
110397 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
110398 +{
110399 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
110400 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
110401 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
110402 +
110403 + unsigned int m = 0x57559429;
110404 + unsigned int n = 0x5052acdb;
110405 + const unsigned int *key4 = (const unsigned int *)key;
110406 + unsigned int h = len;
110407 + unsigned int k = len + seed + n;
110408 + unsigned long long p;
110409 +
110410 + while (len >= 8) {
110411 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
110412 + len -= 8;
110413 + }
110414 + if (len >= 4) {
110415 + cwmixb(key4[0]) key4 += 1;
110416 + len -= 4;
110417 + }
110418 + if (len)
110419 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
110420 + cwmixb(h ^ (k + n));
110421 + return k ^ h;
110422 +
110423 +#undef cwfold
110424 +#undef cwmixa
110425 +#undef cwmixb
110426 +}
110427 +
110428 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
110429 +{
110430 + unsigned int fn, codes, seed = 0;
110431 +
110432 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
110433 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
110434 +
110435 + fn_hash_data->hash = fn ^ codes;
110436 +}
110437 +
110438 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
110439 +{
110440 + gcc_assert(type != NULL_TREE);
110441 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
110442 +
110443 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
110444 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
110445 + fn_hash_data->tree_codes_len++;
110446 + type = TREE_TYPE(type);
110447 + }
110448 +}
110449 +
110450 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
110451 +{
110452 + const_tree result;
110453 +
110454 + gcc_assert(node != NULL_TREE);
110455 +
110456 + if (DECL_P(node)) {
110457 + result = DECL_RESULT(node);
110458 + if (result != NULL_TREE)
110459 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
110460 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
110461 + }
110462 +
110463 + gcc_assert(TYPE_P(node));
110464 +
110465 + if (TREE_CODE(node) == FUNCTION_TYPE)
110466 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
110467 +
110468 + return set_node_codes(node, fn_hash_data);
110469 +}
110470 +
110471 +static void set_function_codes(struct function_hash *fn_hash_data)
110472 +{
110473 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
110474 + enum tree_code code = TREE_CODE(type);
110475 +
110476 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
110477 +
110478 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
110479 +
110480 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
110481 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
110482 +}
110483 +
110484 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
110485 +{
110486 + const struct size_overflow_hash *entry;
110487 + struct function_hash fn_hash_data;
110488 + const char *func_name;
110489 +
110490 + // skip builtins __builtin_constant_p
110491 + if (DECL_BUILT_IN(fndecl))
110492 + return NULL;
110493 +
110494 + fn_hash_data.fndecl = fndecl;
110495 + fn_hash_data.tree_codes_len = 0;
110496 +
110497 + set_function_codes(&fn_hash_data);
110498 + gcc_assert(fn_hash_data.tree_codes_len != 0);
110499 +
110500 + func_name = ASM_NAME(fn_hash_data.fndecl);
110501 + set_hash(func_name, &fn_hash_data);
110502 +
110503 + entry = size_overflow_hash[fn_hash_data.hash];
110504 +
110505 + while (entry) {
110506 + if (!strcmp(entry->name, func_name))
110507 + return entry;
110508 + entry = entry->next;
110509 + }
110510 + return NULL;
110511 +}
110512 +
110513 +static void print_missing_msg(tree func, unsigned int argnum)
110514 +{
110515 + location_t loc;
110516 + const char *curfunc;
110517 + struct function_hash fn_hash_data;
110518 +
110519 + fn_hash_data.fndecl = DECL_ORIGIN(func);
110520 + fn_hash_data.tree_codes_len = 0;
110521 +
110522 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
110523 + curfunc = ASM_NAME(fn_hash_data.fndecl);
110524 +
110525 + set_function_codes(&fn_hash_data);
110526 + set_hash(curfunc, &fn_hash_data);
110527 +
110528 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
110529 +}
110530 +
110531 +static unsigned int find_arg_number_tree(const_tree arg, const_tree func)
110532 +{
110533 + tree var;
110534 + unsigned int argnum = 1;
110535 +
110536 + if (TREE_CODE(arg) == SSA_NAME)
110537 + arg = SSA_NAME_VAR(arg);
110538 +
110539 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
110540 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
110541 + continue;
110542 + if (!skip_types(var))
110543 + return argnum;
110544 + }
110545 +
110546 + return CANNOT_FIND_ARG;
110547 +}
110548 +
110549 +static tree create_new_var(tree type)
110550 +{
110551 + tree new_var = create_tmp_var(type, "cicus");
110552 +
110553 +#if BUILDING_GCC_VERSION <= 4007
110554 + add_referenced_var(new_var);
110555 +#endif
110556 + return new_var;
110557 +}
110558 +
110559 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
110560 +{
110561 + gimple assign;
110562 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110563 + tree type = TREE_TYPE(rhs1);
110564 + tree lhs = create_new_var(type);
110565 +
110566 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
110567 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
110568 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
110569 +
110570 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
110571 + update_stmt(assign);
110572 + gimple_set_plf(assign, MY_STMT, true);
110573 + return assign;
110574 +}
110575 +
110576 +static tree cast_a_tree(tree type, tree var)
110577 +{
110578 + gcc_assert(type != NULL_TREE);
110579 + gcc_assert(var != NULL_TREE);
110580 + gcc_assert(fold_convertible_p(type, var));
110581 +
110582 + return fold_convert(type, var);
110583 +}
110584 +
110585 +static tree get_lhs(const_gimple stmt)
110586 +{
110587 + switch (gimple_code(stmt)) {
110588 + case GIMPLE_ASSIGN:
110589 + case GIMPLE_CALL:
110590 + return gimple_get_lhs(stmt);
110591 + case GIMPLE_PHI:
110592 + return gimple_phi_result(stmt);
110593 + default:
110594 + return NULL_TREE;
110595 + }
110596 +}
110597 +
110598 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
110599 +{
110600 + const_gimple def_stmt = get_def_stmt(rhs);
110601 +
110602 + if (force)
110603 + return false;
110604 +
110605 + if (is_gimple_constant(rhs))
110606 + return false;
110607 +
110608 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
110609 + return false;
110610 +
110611 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
110612 + return false;
110613 +
110614 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
110615 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110616 + return false;
110617 +
110618 + return true;
110619 +}
110620 +
110621 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
110622 +{
110623 + gimple assign, def_stmt;
110624 +
110625 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
110626 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
110627 + gcc_unreachable();
110628 +
110629 + def_stmt = get_def_stmt(rhs);
110630 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
110631 + return def_stmt;
110632 +
110633 + if (lhs == CREATE_NEW_VAR)
110634 + lhs = create_new_var(dst_type);
110635 +
110636 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
110637 +
110638 + if (!gsi_end_p(*gsi)) {
110639 + location_t loc = gimple_location(gsi_stmt(*gsi));
110640 + gimple_set_location(assign, loc);
110641 + }
110642 +
110643 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
110644 +
110645 + if (before)
110646 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
110647 + else
110648 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
110649 + update_stmt(assign);
110650 + return assign;
110651 +}
110652 +
110653 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
110654 +{
110655 + gimple_stmt_iterator gsi;
110656 + tree lhs;
110657 + gimple new_stmt;
110658 +
110659 + if (rhs == NULL_TREE)
110660 + return NULL_TREE;
110661 +
110662 + gsi = gsi_for_stmt(stmt);
110663 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
110664 + gimple_set_plf(new_stmt, MY_STMT, true);
110665 +
110666 + lhs = get_lhs(new_stmt);
110667 + gcc_assert(lhs != NULL_TREE);
110668 + return lhs;
110669 +}
110670 +
110671 +static tree cast_to_TI_type(gimple stmt, tree node)
110672 +{
110673 + gimple_stmt_iterator gsi;
110674 + gimple cast_stmt;
110675 + tree type = TREE_TYPE(node);
110676 +
110677 + if (types_compatible_p(type, intTI_type_node))
110678 + return node;
110679 +
110680 + gsi = gsi_for_stmt(stmt);
110681 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110682 + gimple_set_plf(cast_stmt, MY_STMT, true);
110683 + return gimple_assign_lhs(cast_stmt);
110684 +}
110685 +
110686 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
110687 +{
110688 + tree lhs, new_lhs;
110689 + gimple_stmt_iterator gsi;
110690 +
110691 + if (rhs1 == NULL_TREE) {
110692 + debug_gimple_stmt(oldstmt);
110693 + error("%s: rhs1 is NULL_TREE", __func__);
110694 + gcc_unreachable();
110695 + }
110696 +
110697 + switch (gimple_code(oldstmt)) {
110698 + case GIMPLE_ASM:
110699 + lhs = rhs1;
110700 + break;
110701 + case GIMPLE_CALL:
110702 + case GIMPLE_ASSIGN:
110703 + lhs = gimple_get_lhs(oldstmt);
110704 + break;
110705 + default:
110706 + debug_gimple_stmt(oldstmt);
110707 + gcc_unreachable();
110708 + }
110709 +
110710 + gsi = gsi_for_stmt(oldstmt);
110711 + pointer_set_insert(visited, oldstmt);
110712 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
110713 + basic_block next_bb, cur_bb;
110714 + const_edge e;
110715 +
110716 + gcc_assert(before == false);
110717 + gcc_assert(stmt_can_throw_internal(oldstmt));
110718 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
110719 + gcc_assert(!gsi_end_p(gsi));
110720 +
110721 + cur_bb = gimple_bb(oldstmt);
110722 + next_bb = cur_bb->next_bb;
110723 + e = find_edge(cur_bb, next_bb);
110724 + gcc_assert(e != NULL);
110725 + gcc_assert(e->flags & EDGE_FALLTHRU);
110726 +
110727 + gsi = gsi_after_labels(next_bb);
110728 + gcc_assert(!gsi_end_p(gsi));
110729 +
110730 + before = true;
110731 + oldstmt = gsi_stmt(gsi);
110732 + }
110733 +
110734 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
110735 + return new_lhs;
110736 +}
110737 +
110738 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
110739 +{
110740 + gimple stmt;
110741 + gimple_stmt_iterator gsi;
110742 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
110743 +
110744 + if (gimple_plf(oldstmt, MY_STMT))
110745 + return lhs;
110746 +
110747 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
110748 + rhs1 = gimple_assign_rhs1(oldstmt);
110749 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
110750 + }
110751 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
110752 + rhs2 = gimple_assign_rhs2(oldstmt);
110753 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
110754 + }
110755 +
110756 + stmt = gimple_copy(oldstmt);
110757 + gimple_set_location(stmt, gimple_location(oldstmt));
110758 + gimple_set_plf(stmt, MY_STMT, true);
110759 +
110760 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
110761 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
110762 +
110763 + size_overflow_type = get_size_overflow_type(oldstmt, node);
110764 +
110765 + new_var = create_new_var(size_overflow_type);
110766 + new_var = make_ssa_name(new_var, stmt);
110767 + gimple_assign_set_lhs(stmt, new_var);
110768 +
110769 + if (rhs1 != NULL_TREE)
110770 + gimple_assign_set_rhs1(stmt, rhs1);
110771 +
110772 + if (rhs2 != NULL_TREE)
110773 + gimple_assign_set_rhs2(stmt, rhs2);
110774 +#if BUILDING_GCC_VERSION >= 4007
110775 + if (rhs3 != NULL_TREE)
110776 + gimple_assign_set_rhs3(stmt, rhs3);
110777 +#endif
110778 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
110779 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
110780 +
110781 + gsi = gsi_for_stmt(oldstmt);
110782 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
110783 + update_stmt(stmt);
110784 + pointer_set_insert(visited, oldstmt);
110785 + return gimple_assign_lhs(stmt);
110786 +}
110787 +
110788 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
110789 +{
110790 + gimple assign;
110791 + gimple_stmt_iterator gsi;
110792 + basic_block first_bb;
110793 +
110794 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
110795 +
110796 + if (bb->index == 0) {
110797 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110798 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
110799 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
110800 + bb = first_bb;
110801 + }
110802 +
110803 + gsi = gsi_after_labels(bb);
110804 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
110805 + gimple_set_plf(assign, MY_STMT, true);
110806 +
110807 + return gimple_assign_lhs(assign);
110808 +}
110809 +
110810 +static tree use_phi_ssa_name(tree ssa_name_var, tree new_arg)
110811 +{
110812 + gimple_stmt_iterator gsi;
110813 + gimple assign, def_stmt = get_def_stmt(new_arg);
110814 +
110815 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
110816 + gsi = gsi_after_labels(gimple_bb(def_stmt));
110817 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
110818 + } else {
110819 + gsi = gsi_for_stmt(def_stmt);
110820 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
110821 + }
110822 +
110823 + gimple_set_plf(assign, MY_STMT, true);
110824 + return gimple_assign_lhs(assign);
110825 +}
110826 +
110827 +static tree cast_visited_phi_arg(tree ssa_name_var, tree arg, tree size_overflow_type)
110828 +{
110829 + basic_block bb;
110830 + gimple_stmt_iterator gsi;
110831 + const_gimple def_stmt;
110832 + gimple assign;
110833 +
110834 + def_stmt = get_def_stmt(arg);
110835 + bb = gimple_bb(def_stmt);
110836 + gcc_assert(bb->index != 0);
110837 + gsi = gsi_after_labels(bb);
110838 +
110839 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
110840 + gimple_set_plf(assign, MY_STMT, true);
110841 + return gimple_assign_lhs(assign);
110842 +}
110843 +
110844 +static tree create_new_phi_arg(tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
110845 +{
110846 + tree size_overflow_type;
110847 + tree arg;
110848 + const_gimple def_stmt;
110849 +
110850 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
110851 + return new_arg;
110852 +
110853 + arg = gimple_phi_arg_def(oldstmt, i);
110854 + def_stmt = get_def_stmt(arg);
110855 + gcc_assert(def_stmt != NULL);
110856 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
110857 +
110858 + switch (gimple_code(def_stmt)) {
110859 + case GIMPLE_PHI:
110860 + return cast_visited_phi_arg(ssa_name_var, arg, size_overflow_type);
110861 + case GIMPLE_NOP: {
110862 + basic_block bb;
110863 +
110864 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
110865 + return cast_parm_decl(ssa_name_var, arg, size_overflow_type, bb);
110866 + }
110867 + case GIMPLE_ASM: {
110868 + gimple_stmt_iterator gsi;
110869 + gimple assign, stmt = get_def_stmt(arg);
110870 +
110871 + gsi = gsi_for_stmt(stmt);
110872 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
110873 + gimple_set_plf(assign, MY_STMT, true);
110874 + return gimple_assign_lhs(assign);
110875 + }
110876 + default:
110877 + gcc_assert(new_arg != NULL_TREE);
110878 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
110879 + return use_phi_ssa_name(ssa_name_var, new_arg);
110880 + }
110881 +}
110882 +
110883 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
110884 +{
110885 + basic_block bb;
110886 + gimple phi;
110887 + gimple_seq seq;
110888 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
110889 +
110890 + bb = gsi_bb(gsi);
110891 +
110892 + if (result == NULL_TREE) {
110893 + tree old_result = gimple_phi_result(oldstmt);
110894 + tree size_overflow_type = get_size_overflow_type(oldstmt, old_result);
110895 +
110896 + result = create_new_var(size_overflow_type);
110897 + }
110898 +
110899 + phi = create_phi_node(result, bb);
110900 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
110901 + seq = phi_nodes(bb);
110902 + gsi = gsi_last(seq);
110903 + gsi_remove(&gsi, false);
110904 +
110905 + gsi = gsi_for_stmt(oldstmt);
110906 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
110907 + gimple_set_bb(phi, bb);
110908 + gimple_set_plf(phi, MY_STMT, true);
110909 + return phi;
110910 +}
110911 +
110912 +#if BUILDING_GCC_VERSION <= 4007
110913 +static tree create_new_phi_node(VEC(tree, gc) *args, tree ssa_name_var, gimple oldstmt)
110914 +#else
110915 +static tree create_new_phi_node(vec<tree, va_gc> *args, tree ssa_name_var, gimple oldstmt)
110916 +#endif
110917 +{
110918 + gimple new_phi;
110919 + unsigned int i;
110920 + tree arg, result;
110921 + location_t loc = gimple_location(oldstmt);
110922 +
110923 +#if BUILDING_GCC_VERSION <= 4007
110924 + gcc_assert(!VEC_empty(tree, args));
110925 +#else
110926 + gcc_assert(!args->is_empty());
110927 +#endif
110928 +
110929 + new_phi = overflow_create_phi_node(oldstmt, ssa_name_var);
110930 + result = gimple_phi_result(new_phi);
110931 + ssa_name_var = SSA_NAME_VAR(result);
110932 +
110933 +
110934 +#if BUILDING_GCC_VERSION == 4005
110935 + for (i = 0; i < VEC_length(tree, args); i++) {
110936 + arg = VEC_index(tree, args, i);
110937 +#elif BUILDING_GCC_VERSION <= 4007
110938 + FOR_EACH_VEC_ELT(tree, args, i, arg) {
110939 +#else
110940 + FOR_EACH_VEC_ELT(*args, i, arg) {
110941 +#endif
110942 + arg = create_new_phi_arg(ssa_name_var, arg, oldstmt, i);
110943 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
110944 + }
110945 +
110946 +#if BUILDING_GCC_VERSION <= 4007
110947 + VEC_free(tree, gc, args);
110948 +#else
110949 + vec_free(args);
110950 +#endif
110951 + update_stmt(new_phi);
110952 + return result;
110953 +}
110954 +
110955 +static tree handle_phi(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree orig_result)
110956 +{
110957 + tree ssa_name_var = NULL_TREE;
110958 +#if BUILDING_GCC_VERSION <= 4007
110959 + VEC(tree, gc) *args;
110960 +#else
110961 + vec<tree, va_gc> *args;
110962 +#endif
110963 + gimple oldstmt = get_def_stmt(orig_result);
110964 + unsigned int i, len = gimple_phi_num_args(oldstmt);
110965 +
110966 + pointer_set_insert(visited, oldstmt);
110967 +#if BUILDING_GCC_VERSION <= 4007
110968 + args = VEC_alloc(tree, gc, len);
110969 +#else
110970 + vec_alloc(args, len);
110971 +#endif
110972 + for (i = 0; i < len; i++) {
110973 + tree arg, new_arg;
110974 +
110975 + arg = gimple_phi_arg_def(oldstmt, i);
110976 + new_arg = expand(visited, caller_node, arg);
110977 +
110978 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
110979 + ssa_name_var = SSA_NAME_VAR(new_arg);
110980 +
110981 + if (is_gimple_constant(arg)) {
110982 + tree size_overflow_type = get_size_overflow_type(oldstmt, arg);
110983 +
110984 + new_arg = cast_a_tree(size_overflow_type, arg);
110985 + }
110986 +
110987 +#if BUILDING_GCC_VERSION <= 4007
110988 + VEC_safe_push(tree, gc, args, new_arg);
110989 +#else
110990 + vec_safe_push(args, new_arg);
110991 +#endif
110992 + }
110993 +
110994 + return create_new_phi_node(args, ssa_name_var, oldstmt);
110995 +}
110996 +
110997 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
110998 +{
110999 + gimple assign;
111000 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111001 + tree origtype = TREE_TYPE(orig_rhs);
111002 +
111003 + gcc_assert(is_gimple_assign(stmt));
111004 +
111005 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111006 + gimple_set_plf(assign, MY_STMT, true);
111007 + return gimple_assign_lhs(assign);
111008 +}
111009 +
111010 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
111011 +{
111012 + const_tree rhs1, lhs, rhs1_type, lhs_type;
111013 + enum machine_mode lhs_mode, rhs_mode;
111014 + gimple def_stmt = get_def_stmt(no_const_rhs);
111015 +
111016 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111017 + return false;
111018 +
111019 + rhs1 = gimple_assign_rhs1(def_stmt);
111020 + lhs = gimple_assign_lhs(def_stmt);
111021 + rhs1_type = TREE_TYPE(rhs1);
111022 + lhs_type = TREE_TYPE(lhs);
111023 + rhs_mode = TYPE_MODE(rhs1_type);
111024 + lhs_mode = TYPE_MODE(lhs_type);
111025 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
111026 + return false;
111027 +
111028 + return true;
111029 +}
111030 +
111031 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
111032 +{
111033 + tree rhs1 = gimple_assign_rhs1(stmt);
111034 + tree lhs = gimple_assign_lhs(stmt);
111035 + const_tree rhs1_type = TREE_TYPE(rhs1);
111036 + const_tree lhs_type = TREE_TYPE(lhs);
111037 +
111038 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
111039 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111040 +
111041 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
111042 +}
111043 +
111044 +static bool no_uses(tree node)
111045 +{
111046 + imm_use_iterator imm_iter;
111047 + use_operand_p use_p;
111048 +
111049 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
111050 + const_gimple use_stmt = USE_STMT(use_p);
111051 +
111052 + if (use_stmt == NULL)
111053 + return true;
111054 + if (is_gimple_debug(use_stmt))
111055 + continue;
111056 + return false;
111057 + }
111058 + return true;
111059 +}
111060 +
111061 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
111062 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
111063 +{
111064 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
111065 + gimple def_stmt = get_def_stmt(lhs);
111066 +
111067 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111068 + return false;
111069 +
111070 + rhs1 = gimple_assign_rhs1(def_stmt);
111071 + rhs_type = TREE_TYPE(rhs1);
111072 + lhs_type = TREE_TYPE(lhs);
111073 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
111074 + return false;
111075 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
111076 + return false;
111077 +
111078 + def_stmt = get_def_stmt(rhs1);
111079 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
111080 + return false;
111081 +
111082 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
111083 + return false;
111084 +
111085 + rhs1 = gimple_assign_rhs1(def_stmt);
111086 + rhs2 = gimple_assign_rhs2(def_stmt);
111087 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
111088 + return false;
111089 +
111090 + if (is_gimple_constant(rhs2))
111091 + not_const_rhs = rhs1;
111092 + else
111093 + not_const_rhs = rhs2;
111094 +
111095 + return no_uses(not_const_rhs);
111096 +}
111097 +
111098 +static bool skip_lhs_cast_check(const_gimple stmt)
111099 +{
111100 + const_tree rhs = gimple_assign_rhs1(stmt);
111101 + const_gimple def_stmt = get_def_stmt(rhs);
111102 +
111103 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
111104 + if (gimple_code(def_stmt) == GIMPLE_ASM)
111105 + return true;
111106 +
111107 + if (is_const_plus_unsigned_signed_truncation(rhs))
111108 + return true;
111109 +
111110 + return false;
111111 +}
111112 +
111113 +static tree create_cast_overflow_check(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
111114 +{
111115 + bool cast_lhs, cast_rhs;
111116 + tree lhs = gimple_assign_lhs(stmt);
111117 + tree rhs = gimple_assign_rhs1(stmt);
111118 + const_tree lhs_type = TREE_TYPE(lhs);
111119 + const_tree rhs_type = TREE_TYPE(rhs);
111120 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
111121 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
111122 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
111123 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
111124 +
111125 + static bool check_lhs[3][4] = {
111126 + // ss su us uu
111127 + { false, true, true, false }, // lhs > rhs
111128 + { false, false, false, false }, // lhs = rhs
111129 + { true, true, true, true }, // lhs < rhs
111130 + };
111131 +
111132 + static bool check_rhs[3][4] = {
111133 + // ss su us uu
111134 + { true, false, true, true }, // lhs > rhs
111135 + { true, false, true, true }, // lhs = rhs
111136 + { true, false, true, true }, // lhs < rhs
111137 + };
111138 +
111139 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
111140 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
111141 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111142 +
111143 + if (lhs_size > rhs_size) {
111144 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111145 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111146 + } else if (lhs_size == rhs_size) {
111147 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111148 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111149 + } else {
111150 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111151 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111152 + }
111153 +
111154 + if (!cast_lhs && !cast_rhs)
111155 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111156 +
111157 + if (cast_lhs && !skip_lhs_cast_check(stmt))
111158 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
111159 +
111160 + if (cast_rhs)
111161 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
111162 +
111163 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111164 +}
111165 +
111166 +static tree handle_unary_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
111167 +{
111168 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
111169 +
111170 + if (gimple_plf(stmt, MY_STMT))
111171 + return lhs;
111172 +
111173 + rhs1 = gimple_assign_rhs1(stmt);
111174 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
111175 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111176 +
111177 + new_rhs1 = expand(visited, caller_node, rhs1);
111178 +
111179 + if (new_rhs1 == NULL_TREE)
111180 + return create_cast_assign(visited, stmt);
111181 +
111182 + if (gimple_plf(stmt, NO_CAST_CHECK))
111183 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111184 +
111185 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
111186 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
111187 +
111188 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
111189 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
111190 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111191 + }
111192 +
111193 + if (!gimple_assign_cast_p(stmt))
111194 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111195 +
111196 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
111197 +}
111198 +
111199 +static tree handle_unary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
111200 +{
111201 + tree rhs1, lhs = gimple_assign_lhs(stmt);
111202 + gimple def_stmt = get_def_stmt(lhs);
111203 +
111204 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
111205 + rhs1 = gimple_assign_rhs1(def_stmt);
111206 +
111207 + if (is_gimple_constant(rhs1))
111208 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111209 +
111210 + switch (TREE_CODE(rhs1)) {
111211 + case SSA_NAME:
111212 + return handle_unary_rhs(visited, caller_node, def_stmt);
111213 + case ARRAY_REF:
111214 + case BIT_FIELD_REF:
111215 + case ADDR_EXPR:
111216 + case COMPONENT_REF:
111217 + case INDIRECT_REF:
111218 +#if BUILDING_GCC_VERSION >= 4006
111219 + case MEM_REF:
111220 +#endif
111221 + case TARGET_MEM_REF:
111222 + case VIEW_CONVERT_EXPR:
111223 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111224 + case PARM_DECL:
111225 + case VAR_DECL:
111226 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111227 +
111228 + default:
111229 + debug_gimple_stmt(def_stmt);
111230 + debug_tree(rhs1);
111231 + gcc_unreachable();
111232 + }
111233 +}
111234 +
111235 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
111236 +{
111237 + gimple cond_stmt;
111238 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
111239 +
111240 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
111241 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
111242 + update_stmt(cond_stmt);
111243 +}
111244 +
111245 +static tree create_string_param(tree string)
111246 +{
111247 + tree i_type, a_type;
111248 + const int length = TREE_STRING_LENGTH(string);
111249 +
111250 + gcc_assert(length > 0);
111251 +
111252 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
111253 + a_type = build_array_type(char_type_node, i_type);
111254 +
111255 + TREE_TYPE(string) = a_type;
111256 + TREE_CONSTANT(string) = 1;
111257 + TREE_READONLY(string) = 1;
111258 +
111259 + return build1(ADDR_EXPR, ptr_type_node, string);
111260 +}
111261 +
111262 +#if BUILDING_GCC_VERSION <= 4006
111263 +struct cgraph_node *cgraph_get_create_node(tree decl);
111264 +
111265 +struct cgraph_node *cgraph_get_create_node(tree decl)
111266 +{
111267 + struct cgraph_node *node;
111268 +
111269 + node = cgraph_get_node(decl);
111270 + if (node)
111271 + return node;
111272 + return cgraph_node(decl);
111273 +}
111274 +#endif
111275 +
111276 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
111277 +{
111278 + gimple func_stmt;
111279 + const_gimple def_stmt;
111280 + const_tree loc_line;
111281 + tree loc_file, ssa_name, current_func;
111282 + expanded_location xloc;
111283 + char *ssa_name_buf;
111284 + int len;
111285 + struct cgraph_edge *edge;
111286 + struct cgraph_node *callee_node;
111287 + int frequency;
111288 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
111289 +
111290 + def_stmt = get_def_stmt(arg);
111291 + xloc = expand_location(gimple_location(def_stmt));
111292 +
111293 + if (!gimple_has_location(def_stmt)) {
111294 + xloc = expand_location(gimple_location(stmt));
111295 + if (!gimple_has_location(stmt))
111296 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
111297 + }
111298 +
111299 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
111300 +
111301 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
111302 + loc_file = create_string_param(loc_file);
111303 +
111304 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
111305 + current_func = create_string_param(current_func);
111306 +
111307 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
111308 + call_count++;
111309 + 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);
111310 + gcc_assert(len > 0);
111311 + ssa_name = build_string(len + 1, ssa_name_buf);
111312 + free(ssa_name_buf);
111313 + ssa_name = create_string_param(ssa_name);
111314 +
111315 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
111316 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
111317 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
111318 +
111319 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
111320 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
111321 +
111322 +#if BUILDING_GCC_VERSION <= 4006
111323 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
111324 +#else
111325 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency);
111326 +#endif
111327 + gcc_assert(edge != NULL);
111328 +}
111329 +
111330 +static void __unused print_the_code_insertions(const_gimple stmt)
111331 +{
111332 + location_t loc = gimple_location(stmt);
111333 +
111334 + inform(loc, "Integer size_overflow check applied here.");
111335 +}
111336 +
111337 +static void insert_check_size_overflow(struct cgraph_node *caller_node, gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
111338 +{
111339 + basic_block cond_bb, join_bb, bb_true;
111340 + edge e;
111341 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111342 +
111343 + cond_bb = gimple_bb(stmt);
111344 + if (before)
111345 + gsi_prev(&gsi);
111346 + if (gsi_end_p(gsi))
111347 + e = split_block_after_labels(cond_bb);
111348 + else
111349 + e = split_block(cond_bb, gsi_stmt(gsi));
111350 + cond_bb = e->src;
111351 + join_bb = e->dest;
111352 + e->flags = EDGE_FALSE_VALUE;
111353 + e->probability = REG_BR_PROB_BASE;
111354 +
111355 + bb_true = create_empty_bb(cond_bb);
111356 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
111357 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
111358 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
111359 +
111360 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111361 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
111362 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
111363 +
111364 + if (current_loops != NULL) {
111365 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
111366 + add_bb_to_loop(bb_true, cond_bb->loop_father);
111367 + }
111368 +
111369 + insert_cond(cond_bb, arg, cond_code, type_value);
111370 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
111371 +
111372 +// print_the_code_insertions(stmt);
111373 +}
111374 +
111375 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
111376 +{
111377 + const_tree rhs_type = TREE_TYPE(rhs);
111378 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
111379 +
111380 + gcc_assert(rhs_type != NULL_TREE);
111381 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
111382 + return;
111383 +
111384 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
111385 +
111386 + if (is_const_plus_unsigned_signed_truncation(rhs))
111387 + return;
111388 +
111389 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
111390 + // typemax (-1) < typemin (0)
111391 + if (TREE_OVERFLOW(type_max))
111392 + return;
111393 +
111394 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
111395 +
111396 + cast_rhs_type = TREE_TYPE(cast_rhs);
111397 + type_max_type = TREE_TYPE(type_max);
111398 + type_min_type = TREE_TYPE(type_min);
111399 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
111400 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
111401 +
111402 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
111403 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
111404 +}
111405 +
111406 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
111407 +{
111408 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
111409 + return false;
111410 + if (!is_gimple_constant(rhs))
111411 + return false;
111412 + return true;
111413 +}
111414 +
111415 +static tree get_def_stmt_rhs(const_tree var)
111416 +{
111417 + tree rhs1, def_stmt_rhs1;
111418 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
111419 +
111420 + def_stmt = get_def_stmt(var);
111421 + if (!gimple_assign_cast_p(def_stmt))
111422 + return NULL_TREE;
111423 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
111424 +
111425 + rhs1 = gimple_assign_rhs1(def_stmt);
111426 + rhs1_def_stmt = get_def_stmt(rhs1);
111427 + if (!gimple_assign_cast_p(rhs1_def_stmt))
111428 + return rhs1;
111429 +
111430 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
111431 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
111432 +
111433 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
111434 + case GIMPLE_CALL:
111435 + case GIMPLE_NOP:
111436 + case GIMPLE_ASM:
111437 + case GIMPLE_PHI:
111438 + return def_stmt_rhs1;
111439 + case GIMPLE_ASSIGN:
111440 + return rhs1;
111441 + default:
111442 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
111443 + gcc_unreachable();
111444 + }
111445 +}
111446 +
111447 +static tree handle_intentional_overflow(struct pointer_set_t *visited, struct cgraph_node *caller_node, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
111448 +{
111449 + tree new_rhs, orig_rhs;
111450 + void (*gimple_assign_set_rhs)(gimple, tree);
111451 + tree rhs1 = gimple_assign_rhs1(stmt);
111452 + tree rhs2 = gimple_assign_rhs2(stmt);
111453 + tree lhs = gimple_assign_lhs(stmt);
111454 +
111455 + if (!check_overflow)
111456 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111457 +
111458 + if (change_rhs == NULL_TREE)
111459 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111460 +
111461 + if (new_rhs2 == NULL_TREE) {
111462 + orig_rhs = rhs1;
111463 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
111464 + } else {
111465 + orig_rhs = rhs2;
111466 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
111467 + }
111468 +
111469 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
111470 +
111471 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
111472 + gimple_assign_set_rhs(stmt, new_rhs);
111473 + update_stmt(stmt);
111474 +
111475 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111476 +}
111477 +
111478 +static bool is_subtraction_special(const_gimple stmt)
111479 +{
111480 + gimple rhs1_def_stmt, rhs2_def_stmt;
111481 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
111482 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
111483 + const_tree rhs1 = gimple_assign_rhs1(stmt);
111484 + const_tree rhs2 = gimple_assign_rhs2(stmt);
111485 +
111486 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
111487 + return false;
111488 +
111489 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
111490 +
111491 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
111492 + return false;
111493 +
111494 + rhs1_def_stmt = get_def_stmt(rhs1);
111495 + rhs2_def_stmt = get_def_stmt(rhs2);
111496 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
111497 + return false;
111498 +
111499 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
111500 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
111501 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
111502 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
111503 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
111504 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
111505 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
111506 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
111507 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
111508 + return false;
111509 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
111510 + return false;
111511 +
111512 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
111513 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
111514 + return true;
111515 +}
111516 +
111517 +static tree handle_integer_truncation(struct pointer_set_t *visited, struct cgraph_node *caller_node, const_tree lhs)
111518 +{
111519 + tree new_rhs1, new_rhs2;
111520 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
111521 + gimple assign, stmt = get_def_stmt(lhs);
111522 + tree rhs1 = gimple_assign_rhs1(stmt);
111523 + tree rhs2 = gimple_assign_rhs2(stmt);
111524 +
111525 + if (!is_subtraction_special(stmt))
111526 + return NULL_TREE;
111527 +
111528 + new_rhs1 = expand(visited, caller_node, rhs1);
111529 + new_rhs2 = expand(visited, caller_node, rhs2);
111530 +
111531 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
111532 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
111533 +
111534 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
111535 + return NULL_TREE;
111536 +
111537 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
111538 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
111539 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
111540 + }
111541 +
111542 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
111543 + new_lhs = gimple_assign_lhs(assign);
111544 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
111545 +
111546 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111547 +}
111548 +
111549 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
111550 +{
111551 + const_gimple def_stmt;
111552 +
111553 + if (TREE_CODE(rhs) != SSA_NAME)
111554 + return false;
111555 +
111556 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
111557 + return false;
111558 +
111559 + def_stmt = get_def_stmt(rhs);
111560 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
111561 + return false;
111562 +
111563 + return true;
111564 +}
111565 +
111566 +static tree handle_binary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111567 +{
111568 + tree rhs1, rhs2, new_lhs;
111569 + gimple def_stmt = get_def_stmt(lhs);
111570 + tree new_rhs1 = NULL_TREE;
111571 + tree new_rhs2 = NULL_TREE;
111572 +
111573 + rhs1 = gimple_assign_rhs1(def_stmt);
111574 + rhs2 = gimple_assign_rhs2(def_stmt);
111575 +
111576 + /* no DImode/TImode division in the 32/64 bit kernel */
111577 + switch (gimple_assign_rhs_code(def_stmt)) {
111578 + case RDIV_EXPR:
111579 + case TRUNC_DIV_EXPR:
111580 + case CEIL_DIV_EXPR:
111581 + case FLOOR_DIV_EXPR:
111582 + case ROUND_DIV_EXPR:
111583 + case TRUNC_MOD_EXPR:
111584 + case CEIL_MOD_EXPR:
111585 + case FLOOR_MOD_EXPR:
111586 + case ROUND_MOD_EXPR:
111587 + case EXACT_DIV_EXPR:
111588 + case POINTER_PLUS_EXPR:
111589 + case BIT_AND_EXPR:
111590 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111591 + default:
111592 + break;
111593 + }
111594 +
111595 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
111596 + if (new_lhs != NULL_TREE)
111597 + return new_lhs;
111598 +
111599 + if (TREE_CODE(rhs1) == SSA_NAME)
111600 + new_rhs1 = expand(visited, caller_node, rhs1);
111601 + if (TREE_CODE(rhs2) == SSA_NAME)
111602 + new_rhs2 = expand(visited, caller_node, rhs2);
111603 +
111604 + if (is_a_neg_overflow(def_stmt, rhs2))
111605 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
111606 + if (is_a_neg_overflow(def_stmt, rhs1))
111607 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
111608 +
111609 +
111610 + if (is_a_constant_overflow(def_stmt, rhs2))
111611 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
111612 + if (is_a_constant_overflow(def_stmt, rhs1))
111613 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
111614 +
111615 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111616 +}
111617 +
111618 +#if BUILDING_GCC_VERSION >= 4007
111619 +static tree get_new_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
111620 +{
111621 + if (is_gimple_constant(rhs))
111622 + return cast_a_tree(size_overflow_type, rhs);
111623 + if (TREE_CODE(rhs) != SSA_NAME)
111624 + return NULL_TREE;
111625 + return expand(visited, caller_node, rhs);
111626 +}
111627 +
111628 +static tree handle_ternary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111629 +{
111630 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
111631 + gimple def_stmt = get_def_stmt(lhs);
111632 +
111633 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
111634 +
111635 + rhs1 = gimple_assign_rhs1(def_stmt);
111636 + rhs2 = gimple_assign_rhs2(def_stmt);
111637 + rhs3 = gimple_assign_rhs3(def_stmt);
111638 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
111639 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
111640 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
111641 +
111642 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
111643 +}
111644 +#endif
111645 +
111646 +static tree get_size_overflow_type(gimple stmt, const_tree node)
111647 +{
111648 + const_tree type;
111649 + tree new_type;
111650 +
111651 + gcc_assert(node != NULL_TREE);
111652 +
111653 + type = TREE_TYPE(node);
111654 +
111655 + if (gimple_plf(stmt, MY_STMT))
111656 + return TREE_TYPE(node);
111657 +
111658 + switch (TYPE_MODE(type)) {
111659 + case QImode:
111660 + new_type = intHI_type_node;
111661 + break;
111662 + case HImode:
111663 + new_type = intSI_type_node;
111664 + break;
111665 + case SImode:
111666 + new_type = intDI_type_node;
111667 + break;
111668 + case DImode:
111669 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
111670 + new_type = intDI_type_node;
111671 + else
111672 + new_type = intTI_type_node;
111673 + break;
111674 + case TImode:
111675 + gcc_assert(!TYPE_UNSIGNED(type));
111676 + new_type = intTI_type_node;
111677 + break;
111678 + default:
111679 + debug_tree((tree)node);
111680 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
111681 + gcc_unreachable();
111682 + }
111683 +
111684 + if (TYPE_QUALS(type) != 0)
111685 + return build_qualified_type(new_type, TYPE_QUALS(type));
111686 + return new_type;
111687 +}
111688 +
111689 +static tree expand_visited(gimple def_stmt)
111690 +{
111691 + const_gimple next_stmt;
111692 + gimple_stmt_iterator gsi;
111693 + enum gimple_code code = gimple_code(def_stmt);
111694 +
111695 + if (code == GIMPLE_ASM)
111696 + return NULL_TREE;
111697 +
111698 + gsi = gsi_for_stmt(def_stmt);
111699 + gsi_next(&gsi);
111700 +
111701 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
111702 + return NULL_TREE;
111703 + gcc_assert(!gsi_end_p(gsi));
111704 + next_stmt = gsi_stmt(gsi);
111705 +
111706 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
111707 + return NULL_TREE;
111708 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
111709 +
111710 + return get_lhs(next_stmt);
111711 +}
111712 +
111713 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111714 +{
111715 + gimple def_stmt;
111716 +
111717 + def_stmt = get_def_stmt(lhs);
111718 +
111719 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111720 + return NULL_TREE;
111721 +
111722 + if (gimple_plf(def_stmt, MY_STMT))
111723 + return lhs;
111724 +
111725 + if (pointer_set_contains(visited, def_stmt))
111726 + return expand_visited(def_stmt);
111727 +
111728 + switch (gimple_code(def_stmt)) {
111729 + case GIMPLE_PHI:
111730 + return handle_phi(visited, caller_node, lhs);
111731 + case GIMPLE_CALL:
111732 + case GIMPLE_ASM:
111733 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111734 + case GIMPLE_ASSIGN:
111735 + switch (gimple_num_ops(def_stmt)) {
111736 + case 2:
111737 + return handle_unary_ops(visited, caller_node, def_stmt);
111738 + case 3:
111739 + return handle_binary_ops(visited, caller_node, lhs);
111740 +#if BUILDING_GCC_VERSION >= 4007
111741 + case 4:
111742 + return handle_ternary_ops(visited, caller_node, lhs);
111743 +#endif
111744 + }
111745 + default:
111746 + debug_gimple_stmt(def_stmt);
111747 + error("%s: unknown gimple code", __func__);
111748 + gcc_unreachable();
111749 + }
111750 +}
111751 +
111752 +static tree cast_to_orig_type(gimple stmt, const_tree orig_node, tree new_node)
111753 +{
111754 + const_gimple assign;
111755 + tree orig_type = TREE_TYPE(orig_node);
111756 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111757 +
111758 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111759 + return gimple_assign_lhs(assign);
111760 +}
111761 +
111762 +static void change_orig_node(struct interesting_node *cur_node, tree new_node)
111763 +{
111764 + void (*set_rhs)(gimple, tree);
111765 + gimple stmt = cur_node->first_stmt;
111766 + const_tree orig_node = cur_node->node;
111767 +
111768 + switch (gimple_code(stmt)) {
111769 + case GIMPLE_RETURN:
111770 + gimple_return_set_retval(stmt, cast_to_orig_type(stmt, orig_node, new_node));
111771 + break;
111772 + case GIMPLE_CALL:
111773 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(stmt, orig_node, new_node));
111774 + break;
111775 + case GIMPLE_ASSIGN:
111776 + switch (cur_node->num) {
111777 + case 1:
111778 + set_rhs = &gimple_assign_set_rhs1;
111779 + break;
111780 + case 2:
111781 + set_rhs = &gimple_assign_set_rhs2;
111782 + break;
111783 +#if BUILDING_GCC_VERSION > 4005
111784 + case 3:
111785 + set_rhs = &gimple_assign_set_rhs3;
111786 + break;
111787 +#endif
111788 + default:
111789 + gcc_unreachable();
111790 + }
111791 +
111792 + set_rhs(stmt, cast_to_orig_type(stmt, orig_node, new_node));
111793 + break;
111794 + default:
111795 + debug_gimple_stmt(stmt);
111796 + gcc_unreachable();
111797 + }
111798 +
111799 + update_stmt(stmt);
111800 +}
111801 +
111802 +static unsigned int get_correct_arg_count(unsigned int argnum, tree fndecl)
111803 +{
111804 + const struct size_overflow_hash *hash;
111805 + unsigned int new_argnum;
111806 + tree arg;
111807 + const_tree origarg;
111808 +
111809 + if (argnum == 0)
111810 + return argnum;
111811 +
111812 + hash = get_function_hash(fndecl);
111813 + if (hash && hash->param & (1U << argnum))
111814 + return argnum;
111815 +
111816 + if (DECL_EXTERNAL(fndecl))
111817 + return argnum;
111818 +
111819 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
111820 + argnum--;
111821 + while (origarg && argnum) {
111822 + origarg = TREE_CHAIN(origarg);
111823 + argnum--;
111824 + }
111825 + gcc_assert(argnum == 0);
111826 + gcc_assert(origarg != NULL_TREE);
111827 +
111828 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
111829 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
111830 + return new_argnum;
111831 +
111832 + return CANNOT_FIND_ARG;
111833 +}
111834 +
111835 +// Don't want to duplicate entries in next_cgraph_node
111836 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
111837 +{
111838 + const_tree new_callee_fndecl;
111839 + struct next_cgraph_node *cur_node;
111840 +
111841 + if (fndecl == RET_CHECK)
111842 +#if BUILDING_GCC_VERSION <= 4007
111843 + new_callee_fndecl = node->decl;
111844 +#else
111845 + new_callee_fndecl = node->symbol.decl;
111846 +#endif
111847 + else
111848 + new_callee_fndecl = fndecl;
111849 +
111850 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
111851 +#if BUILDING_GCC_VERSION <= 4007
111852 + if (!operand_equal_p(cur_node->current_function->decl, node->decl, 0))
111853 +#else
111854 + if (!operand_equal_p(cur_node->current_function->symbol.decl, node->symbol.decl, 0))
111855 +#endif
111856 + continue;
111857 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
111858 + continue;
111859 + if (num == cur_node->num)
111860 + return true;
111861 + }
111862 + return false;
111863 +}
111864 +
111865 +/* Add a next_cgraph_node into the list for handle_function().
111866 + * handle_function() iterates over all the next cgraph nodes and
111867 + * starts the overflow check insertion process.
111868 + */
111869 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
111870 +{
111871 + struct next_cgraph_node *new_node;
111872 +
111873 + if (is_in_next_cgraph_node(head, node, fndecl, num))
111874 + return head;
111875 +
111876 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
111877 + new_node->current_function = node;
111878 + new_node->next = NULL;
111879 + new_node->num = num;
111880 + if (fndecl == RET_CHECK)
111881 +#if BUILDING_GCC_VERSION <= 4007
111882 + new_node->callee_fndecl = node->decl;
111883 +#else
111884 + new_node->callee_fndecl = node->symbol.decl;
111885 +#endif
111886 + else
111887 + new_node->callee_fndecl = fndecl;
111888 +
111889 + if (!head)
111890 + return new_node;
111891 +
111892 + new_node->next = head;
111893 + return new_node;
111894 +}
111895 +
111896 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
111897 +{
111898 + struct cgraph_edge *e;
111899 +
111900 + if (num == 0)
111901 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
111902 +
111903 + for (e = node->callers; e; e = e->next_caller) {
111904 + tree fndecl = gimple_call_fndecl(e->call_stmt);
111905 +
111906 + gcc_assert(fndecl != NULL_TREE);
111907 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
111908 + }
111909 +
111910 + return head;
111911 +}
111912 +
111913 +static bool is_a_return_check(const_tree node)
111914 +{
111915 + if (TREE_CODE(node) == FUNCTION_DECL)
111916 + return true;
111917 +
111918 + gcc_assert(TREE_CODE(node) == PARM_DECL);
111919 + return false;
111920 +}
111921 +
111922 +static bool is_in_hash_table(tree fndecl, unsigned int num)
111923 +{
111924 + const struct size_overflow_hash *hash;
111925 +
111926 + hash = get_function_hash(fndecl);
111927 + if (hash && (hash->param & (1U << num)))
111928 + return true;
111929 + return false;
111930 +}
111931 +
111932 +struct missing_functions {
111933 + struct missing_functions *next;
111934 + const_tree node;
111935 + tree fndecl;
111936 +};
111937 +
111938 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
111939 +{
111940 + struct missing_functions *new_function;
111941 +
111942 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
111943 + new_function->node = node;
111944 + new_function->next = NULL;
111945 +
111946 + if (TREE_CODE(node) == FUNCTION_DECL)
111947 + new_function->fndecl = node;
111948 + else
111949 + new_function->fndecl = current_function_decl;
111950 + gcc_assert(new_function->fndecl);
111951 +
111952 + if (!missing_fn_head)
111953 + return new_function;
111954 +
111955 + new_function->next = missing_fn_head;
111956 + return new_function;
111957 +}
111958 +
111959 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
111960 + * If the function is missing everywhere then print the missing message into stderr.
111961 + */
111962 +static bool is_missing_function(tree orig_fndecl, unsigned int num)
111963 +{
111964 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
111965 +#if BUILDING_GCC_VERSION >= 4008
111966 + case BUILT_IN_BSWAP16:
111967 +#endif
111968 + case BUILT_IN_BSWAP32:
111969 + case BUILT_IN_BSWAP64:
111970 + case BUILT_IN_EXPECT:
111971 + case BUILT_IN_MEMCMP:
111972 + return false;
111973 + default:
111974 + break;
111975 + }
111976 +
111977 + // skip test.c
111978 + if (strcmp(NAME(current_function_decl), "coolmalloc")) {
111979 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
111980 + warning(0, "unnecessary size_overflow attribute on: %s\n", NAME(orig_fndecl));
111981 + }
111982 +
111983 + if (is_in_hash_table(orig_fndecl, num))
111984 + return false;
111985 +
111986 + print_missing_msg(orig_fndecl, num);
111987 + return true;
111988 +}
111989 +
111990 +// Get the argnum of a function decl, if node is a return then the argnum is 0
111991 +static unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
111992 +{
111993 + if (is_a_return_check(node))
111994 + return 0;
111995 + else
111996 + return find_arg_number_tree(node, orig_fndecl);
111997 +}
111998 +
111999 +/* If the function is missing from the hash table and it is a static function
112000 + * then create a next_cgraph_node from it for handle_function()
112001 + */
112002 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
112003 +{
112004 + unsigned int num;
112005 + tree orig_fndecl;
112006 + struct cgraph_node *next_node = NULL;
112007 +
112008 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
112009 +
112010 + num = get_function_num(missing_fn_head->node, orig_fndecl);
112011 + if (num == CANNOT_FIND_ARG)
112012 + return cnodes;
112013 +
112014 + if (!is_missing_function(orig_fndecl, num))
112015 + return cnodes;
112016 +
112017 + next_node = cgraph_get_node(missing_fn_head->fndecl);
112018 + if (next_node && next_node->local.local)
112019 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
112020 + return cnodes;
112021 +}
112022 +
112023 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
112024 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
112025 + */
112026 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
112027 +{
112028 + unsigned int i;
112029 + tree node;
112030 + struct missing_functions *cur, *missing_fn_head = NULL;
112031 +
112032 +#if BUILDING_GCC_VERSION == 4005
112033 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112034 + node = VEC_index(tree, cur_node->last_nodes, i);
112035 +#elif BUILDING_GCC_VERSION <= 4007
112036 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
112037 +#else
112038 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
112039 +#endif
112040 + switch (TREE_CODE(node)) {
112041 + case PARM_DECL:
112042 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
112043 + break;
112044 + case FUNCTION_DECL:
112045 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
112046 + break;
112047 + default:
112048 + break;
112049 + }
112050 + }
112051 +
112052 + while (missing_fn_head) {
112053 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
112054 +
112055 + cur = missing_fn_head->next;
112056 + free(missing_fn_head);
112057 + missing_fn_head = cur;
112058 + }
112059 +
112060 + return cnodes;
112061 +}
112062 +
112063 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
112064 +{
112065 + gimple phi = get_def_stmt(result);
112066 + unsigned int i, n = gimple_phi_num_args(phi);
112067 +
112068 + pointer_set_insert(visited, phi);
112069 + for (i = 0; i < n; i++) {
112070 + const_tree arg = gimple_phi_arg_def(phi, i);
112071 +
112072 + set_conditions(visited, interesting_conditions, arg);
112073 + }
112074 +}
112075 +
112076 +enum conditions {
112077 + FROM_CONST, NOT_UNARY, CAST
112078 +};
112079 +
112080 +// Search for constants, cast assignments and binary/ternary assignments
112081 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
112082 +{
112083 + gimple def_stmt = get_def_stmt(lhs);
112084 +
112085 + if (is_gimple_constant(lhs)) {
112086 + interesting_conditions[FROM_CONST] = true;
112087 + return;
112088 + }
112089 +
112090 + if (!def_stmt)
112091 + return;
112092 +
112093 + if (pointer_set_contains(visited, def_stmt))
112094 + return;
112095 +
112096 + switch (gimple_code(def_stmt)) {
112097 + case GIMPLE_NOP:
112098 + case GIMPLE_CALL:
112099 + case GIMPLE_ASM:
112100 + return;
112101 + case GIMPLE_PHI:
112102 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
112103 + case GIMPLE_ASSIGN:
112104 + if (gimple_num_ops(def_stmt) == 2) {
112105 + const_tree rhs = gimple_assign_rhs1(def_stmt);
112106 +
112107 + if (gimple_assign_cast_p(def_stmt))
112108 + interesting_conditions[CAST] = true;
112109 +
112110 + return set_conditions(visited, interesting_conditions, rhs);
112111 + } else {
112112 + interesting_conditions[NOT_UNARY] = true;
112113 + return;
112114 + }
112115 + default:
112116 + debug_gimple_stmt(def_stmt);
112117 + gcc_unreachable();
112118 + }
112119 +}
112120 +
112121 +// determine whether duplication will be necessary or not.
112122 +static void search_interesting_conditions(const_tree arg, bool *interesting_conditions)
112123 +{
112124 + struct pointer_set_t *visited;
112125 +
112126 + visited = pointer_set_create();
112127 + set_conditions(visited, interesting_conditions, arg);
112128 + pointer_set_destroy(visited);
112129 +}
112130 +
112131 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
112132 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
112133 +{
112134 + gimple assign;
112135 + gimple_stmt_iterator gsi;
112136 +
112137 + // already removed
112138 + if (gimple_bb(asm_stmt) == NULL)
112139 + return;
112140 + gsi = gsi_for_stmt(asm_stmt);
112141 +
112142 + assign = gimple_build_assign(lhs, rhs);
112143 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
112144 + SSA_NAME_DEF_STMT(lhs) = assign;
112145 +
112146 + gsi_remove(&gsi, true);
112147 +}
112148 +
112149 +// Get the field decl of a component ref for intentional_overflow checking
112150 +static const_tree search_field_decl(const_tree comp_ref)
112151 +{
112152 + const_tree field = NULL_TREE;
112153 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
112154 +
112155 + for (i = 0; i < len; i++) {
112156 + field = TREE_OPERAND(comp_ref, i);
112157 + if (TREE_CODE(field) == FIELD_DECL)
112158 + break;
112159 + }
112160 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
112161 + return field;
112162 +}
112163 +
112164 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
112165 + * stmt is a return otherwise it is the callee function.
112166 + */
112167 +static const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
112168 +{
112169 + const_tree fndecl;
112170 +
112171 + if (argnum == 0)
112172 + fndecl = current_function_decl;
112173 + else
112174 + fndecl = gimple_call_fndecl(stmt);
112175 +
112176 + if (fndecl == NULL_TREE)
112177 + return NULL_TREE;
112178 +
112179 + return DECL_ORIGIN(fndecl);
112180 +}
112181 +
112182 +/* Get the param of the intentional_overflow attribute.
112183 + * * 0: MARK_NOT_INTENTIONAL
112184 + * * 1..MAX_PARAM: MARK_YES
112185 + * * -1: MARK_TURN_OFF
112186 + */
112187 +static tree get_attribute_param(const_tree decl)
112188 +{
112189 + const_tree attr;
112190 +
112191 + if (decl == NULL_TREE)
112192 + return NULL_TREE;
112193 +
112194 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
112195 + if (!attr || !TREE_VALUE(attr))
112196 + return NULL_TREE;
112197 +
112198 + return TREE_VALUE(attr);
112199 +}
112200 +
112201 +// MARK_TURN_OFF
112202 +static bool is_turn_off_intentional_attr(const_tree decl)
112203 +{
112204 + const_tree param_head;
112205 +
112206 + param_head = get_attribute_param(decl);
112207 + if (param_head == NULL_TREE)
112208 + return false;
112209 +
112210 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
112211 + return true;
112212 + return false;
112213 +}
112214 +
112215 +// MARK_NOT_INTENTIONAL
112216 +static bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
112217 +{
112218 + const_tree param_head;
112219 +
112220 + if (argnum == 0)
112221 + return false;
112222 +
112223 + param_head = get_attribute_param(decl);
112224 + if (param_head == NULL_TREE)
112225 + return false;
112226 +
112227 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
112228 + return true;
112229 + return false;
112230 +}
112231 +
112232 +// MARK_YES
112233 +static bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
112234 +{
112235 + tree param, param_head;
112236 +
112237 + if (argnum == 0)
112238 + return false;
112239 +
112240 + param_head = get_attribute_param(decl);
112241 + for (param = param_head; param; param = TREE_CHAIN(param))
112242 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
112243 + return true;
112244 + return false;
112245 +}
112246 +
112247 +static bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
112248 +{
112249 + const char *str;
112250 +
112251 + if (!stmt)
112252 + return false;
112253 +
112254 + str = gimple_asm_string(stmt);
112255 + return !strcmp(str, "# size_overflow MARK_TURN_OFF\n\t");
112256 +}
112257 +
112258 +static bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
112259 +{
112260 + const char *str;
112261 +
112262 + if (!stmt)
112263 + return false;
112264 +
112265 + str = gimple_asm_string(stmt);
112266 + return !strcmp(str, "# size_overflow MARK_YES\n\t");
112267 +}
112268 +
112269 +static bool is_size_overflow_asm(const_gimple stmt)
112270 +{
112271 + const char *str;
112272 +
112273 + if (!stmt)
112274 + return false;
112275 +
112276 + str = gimple_asm_string(stmt);
112277 + return !strncmp(str, "# size_overflow", 15);
112278 +}
112279 +
112280 +static void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
112281 +{
112282 + location_t loc;
112283 +
112284 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
112285 + return;
112286 +
112287 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
112288 + return;
112289 +
112290 + loc = DECL_SOURCE_LOCATION(decl);
112291 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", NAME(decl), argnum);
112292 +}
112293 +
112294 +/* Get the type of the intentional_overflow attribute of a node
112295 + * * MARK_TURN_OFF
112296 + * * MARK_YES
112297 + * * MARK_NO
112298 + * * MARK_NOT_INTENTIONAL
112299 + */
112300 +static enum mark get_intentional_attr_type(const_tree node)
112301 +{
112302 + const_tree cur_decl;
112303 +
112304 + if (node == NULL_TREE)
112305 + return MARK_NO;
112306 +
112307 + switch (TREE_CODE(node)) {
112308 + case COMPONENT_REF:
112309 + cur_decl = search_field_decl(node);
112310 + if (is_turn_off_intentional_attr(cur_decl))
112311 + return MARK_TURN_OFF;
112312 + if (is_end_intentional_intentional_attr(cur_decl, 1))
112313 + return MARK_YES;
112314 + break;
112315 + case PARM_DECL: {
112316 + unsigned int argnum;
112317 +
112318 + cur_decl = DECL_ORIGIN(current_function_decl);
112319 + argnum = find_arg_number_tree(node, cur_decl);
112320 + if (argnum == CANNOT_FIND_ARG)
112321 + return MARK_NO;
112322 + if (is_yes_intentional_attr(cur_decl, argnum))
112323 + return MARK_YES;
112324 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
112325 + return MARK_NOT_INTENTIONAL;
112326 + break;
112327 + }
112328 + case FUNCTION_DECL:
112329 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
112330 + return MARK_TURN_OFF;
112331 + break;
112332 + default:
112333 + break;
112334 + }
112335 + return MARK_NO;
112336 +}
112337 +
112338 +// Search for the intentional_overflow attribute on the last nodes
112339 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
112340 +{
112341 + unsigned int i;
112342 + tree last_node;
112343 + enum mark mark = MARK_NO;
112344 +
112345 +#if BUILDING_GCC_VERSION == 4005
112346 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112347 + last_node = VEC_index(tree, cur_node->last_nodes, i);
112348 +#elif BUILDING_GCC_VERSION <= 4007
112349 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
112350 +#else
112351 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
112352 +#endif
112353 + mark = get_intentional_attr_type(last_node);
112354 + if (mark != MARK_NO)
112355 + break;
112356 + }
112357 + return mark;
112358 +}
112359 +
112360 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
112361 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
112362 + */
112363 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
112364 +{
112365 + const_tree input, output;
112366 +
112367 + if (!cur_node->intentional_mark_from_gimple)
112368 + return false;
112369 +
112370 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
112371 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
112372 + else
112373 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
112374 +
112375 + // skip param decls
112376 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
112377 + return true;
112378 + input = gimple_asm_input_op(cur_node->intentional_mark_from_gimple, 0);
112379 + output = gimple_asm_output_op(cur_node->intentional_mark_from_gimple, 0);
112380 +
112381 + replace_size_overflow_asm_with_assign(cur_node->intentional_mark_from_gimple, TREE_VALUE(output), TREE_VALUE(input));
112382 + return true;
112383 +}
112384 +
112385 +/* Search intentional_overflow attribute on caller and on callee too.
112386 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
112387 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
112388 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
112389 +*/
112390 +static void check_intentional_attribute_ipa(struct interesting_node *cur_node)
112391 +{
112392 + const_tree fndecl;
112393 +
112394 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
112395 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
112396 + return;
112397 + }
112398 +
112399 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
112400 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
112401 + return;
112402 + }
112403 +
112404 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
112405 + return;
112406 +
112407 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
112408 + if (is_turn_off_intentional_attr(fndecl)) {
112409 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
112410 + return;
112411 + }
112412 +
112413 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
112414 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
112415 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
112416 + cur_node->intentional_attr_decl = MARK_YES;
112417 +
112418 + if (is_intentional_attribute_from_gimple(cur_node))
112419 + return;
112420 +
112421 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
112422 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
112423 +}
112424 +
112425 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
112426 +static bool skip_asm(const_tree arg)
112427 +{
112428 + gimple def_stmt = get_def_stmt(arg);
112429 +
112430 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112431 + return false;
112432 +
112433 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
112434 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
112435 +}
112436 +
112437 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
112438 +{
112439 + gimple phi = get_def_stmt(result);
112440 + unsigned int i, n = gimple_phi_num_args(phi);
112441 +
112442 + pointer_set_insert(visited, phi);
112443 + for (i = 0; i < n; i++) {
112444 + tree arg = gimple_phi_arg_def(phi, i);
112445 +
112446 + walk_use_def(visited, cur_node, arg);
112447 + }
112448 +}
112449 +
112450 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112451 +{
112452 + gimple def_stmt = get_def_stmt(lhs);
112453 + tree rhs1, rhs2;
112454 +
112455 + rhs1 = gimple_assign_rhs1(def_stmt);
112456 + rhs2 = gimple_assign_rhs2(def_stmt);
112457 +
112458 + walk_use_def(visited, cur_node, rhs1);
112459 + walk_use_def(visited, cur_node, rhs2);
112460 +}
112461 +
112462 +static void insert_last_node(struct interesting_node *cur_node, tree node)
112463 +{
112464 + unsigned int i;
112465 + tree element;
112466 + enum tree_code code;
112467 +
112468 + gcc_assert(node != NULL_TREE);
112469 +
112470 + if (is_gimple_constant(node))
112471 + return;
112472 +
112473 + code = TREE_CODE(node);
112474 + if (code == VAR_DECL) {
112475 + node = DECL_ORIGIN(node);
112476 + code = TREE_CODE(node);
112477 + }
112478 +
112479 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
112480 + return;
112481 +
112482 +#if BUILDING_GCC_VERSION == 4005
112483 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112484 + element = VEC_index(tree, cur_node->last_nodes, i);
112485 +#elif BUILDING_GCC_VERSION <= 4007
112486 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
112487 +#else
112488 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
112489 +#endif
112490 + if (operand_equal_p(node, element, 0))
112491 + return;
112492 + }
112493 +
112494 +#if BUILDING_GCC_VERSION <= 4007
112495 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
112496 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
112497 +#else
112498 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
112499 + vec_safe_push(cur_node->last_nodes, node);
112500 +#endif
112501 +}
112502 +
112503 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
112504 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
112505 +{
112506 + const_tree asm_lhs;
112507 +
112508 + if (!is_size_overflow_asm(stmt))
112509 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112510 +
112511 + asm_lhs = gimple_asm_input_op(stmt, 0);
112512 + walk_use_def(visited, cur_node, TREE_VALUE(asm_lhs));
112513 +}
112514 +
112515 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
112516 + * and component refs (for checking the intentional_overflow attribute).
112517 + */
112518 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112519 +{
112520 + const_gimple def_stmt;
112521 +
112522 + if (TREE_CODE(lhs) != SSA_NAME) {
112523 + insert_last_node(cur_node, lhs);
112524 + return;
112525 + }
112526 +
112527 + def_stmt = get_def_stmt(lhs);
112528 + if (!def_stmt)
112529 + return;
112530 +
112531 + if (pointer_set_insert(visited, def_stmt))
112532 + return;
112533 +
112534 + switch (gimple_code(def_stmt)) {
112535 + case GIMPLE_NOP:
112536 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112537 + case GIMPLE_ASM:
112538 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
112539 + case GIMPLE_CALL: {
112540 + tree fndecl = gimple_call_fndecl(def_stmt);
112541 +
112542 + if (fndecl == NULL_TREE)
112543 + return;
112544 + insert_last_node(cur_node, fndecl);
112545 + return;
112546 + }
112547 + case GIMPLE_PHI:
112548 + return walk_use_def_phi(visited, cur_node, lhs);
112549 + case GIMPLE_ASSIGN:
112550 + switch (gimple_num_ops(def_stmt)) {
112551 + case 2:
112552 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
112553 + case 3:
112554 + return walk_use_def_binary(visited, cur_node, lhs);
112555 + }
112556 + default:
112557 + debug_gimple_stmt((gimple)def_stmt);
112558 + error("%s: unknown gimple code", __func__);
112559 + gcc_unreachable();
112560 + }
112561 +}
112562 +
112563 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
112564 +static void set_last_nodes(struct interesting_node *cur_node)
112565 +{
112566 + struct pointer_set_t *visited;
112567 +
112568 + visited = pointer_set_create();
112569 + walk_use_def(visited, cur_node, cur_node->node);
112570 + pointer_set_destroy(visited);
112571 +}
112572 +
112573 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
112574 + * it decides whether the duplication is necessary or not and it searches for missing size_overflow attributes. After expand() it changes the orig node to the duplicated node
112575 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
112576 + * If there is a mark_turn_off intentional attribute on the caller or the callee then there is no duplication and missing size_overflow attribute check anywhere.
112577 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
112578 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
112579 + * It skips the possible error codes too. If the def_stmts trace back to a constant and there are no binary/ternary assigments then we assume that it is some kind of error code.
112580 + */
112581 +static struct next_cgraph_node *handle_interesting_stmt(struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
112582 +{
112583 + struct pointer_set_t *visited;
112584 + bool interesting_conditions[3] = {false, false, false};
112585 + tree new_node, orig_node = cur_node->node;
112586 +
112587 + set_last_nodes(cur_node);
112588 +
112589 + check_intentional_attribute_ipa(cur_node);
112590 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
112591 + return cnodes;
112592 +
112593 + search_interesting_conditions(orig_node, interesting_conditions);
112594 +
112595 + // error code
112596 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
112597 + return cnodes;
112598 +
112599 + cnodes = search_overflow_attribute(cnodes, cur_node);
112600 +
112601 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
112602 + return cnodes;
112603 +
112604 + // unnecessary overflow check
112605 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
112606 + return cnodes;
112607 +
112608 + visited = pointer_set_create();
112609 + new_node = expand(visited, caller_node, orig_node);
112610 + pointer_set_destroy(visited);
112611 +
112612 + if (new_node == NULL_TREE)
112613 + return cnodes;
112614 +
112615 + change_orig_node(cur_node, new_node);
112616 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
112617 +
112618 + return cnodes;
112619 +}
112620 +
112621 +// Check visited interesting nodes.
112622 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
112623 +{
112624 + struct interesting_node *cur;
112625 +
112626 + for (cur = head; cur; cur = cur->next) {
112627 + if (!operand_equal_p(node, cur->node, 0))
112628 + continue;
112629 + if (num != cur->num)
112630 + continue;
112631 + if (first_stmt == cur->first_stmt)
112632 + return true;
112633 + }
112634 + return false;
112635 +}
112636 +
112637 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
112638 + first_stmt: it is the call or assignment or ret stmt, change_orig_node() will change the original node (retval, or function arg) in this
112639 + last_nodes: they are the last stmts in the recursion (they haven't a def_stmt). They are useful in the missing size_overflow attribute check and
112640 + the intentional_overflow attribute check. They are collected by set_last_nodes().
112641 + num: arg count of a call stmt or 0 when it is a ret
112642 + node: the recursion starts from here, it is a call arg or a return value
112643 + fndecl: the fndecl of the interesting node when the node is an arg. it is the fndecl of the callee function otherwise it is the fndecl of the caller (current_function_fndecl) function.
112644 + intentional_attr_decl: intentional_overflow attribute of the callee function
112645 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
112646 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
112647 + */
112648 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
112649 +{
112650 + struct interesting_node *new_node;
112651 + tree fndecl;
112652 + enum gimple_code code;
112653 +
112654 + gcc_assert(node != NULL_TREE);
112655 + code = gimple_code(first_stmt);
112656 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
112657 +
112658 + if (num == CANNOT_FIND_ARG)
112659 + return head;
112660 +
112661 + if (skip_types(node))
112662 + return head;
112663 +
112664 + if (skip_asm(node))
112665 + return head;
112666 +
112667 + if (is_gimple_call(first_stmt))
112668 + fndecl = gimple_call_fndecl(first_stmt);
112669 + else
112670 + fndecl = current_function_decl;
112671 +
112672 + if (fndecl == NULL_TREE)
112673 + return head;
112674 +
112675 + if (is_in_interesting_node(head, first_stmt, node, num))
112676 + return head;
112677 +
112678 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
112679 +
112680 + new_node->next = NULL;
112681 + new_node->first_stmt = first_stmt;
112682 +#if BUILDING_GCC_VERSION <= 4007
112683 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
112684 +#else
112685 + vec_alloc(new_node->last_nodes, VEC_LEN);
112686 +#endif
112687 + new_node->num = num;
112688 + new_node->node = node;
112689 + new_node->fndecl = fndecl;
112690 + new_node->intentional_attr_decl = MARK_NO;
112691 + new_node->intentional_attr_cur_fndecl = MARK_NO;
112692 + new_node->intentional_mark_from_gimple = asm_stmt;
112693 +
112694 + if (!head)
112695 + return new_node;
112696 +
112697 + new_node->next = head;
112698 + return new_node;
112699 +}
112700 +
112701 +/* Check the ret stmts in the functions on the next cgraph node list (these functions will be in the hash table and they are reachable from ipa).
112702 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
112703 + */
112704 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112705 +{
112706 + struct next_cgraph_node *cur_node;
112707 + tree ret = gimple_return_retval(stmt);
112708 +
112709 + if (ret == NULL_TREE)
112710 + return head;
112711 +
112712 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112713 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
112714 + continue;
112715 + if (cur_node->num == 0)
112716 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
112717 + }
112718 +
112719 + return head;
112720 +}
112721 +
112722 +/* Check the call stmts in the functions on the next cgraph node list (these functions will be in the hash table and they are reachable from ipa).
112723 + * If the call stmt is in the next cgraph node list then it's an interesting call.
112724 + */
112725 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112726 +{
112727 + unsigned int argnum;
112728 + tree fndecl, arg;
112729 + struct next_cgraph_node *cur_node;
112730 +
112731 + fndecl = gimple_call_fndecl(stmt);
112732 + if (fndecl == NULL_TREE)
112733 + return head;
112734 +
112735 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112736 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
112737 + continue;
112738 + argnum = get_correct_arg_count(cur_node->num, fndecl);
112739 + gcc_assert(argnum != CANNOT_FIND_ARG);
112740 + if (argnum == 0)
112741 + continue;
112742 +
112743 + arg = gimple_call_arg(stmt, argnum - 1);
112744 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
112745 + }
112746 +
112747 + return head;
112748 +}
112749 +
112750 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
112751 +{
112752 + if (!operand_equal_p(orig_node, node, 0))
112753 + return WRONG_NODE;
112754 + if (skip_types(node))
112755 + return WRONG_NODE;
112756 + return ret_count;
112757 +}
112758 +
112759 +// Get the index of the rhs node in an assignment
112760 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
112761 +{
112762 + const_tree rhs1, rhs2;
112763 + unsigned int ret;
112764 +
112765 + gcc_assert(stmt);
112766 + gcc_assert(is_gimple_assign(stmt));
112767 +
112768 + rhs1 = gimple_assign_rhs1(stmt);
112769 + gcc_assert(rhs1 != NULL_TREE);
112770 +
112771 + switch (gimple_num_ops(stmt)) {
112772 + case 2:
112773 + return check_ops(node, rhs1, 1);
112774 + case 3:
112775 + ret = check_ops(node, rhs1, 1);
112776 + if (ret != WRONG_NODE)
112777 + return ret;
112778 +
112779 + rhs2 = gimple_assign_rhs2(stmt);
112780 + gcc_assert(rhs2 != NULL_TREE);
112781 + return check_ops(node, rhs2, 2);
112782 + default:
112783 + gcc_unreachable();
112784 + }
112785 +}
112786 +
112787 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
112788 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
112789 +{
112790 + unsigned int i;
112791 +
112792 + if (gimple_call_fndecl(stmt) == NULL_TREE)
112793 + return CANNOT_FIND_ARG;
112794 +
112795 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
112796 + tree node;
112797 +
112798 + node = gimple_call_arg(stmt, i);
112799 + if (!operand_equal_p(arg, node, 0))
112800 + continue;
112801 + if (!skip_types(node))
112802 + return i + 1;
112803 + }
112804 +
112805 + return CANNOT_FIND_ARG;
112806 +}
112807 +
112808 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
112809 + * any of return, call or assignment stmts (because of inlining).
112810 + */
112811 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
112812 +{
112813 + use_operand_p use_p;
112814 + imm_use_iterator imm_iter;
112815 + unsigned int argnum;
112816 +
112817 + if (is_size_overflow_intentional_asm_turn_off(intentional_asm))
112818 + return head;
112819 +
112820 + gcc_assert(TREE_CODE(node) == SSA_NAME);
112821 +
112822 + if (pointer_set_insert(visited, node))
112823 + return head;
112824 +
112825 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
112826 + gimple stmt = USE_STMT(use_p);
112827 +
112828 + if (stmt == NULL)
112829 + return head;
112830 + if (is_gimple_debug(stmt))
112831 + continue;
112832 +
112833 + switch (gimple_code(stmt)) {
112834 + case GIMPLE_CALL:
112835 + argnum = find_arg_number_gimple(node, stmt);
112836 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112837 + break;
112838 + case GIMPLE_RETURN:
112839 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
112840 + break;
112841 + case GIMPLE_ASSIGN:
112842 + argnum = get_assign_ops_count(stmt, node);
112843 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112844 + break;
112845 + case GIMPLE_PHI: {
112846 + tree result = gimple_phi_result(stmt);
112847 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
112848 + break;
112849 + }
112850 + case GIMPLE_ASM:
112851 + if (gimple_asm_noutputs(stmt) != 0)
112852 + break;
112853 + if (!is_size_overflow_asm(stmt))
112854 + break;
112855 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
112856 + break;
112857 + case GIMPLE_COND:
112858 + case GIMPLE_SWITCH:
112859 + break;
112860 + default:
112861 + debug_gimple_stmt(stmt);
112862 + gcc_unreachable();
112863 + break;
112864 + }
112865 + }
112866 + return head;
112867 +}
112868 +
112869 +static void remove_size_overflow_asm(gimple stmt)
112870 +{
112871 + gimple_stmt_iterator gsi;
112872 +
112873 + gcc_assert(gimple_code(stmt) == GIMPLE_ASM);
112874 + gsi = gsi_for_stmt(stmt);
112875 + gsi_remove(&gsi, true);
112876 +}
112877 +
112878 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
112879 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
112880 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
112881 + */
112882 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
112883 +{
112884 + const_tree output, input;
112885 + struct pointer_set_t *visited;
112886 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
112887 +
112888 + if (!is_size_overflow_asm(stmt))
112889 + return head;
112890 +
112891 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
112892 + intentional_asm = stmt;
112893 +
112894 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
112895 + input = gimple_asm_input_op(stmt, 0);
112896 +
112897 + if (gimple_asm_noutputs(stmt) == 0) {
112898 + remove_size_overflow_asm(stmt);
112899 + if (is_gimple_constant(TREE_VALUE(input)))
112900 + return head;
112901 +
112902 + visited = pointer_set_create();
112903 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
112904 + pointer_set_destroy(visited);
112905 + return head;
112906 + }
112907 +
112908 + output = gimple_asm_output_op(stmt, 0);
112909 +
112910 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
112911 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
112912 +
112913 + visited = pointer_set_create();
112914 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
112915 + pointer_set_destroy(visited);
112916 + return head;
112917 +}
112918 +
112919 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
112920 + * or a call stmt or a return stmt and store them in the interesting_node list
112921 + */
112922 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
112923 +{
112924 + basic_block bb;
112925 + struct interesting_node *head = NULL;
112926 +
112927 + FOR_ALL_BB(bb) {
112928 + gimple_stmt_iterator gsi;
112929 +
112930 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
112931 + enum gimple_code code;
112932 + gimple stmt = gsi_stmt(gsi);
112933 +
112934 + code = gimple_code(stmt);
112935 +
112936 + if (code == GIMPLE_ASM)
112937 + head = handle_stmt_by_size_overflow_asm(stmt, head);
112938 +
112939 + if (!next_node)
112940 + continue;
112941 + if (code == GIMPLE_CALL)
112942 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
112943 + if (code == GIMPLE_RETURN)
112944 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
112945 + }
112946 + }
112947 + return head;
112948 +}
112949 +
112950 +static void set_current_function_decl(tree fndecl)
112951 +{
112952 + gcc_assert(fndecl != NULL_TREE);
112953 +
112954 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
112955 + calculate_dominance_info(CDI_DOMINATORS);
112956 + current_function_decl = fndecl;
112957 +}
112958 +
112959 +static void unset_current_function_decl(void)
112960 +{
112961 + free_dominance_info(CDI_DOMINATORS);
112962 + pop_cfun();
112963 + current_function_decl = NULL_TREE;
112964 +}
112965 +
112966 +static void free_interesting_node(struct interesting_node *head)
112967 +{
112968 + struct interesting_node *cur;
112969 +
112970 + while (head) {
112971 + cur = head->next;
112972 +#if BUILDING_GCC_VERSION <= 4007
112973 + VEC_free(tree, gc, head->last_nodes);
112974 +#else
112975 + vec_free(head->last_nodes);
112976 +#endif
112977 + free(head);
112978 + head = cur;
112979 + }
112980 +}
112981 +
112982 +static struct visited *insert_visited_function(struct visited *head, struct interesting_node *cur_node)
112983 +{
112984 + struct visited *new_visited;
112985 +
112986 + new_visited = (struct visited *)xmalloc(sizeof(*new_visited));
112987 + new_visited->fndecl = cur_node->fndecl;
112988 + new_visited->num = cur_node->num;
112989 + new_visited->first_stmt = cur_node->first_stmt;
112990 + new_visited->next = NULL;
112991 +
112992 + if (!head)
112993 + return new_visited;
112994 +
112995 + new_visited->next = head;
112996 + return new_visited;
112997 +}
112998 +
112999 +/* Check whether the function was already visited. If the fndecl, the arg count of the fndecl and the first_stmt (call or return) are same then
113000 + * it is a visited function.
113001 + */
113002 +static bool is_visited_function(struct visited *head, struct interesting_node *cur_node)
113003 +{
113004 + struct visited *cur;
113005 +
113006 + if (!head)
113007 + return false;
113008 +
113009 + for (cur = head; cur; cur = cur->next) {
113010 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
113011 + continue;
113012 + if (cur_node->num != cur->num)
113013 + continue;
113014 + if (cur_node->first_stmt == cur->first_stmt)
113015 + return true;
113016 + }
113017 + return false;
113018 +}
113019 +
113020 +static void free_next_cgraph_node(struct next_cgraph_node *head)
113021 +{
113022 + struct next_cgraph_node *cur;
113023 +
113024 + while (head) {
113025 + cur = head->next;
113026 + free(head);
113027 + head = cur;
113028 + }
113029 +}
113030 +
113031 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
113032 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
113033 + * the newly collected interesting functions (they are interesting if there is control flow between
113034 + * the interesting stmts and them).
113035 + */
113036 +static struct visited *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited *visited)
113037 +{
113038 + struct interesting_node *head, *cur_node;
113039 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
113040 +
113041 +#if BUILDING_GCC_VERSION <= 4007
113042 + set_current_function_decl(node->decl);
113043 +#else
113044 + set_current_function_decl(node->symbol.decl);
113045 +#endif
113046 + call_count = 0;
113047 +
113048 + head = collect_interesting_stmts(next_node);
113049 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
113050 + if (is_visited_function(visited, cur_node))
113051 + continue;
113052 + cnodes_head = handle_interesting_stmt(cnodes_head, cur_node, node);
113053 + visited = insert_visited_function(visited, cur_node);
113054 + }
113055 +
113056 + free_interesting_node(head);
113057 + unset_current_function_decl();
113058 +
113059 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
113060 + visited = handle_function(cur_cnodes->current_function, cur_cnodes, visited);
113061 +
113062 + free_next_cgraph_node(cnodes_head);
113063 + return visited;
113064 +}
113065 +
113066 +static void free_visited(struct visited *head)
113067 +{
113068 + struct visited *cur;
113069 +
113070 + while (head) {
113071 + cur = head->next;
113072 + free(head);
113073 + head = cur;
113074 + }
113075 +}
113076 +
113077 +// erase the local flag
113078 +static void set_plf_false(void)
113079 +{
113080 + basic_block bb;
113081 +
113082 + FOR_ALL_BB(bb) {
113083 + gimple_stmt_iterator si;
113084 +
113085 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113086 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
113087 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
113088 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
113089 + }
113090 +}
113091 +
113092 +#if BUILDING_GCC_VERSION <= 4006
113093 +static bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
113094 +{
113095 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
113096 +}
113097 +
113098 +static struct cgraph_node *cgraph_first_function_with_gimple_body(void)
113099 +{
113100 + struct cgraph_node *node;
113101 +
113102 + for (node = cgraph_nodes; node; node = node->next) {
113103 + if (cgraph_function_with_gimple_body_p(node))
113104 + return node;
113105 + }
113106 + return NULL;
113107 +}
113108 +
113109 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
113110 +{
113111 + for (node = node->next; node; node = node->next) {
113112 + if (cgraph_function_with_gimple_body_p(node))
113113 + return node;
113114 + }
113115 + return NULL;
113116 +}
113117 +
113118 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
113119 + for ((node) = cgraph_first_function_with_gimple_body (); (node); \
113120 + (node) = cgraph_next_function_with_gimple_body (node))
113121 +
113122 +#endif
113123 +
113124 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
113125 +static unsigned int search_function(void)
113126 +{
113127 + struct cgraph_node *node;
113128 + struct visited *visited = NULL;
113129 +
113130 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113131 +#if BUILDING_GCC_VERSION <= 4007
113132 + set_current_function_decl(node->decl);
113133 +#else
113134 + set_current_function_decl(node->symbol.decl);
113135 +#endif
113136 + set_plf_false();
113137 + unset_current_function_decl();
113138 + }
113139 +
113140 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113141 + gcc_assert(cgraph_function_flags_ready);
113142 +#if BUILDING_GCC_VERSION <= 4007
113143 + gcc_assert(node->reachable);
113144 +#endif
113145 +
113146 + visited = handle_function(node, NULL, visited);
113147 + }
113148 +
113149 + free_visited(visited);
113150 + return 0;
113151 +}
113152 +
113153 +static struct ipa_opt_pass_d pass_ipa = {
113154 + .pass = {
113155 + .type = SIMPLE_IPA_PASS,
113156 + .name = "size_overflow",
113157 +#if BUILDING_GCC_VERSION >= 4008
113158 + .optinfo_flags = OPTGROUP_NONE,
113159 +#endif
113160 + .gate = NULL,
113161 + .execute = search_function,
113162 + .sub = NULL,
113163 + .next = NULL,
113164 + .static_pass_number = 0,
113165 + .tv_id = TV_NONE,
113166 + .properties_required = 0,
113167 + .properties_provided = 0,
113168 + .properties_destroyed = 0,
113169 + .todo_flags_start = 0,
113170 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_remove_unused_locals | TODO_ggc_collect | TODO_verify_flow | TODO_dump_cgraph | TODO_dump_func | TODO_update_ssa_no_phi,
113171 + },
113172 + .generate_summary = NULL,
113173 + .write_summary = NULL,
113174 + .read_summary = NULL,
113175 +#if BUILDING_GCC_VERSION >= 4006
113176 + .write_optimization_summary = NULL,
113177 + .read_optimization_summary = NULL,
113178 +#endif
113179 + .stmt_fixup = NULL,
113180 + .function_transform_todo_flags_start = 0,
113181 + .function_transform = NULL,
113182 + .variable_transform = NULL,
113183 +};
113184 +
113185 +// data for the size_overflow asm stmt
113186 +struct asm_data {
113187 + gimple def_stmt;
113188 + tree input;
113189 + tree output;
113190 +};
113191 +
113192 +#if BUILDING_GCC_VERSION <= 4007
113193 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
113194 +#else
113195 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
113196 +#endif
113197 +{
113198 + tree list;
113199 +#if BUILDING_GCC_VERSION <= 4007
113200 + VEC(tree, gc) *vec_list = NULL;
113201 +#else
113202 + vec<tree, va_gc> *vec_list = NULL;
113203 +#endif
113204 +
113205 + list = build_tree_list(NULL_TREE, string);
113206 + list = chainon(NULL_TREE, build_tree_list(list, io));
113207 +#if BUILDING_GCC_VERSION <= 4007
113208 + VEC_safe_push(tree, gc, vec_list, list);
113209 +#else
113210 + vec_safe_push(vec_list, list);
113211 +#endif
113212 + return vec_list;
113213 +}
113214 +
113215 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
113216 +{
113217 + gimple asm_stmt;
113218 + gimple_stmt_iterator gsi;
113219 +#if BUILDING_GCC_VERSION <= 4007
113220 + VEC(tree, gc) *input, *output = NULL;
113221 +#else
113222 + vec<tree, va_gc> *input, *output = NULL;
113223 +#endif
113224 +
113225 + input = create_asm_io_list(str_input, asm_data->input);
113226 +
113227 + if (asm_data->output)
113228 + output = create_asm_io_list(str_output, asm_data->output);
113229 +
113230 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
113231 + gsi = gsi_for_stmt(asm_data->def_stmt);
113232 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
113233 +
113234 + if (asm_data->output)
113235 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
113236 +}
113237 +
113238 +static void replace_call_lhs(const struct asm_data *asm_data)
113239 +{
113240 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
113241 + update_stmt(asm_data->def_stmt);
113242 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
113243 +}
113244 +
113245 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
113246 +{
113247 + enum mark cur_fndecl_attr;
113248 + gimple phi = get_def_stmt(result);
113249 + unsigned int i, n = gimple_phi_num_args(phi);
113250 +
113251 + pointer_set_insert(visited, phi);
113252 + for (i = 0; i < n; i++) {
113253 + tree arg = gimple_phi_arg_def(phi, i);
113254 +
113255 + cur_fndecl_attr = search_intentional(visited, arg);
113256 + if (cur_fndecl_attr != MARK_NO)
113257 + return cur_fndecl_attr;
113258 + }
113259 + return MARK_NO;
113260 +}
113261 +
113262 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
113263 +{
113264 + enum mark cur_fndecl_attr;
113265 + const_tree rhs1, rhs2;
113266 + gimple def_stmt = get_def_stmt(lhs);
113267 +
113268 + rhs1 = gimple_assign_rhs1(def_stmt);
113269 + rhs2 = gimple_assign_rhs2(def_stmt);
113270 +
113271 + cur_fndecl_attr = search_intentional(visited, rhs1);
113272 + if (cur_fndecl_attr != MARK_NO)
113273 + return cur_fndecl_attr;
113274 + return search_intentional(visited, rhs2);
113275 +}
113276 +
113277 +// Look up the intentional_overflow attribute on the caller and the callee functions.
113278 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
113279 +{
113280 + const_gimple def_stmt;
113281 +
113282 + if (TREE_CODE(lhs) != SSA_NAME)
113283 + return get_intentional_attr_type(lhs);
113284 +
113285 + def_stmt = get_def_stmt(lhs);
113286 + if (!def_stmt)
113287 + return MARK_NO;
113288 +
113289 + if (pointer_set_contains(visited, def_stmt))
113290 + return MARK_NO;
113291 +
113292 + switch (gimple_code(def_stmt)) {
113293 + case GIMPLE_NOP:
113294 + return search_intentional(visited, SSA_NAME_VAR(lhs));
113295 + case GIMPLE_ASM:
113296 + case GIMPLE_CALL:
113297 + return MARK_NO;
113298 + case GIMPLE_PHI:
113299 + return search_intentional_phi(visited, lhs);
113300 + case GIMPLE_ASSIGN:
113301 + switch (gimple_num_ops(def_stmt)) {
113302 + case 2:
113303 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
113304 + case 3:
113305 + return search_intentional_binary(visited, lhs);
113306 + }
113307 + case GIMPLE_RETURN:
113308 + return MARK_NO;
113309 + default:
113310 + debug_gimple_stmt((gimple)def_stmt);
113311 + error("%s: unknown gimple code", __func__);
113312 + gcc_unreachable();
113313 + }
113314 +}
113315 +
113316 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
113317 +static const char *check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
113318 +{
113319 + const_tree fndecl;
113320 + const char *asm_str;
113321 + struct pointer_set_t *visited;
113322 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
113323 +
113324 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
113325 + if (is_end_intentional_intentional_attr(fndecl, argnum))
113326 + decl_attr = MARK_NOT_INTENTIONAL;
113327 + else if (is_yes_intentional_attr(fndecl, argnum))
113328 + decl_attr = MARK_YES;
113329 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
113330 + return "# size_overflow MARK_TURN_OFF\n\t";
113331 + }
113332 +
113333 + visited = pointer_set_create();
113334 + cur_fndecl_attr = search_intentional(visited, arg);
113335 + pointer_set_destroy(visited);
113336 +
113337 + switch (cur_fndecl_attr) {
113338 + case MARK_NO:
113339 + asm_str = "# size_overflow\n\t";
113340 + break;
113341 + case MARK_TURN_OFF:
113342 + asm_str = "# size_overflow MARK_TURN_OFF\n\t";
113343 + break;
113344 + default:
113345 + asm_str = "# size_overflow MARK_YES\n\t";
113346 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
113347 + break;
113348 + }
113349 +
113350 + return asm_str;
113351 +}
113352 +
113353 +static void check_missing_size_overflow_attribute(tree var)
113354 +{
113355 + tree orig_fndecl;
113356 + unsigned int num;
113357 +
113358 + if (is_a_return_check(var))
113359 + orig_fndecl = DECL_ORIGIN(var);
113360 + else
113361 + orig_fndecl = DECL_ORIGIN(current_function_decl);
113362 +
113363 + num = get_function_num(var, orig_fndecl);
113364 + if (num == CANNOT_FIND_ARG)
113365 + return;
113366 +
113367 + is_missing_function(orig_fndecl, num);
113368 +}
113369 +
113370 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
113371 +{
113372 + gimple phi = get_def_stmt(result);
113373 + unsigned int i, n = gimple_phi_num_args(phi);
113374 +
113375 + pointer_set_insert(visited, phi);
113376 + for (i = 0; i < n; i++) {
113377 + tree arg = gimple_phi_arg_def(phi, i);
113378 +
113379 + search_size_overflow_attribute(visited, arg);
113380 + }
113381 +}
113382 +
113383 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
113384 +{
113385 + const_gimple def_stmt = get_def_stmt(lhs);
113386 + tree rhs1, rhs2;
113387 +
113388 + rhs1 = gimple_assign_rhs1(def_stmt);
113389 + rhs2 = gimple_assign_rhs2(def_stmt);
113390 +
113391 + search_size_overflow_attribute(visited, rhs1);
113392 + search_size_overflow_attribute(visited, rhs2);
113393 +}
113394 +
113395 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
113396 +{
113397 + const_gimple def_stmt;
113398 +
113399 + if (TREE_CODE(lhs) == PARM_DECL) {
113400 + check_missing_size_overflow_attribute(lhs);
113401 + return;
113402 + }
113403 +
113404 + def_stmt = get_def_stmt(lhs);
113405 + if (!def_stmt)
113406 + return;
113407 +
113408 + if (pointer_set_insert(visited, def_stmt))
113409 + return;
113410 +
113411 + switch (gimple_code(def_stmt)) {
113412 + case GIMPLE_NOP:
113413 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
113414 + case GIMPLE_ASM:
113415 + return;
113416 + case GIMPLE_CALL: {
113417 + tree fndecl = gimple_call_fndecl(def_stmt);
113418 +
113419 + if (fndecl == NULL_TREE)
113420 + return;
113421 + check_missing_size_overflow_attribute(fndecl);
113422 + return;
113423 + }
113424 + case GIMPLE_PHI:
113425 + return search_size_overflow_attribute_phi(visited, lhs);
113426 + case GIMPLE_ASSIGN:
113427 + switch (gimple_num_ops(def_stmt)) {
113428 + case 2:
113429 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
113430 + case 3:
113431 + return search_size_overflow_attribute_binary(visited, lhs);
113432 + }
113433 + default:
113434 + debug_gimple_stmt((gimple)def_stmt);
113435 + error("%s: unknown gimple code", __func__);
113436 + gcc_unreachable();
113437 + }
113438 +}
113439 +
113440 +// Search missing entries in the hash table (invoked from the gimple pass)
113441 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
113442 +{
113443 + tree fndecl = NULL_TREE;
113444 + tree lhs;
113445 + struct pointer_set_t *visited;
113446 +
113447 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
113448 + return;
113449 +
113450 + if (num == 0) {
113451 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
113452 + lhs = gimple_return_retval(stmt);
113453 + } else {
113454 + gcc_assert(is_gimple_call(stmt));
113455 + lhs = gimple_call_arg(stmt, num - 1);
113456 + fndecl = gimple_call_fndecl(stmt);
113457 + }
113458 +
113459 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
113460 + return;
113461 +
113462 + visited = pointer_set_create();
113463 + search_size_overflow_attribute(visited, lhs);
113464 + pointer_set_destroy(visited);
113465 +}
113466 +
113467 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
113468 +{
113469 + gimple_stmt_iterator gsi;
113470 + gimple assign;
113471 +
113472 + assign = gimple_build_assign(asm_data->input, asm_data->output);
113473 + gsi = gsi_for_stmt(stmt);
113474 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
113475 + asm_data->def_stmt = assign;
113476 +
113477 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
113478 + asm_data->output = make_ssa_name(asm_data->output, stmt);
113479 + if (gimple_code(stmt) == GIMPLE_RETURN)
113480 + gimple_return_set_retval(stmt, asm_data->output);
113481 + else
113482 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
113483 + update_stmt(stmt);
113484 +}
113485 +
113486 +/* Create the input of the size_overflow asm stmt.
113487 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
113488 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
113489 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
113490 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
113491 + */
113492 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
113493 +{
113494 + if (!asm_data->def_stmt) {
113495 + asm_data->input = NULL_TREE;
113496 + return;
113497 + }
113498 +
113499 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
113500 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
113501 +
113502 + switch (gimple_code(asm_data->def_stmt)) {
113503 + case GIMPLE_ASSIGN:
113504 + case GIMPLE_CALL:
113505 + replace_call_lhs(asm_data);
113506 + break;
113507 + case GIMPLE_PHI:
113508 + create_output_from_phi(stmt, argnum, asm_data);
113509 + break;
113510 + case GIMPLE_NOP: {
113511 + const char *str = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
113512 +
113513 + asm_data->input = asm_data->output;
113514 + asm_data->output = NULL;
113515 + asm_data->def_stmt = stmt;
113516 +
113517 + create_asm_stmt(str, build_string(2, "rm"), NULL, asm_data);
113518 + asm_data->input = NULL_TREE;
113519 + break;
113520 + }
113521 + case GIMPLE_ASM:
113522 + if (is_size_overflow_asm(asm_data->def_stmt)) {
113523 + asm_data->input = NULL_TREE;
113524 + break;
113525 + }
113526 + default:
113527 + debug_gimple_stmt(asm_data->def_stmt);
113528 + gcc_unreachable();
113529 + }
113530 +}
113531 +
113532 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
113533 + * is of the right kind create the appropriate size_overflow asm stmts:
113534 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
113535 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
113536 + */
113537 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
113538 +{
113539 + struct asm_data asm_data;
113540 + const char *str;
113541 +
113542 + if (is_gimple_constant(output_node))
113543 + return;
113544 +
113545 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
113546 +
113547 + asm_data.output = output_node;
113548 + asm_data.def_stmt = get_def_stmt(asm_data.output);
113549 + create_asm_input(stmt, argnum, &asm_data);
113550 + if (asm_data.input == NULL_TREE)
113551 + return;
113552 +
113553 + str = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
113554 + create_asm_stmt(str, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
113555 +}
113556 +
113557 +// Determine the return value and insert the asm stmt to mark the return stmt.
113558 +static void insert_asm_ret(gimple stmt)
113559 +{
113560 + tree ret;
113561 +
113562 + ret = gimple_return_retval(stmt);
113563 + create_size_overflow_asm(stmt, ret, 0);
113564 +}
113565 +
113566 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
113567 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
113568 +{
113569 + tree arg;
113570 + unsigned int argnum;
113571 +
113572 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
113573 + gcc_assert(argnum != 0);
113574 + if (argnum == CANNOT_FIND_ARG)
113575 + return;
113576 +
113577 + arg = gimple_call_arg(stmt, argnum - 1);
113578 + gcc_assert(arg != NULL_TREE);
113579 + create_size_overflow_asm(stmt, arg, argnum);
113580 +}
113581 +
113582 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
113583 +static void set_argnum_attribute(const_tree attr, bool *argnums)
113584 +{
113585 + unsigned int argnum;
113586 + tree attr_value;
113587 +
113588 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
113589 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
113590 + argnums[argnum] = true;
113591 + }
113592 +}
113593 +
113594 +// If a function arg or the return value is in the hash table then set its index in the array.
113595 +static void set_argnum_hash(tree fndecl, bool *argnums)
113596 +{
113597 + unsigned int num;
113598 + const struct size_overflow_hash *hash;
113599 +
113600 + hash = get_function_hash(DECL_ORIGIN(fndecl));
113601 + if (!hash)
113602 + return;
113603 +
113604 + for (num = 0; num <= MAX_PARAM; num++) {
113605 + if (!(hash->param & (1U << num)))
113606 + continue;
113607 +
113608 + argnums[num] = true;
113609 + }
113610 +}
113611 +
113612 +static bool is_all_the_argnums_empty(bool *argnums)
113613 +{
113614 + unsigned int i;
113615 +
113616 + for (i = 0; i <= MAX_PARAM; i++)
113617 + if (argnums[i])
113618 + return false;
113619 + return true;
113620 +}
113621 +
113622 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
113623 +static void search_interesting_args(tree fndecl, bool *argnums)
113624 +{
113625 + const_tree attr;
113626 +
113627 + set_argnum_hash(fndecl, argnums);
113628 + if (!is_all_the_argnums_empty(argnums))
113629 + return;
113630 +
113631 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
113632 + if (attr && TREE_VALUE(attr))
113633 + set_argnum_attribute(attr, argnums);
113634 +}
113635 +
113636 +/*
113637 + * Look up the intentional_overflow attribute that turns off ipa based duplication
113638 + * on the callee function, if found insert an asm stmt with "MARK_TURN_OFF".
113639 + */
113640 +static bool create_mark_turn_off_asm(gimple stmt)
113641 +{
113642 + enum mark mark;
113643 + struct asm_data asm_data;
113644 + const_tree fndecl = gimple_call_fndecl(stmt);
113645 +
113646 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
113647 + if (mark != MARK_TURN_OFF)
113648 + return false;
113649 +
113650 + asm_data.input = gimple_call_lhs(stmt);
113651 + if (asm_data.input == NULL_TREE) {
113652 + asm_data.input = gimple_call_arg(stmt, 0);
113653 + if (is_gimple_constant(asm_data.input))
113654 + return false;
113655 + }
113656 +
113657 + asm_data.output = NULL;
113658 + asm_data.def_stmt = stmt;
113659 + create_asm_stmt("# size_overflow MARK_TURN_OFF\n\t", build_string(2, "rm"), NULL, &asm_data);
113660 + return true;
113661 +}
113662 +
113663 +// If the argument(s) of the callee function is/are in the hash table or are marked by an attribute then mark the call stmt with an asm stmt
113664 +static void handle_interesting_function(gimple stmt)
113665 +{
113666 + unsigned int argnum;
113667 + tree fndecl;
113668 + bool orig_argnums[MAX_PARAM + 1] = {false};
113669 +
113670 + if (gimple_call_num_args(stmt) == 0)
113671 + return;
113672 + fndecl = gimple_call_fndecl(stmt);
113673 + if (fndecl == NULL_TREE)
113674 + return;
113675 + fndecl = DECL_ORIGIN(fndecl);
113676 +
113677 + if (create_mark_turn_off_asm(stmt))
113678 + return;
113679 +
113680 + search_interesting_args(fndecl, orig_argnums);
113681 +
113682 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
113683 + if (orig_argnums[argnum])
113684 + insert_asm_arg(stmt, argnum);
113685 +}
113686 +
113687 +// If the return value of the caller function is in hash table (its index is 0) then mark the return stmt with an asm stmt
113688 +static void handle_interesting_ret(gimple stmt)
113689 +{
113690 + bool orig_argnums[MAX_PARAM + 1] = {false};
113691 +
113692 + search_interesting_args(current_function_decl, orig_argnums);
113693 +
113694 + if (orig_argnums[0])
113695 + insert_asm_ret(stmt);
113696 +}
113697 +
113698 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
113699 +static unsigned int search_interesting_functions(void)
113700 +{
113701 + basic_block bb;
113702 +
113703 + FOR_ALL_BB(bb) {
113704 + gimple_stmt_iterator gsi;
113705 +
113706 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
113707 + gimple stmt = gsi_stmt(gsi);
113708 +
113709 + if (is_gimple_call(stmt))
113710 + handle_interesting_function(stmt);
113711 + else if (gimple_code(stmt) == GIMPLE_RETURN)
113712 + handle_interesting_ret(stmt);
113713 + }
113714 + }
113715 + return 0;
113716 +}
113717 +
113718 +/*
113719 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
113720 + * this pass inserts asm stmts to mark the interesting args
113721 + * that the ipa pass will detect and insert the size overflow checks for.
113722 + */
113723 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
113724 + .pass = {
113725 + .type = GIMPLE_PASS,
113726 + .name = "insert_size_overflow_asm",
113727 +#if BUILDING_GCC_VERSION >= 4008
113728 + .optinfo_flags = OPTGROUP_NONE,
113729 +#endif
113730 + .gate = NULL,
113731 + .execute = search_interesting_functions,
113732 + .sub = NULL,
113733 + .next = NULL,
113734 + .static_pass_number = 0,
113735 + .tv_id = TV_NONE,
113736 + .properties_required = PROP_cfg,
113737 + .properties_provided = 0,
113738 + .properties_destroyed = 0,
113739 + .todo_flags_start = 0,
113740 + .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
113741 + }
113742 +};
113743 +
113744 +// Create the noreturn report_size_overflow() function decl.
113745 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
113746 +{
113747 + tree fntype;
113748 +
113749 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
113750 +
113751 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
113752 + fntype = build_function_type_list(void_type_node,
113753 + const_char_ptr_type_node,
113754 + unsigned_type_node,
113755 + const_char_ptr_type_node,
113756 + const_char_ptr_type_node,
113757 + NULL_TREE);
113758 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
113759 +
113760 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
113761 + TREE_PUBLIC(report_size_overflow_decl) = 1;
113762 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
113763 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
113764 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
113765 +}
113766 +
113767 +static unsigned int dump_functions(void)
113768 +{
113769 + struct cgraph_node *node;
113770 +
113771 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113772 + basic_block bb;
113773 +
113774 +#if BUILDING_GCC_VERSION <= 4007
113775 + push_cfun(DECL_STRUCT_FUNCTION(node->decl));
113776 + current_function_decl = node->decl;
113777 +#else
113778 + push_cfun(DECL_STRUCT_FUNCTION(node->symbol.decl));
113779 + current_function_decl = node->symbol.decl;
113780 +#endif
113781 +
113782 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", NAME(current_function_decl));
113783 +
113784 + FOR_ALL_BB(bb) {
113785 + gimple_stmt_iterator si;
113786 +
113787 + fprintf(stderr, "<bb %u>:\n", bb->index);
113788 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
113789 + debug_gimple_stmt(gsi_stmt(si));
113790 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113791 + debug_gimple_stmt(gsi_stmt(si));
113792 + fprintf(stderr, "\n");
113793 + }
113794 +
113795 + fprintf(stderr, "-------------------------------------------------------------------------\n");
113796 +
113797 + pop_cfun();
113798 + current_function_decl = NULL_TREE;
113799 + }
113800 +
113801 + fprintf(stderr, "###############################################################################\n");
113802 +
113803 + return 0;
113804 +}
113805 +
113806 +static struct ipa_opt_pass_d pass_dump = {
113807 + .pass = {
113808 + .type = SIMPLE_IPA_PASS,
113809 + .name = "dump",
113810 +#if BUILDING_GCC_VERSION >= 4008
113811 + .optinfo_flags = OPTGROUP_NONE,
113812 +#endif
113813 + .gate = NULL,
113814 + .execute = dump_functions,
113815 + .sub = NULL,
113816 + .next = NULL,
113817 + .static_pass_number = 0,
113818 + .tv_id = TV_NONE,
113819 + .properties_required = 0,
113820 + .properties_provided = 0,
113821 + .properties_destroyed = 0,
113822 + .todo_flags_start = 0,
113823 + .todo_flags_finish = 0,
113824 + },
113825 + .generate_summary = NULL,
113826 + .write_summary = NULL,
113827 + .read_summary = NULL,
113828 +#if BUILDING_GCC_VERSION >= 4006
113829 + .write_optimization_summary = NULL,
113830 + .read_optimization_summary = NULL,
113831 +#endif
113832 + .stmt_fixup = NULL,
113833 + .function_transform_todo_flags_start = 0,
113834 + .function_transform = NULL,
113835 + .variable_transform = NULL,
113836 +};
113837 +
113838 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
113839 +{
113840 + int i;
113841 + const char * const plugin_name = plugin_info->base_name;
113842 + const int argc = plugin_info->argc;
113843 + const struct plugin_argument * const argv = plugin_info->argv;
113844 + bool enable = true;
113845 +
113846 + struct register_pass_info insert_size_overflow_asm_pass_info = {
113847 + .pass = &insert_size_overflow_asm_pass.pass,
113848 + .reference_pass_name = "ssa",
113849 + .ref_pass_instance_number = 1,
113850 + .pos_op = PASS_POS_INSERT_AFTER
113851 + };
113852 +
113853 + struct register_pass_info __unused dump_before_pass_info = {
113854 + .pass = &pass_dump.pass,
113855 + .reference_pass_name = "increase_alignment",
113856 + .ref_pass_instance_number = 1,
113857 + .pos_op = PASS_POS_INSERT_BEFORE
113858 + };
113859 +
113860 + struct register_pass_info ipa_pass_info = {
113861 + .pass = &pass_ipa.pass,
113862 + .reference_pass_name = "increase_alignment",
113863 + .ref_pass_instance_number = 1,
113864 + .pos_op = PASS_POS_INSERT_BEFORE
113865 + };
113866 +
113867 + struct register_pass_info __unused dump_after_pass_info = {
113868 + .pass = &pass_dump.pass,
113869 + .reference_pass_name = "increase_alignment",
113870 + .ref_pass_instance_number = 1,
113871 + .pos_op = PASS_POS_INSERT_BEFORE
113872 + };
113873 +
113874 + if (!plugin_default_version_check(version, &gcc_version)) {
113875 + error(G_("incompatible gcc/plugin versions"));
113876 + return 1;
113877 + }
113878 +
113879 + for (i = 0; i < argc; ++i) {
113880 + if (!strcmp(argv[i].key, "no-size-overflow")) {
113881 + enable = false;
113882 + continue;
113883 + }
113884 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
113885 + }
113886 +
113887 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
113888 + if (enable) {
113889 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
113890 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
113891 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
113892 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &ipa_pass_info);
113893 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
113894 + }
113895 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
113896 +
113897 + return 0;
113898 +}
113899 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
113900 new file mode 100644
113901 index 0000000..ac2901e
113902 --- /dev/null
113903 +++ b/tools/gcc/stackleak_plugin.c
113904 @@ -0,0 +1,327 @@
113905 +/*
113906 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
113907 + * Licensed under the GPL v2
113908 + *
113909 + * Note: the choice of the license means that the compilation process is
113910 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
113911 + * but for the kernel it doesn't matter since it doesn't link against
113912 + * any of the gcc libraries
113913 + *
113914 + * gcc plugin to help implement various PaX features
113915 + *
113916 + * - track lowest stack pointer
113917 + *
113918 + * TODO:
113919 + * - initialize all local variables
113920 + *
113921 + * BUGS:
113922 + * - none known
113923 + */
113924 +#include "gcc-plugin.h"
113925 +#include "config.h"
113926 +#include "system.h"
113927 +#include "coretypes.h"
113928 +#include "tree.h"
113929 +#include "tree-pass.h"
113930 +#include "flags.h"
113931 +#include "intl.h"
113932 +#include "toplev.h"
113933 +#include "plugin.h"
113934 +//#include "expr.h" where are you...
113935 +#include "diagnostic.h"
113936 +#include "plugin-version.h"
113937 +#include "tm.h"
113938 +#include "function.h"
113939 +#include "basic-block.h"
113940 +#include "gimple.h"
113941 +#include "rtl.h"
113942 +#include "emit-rtl.h"
113943 +
113944 +#if BUILDING_GCC_VERSION >= 4008
113945 +#define TODO_dump_func 0
113946 +#endif
113947 +
113948 +extern void print_gimple_stmt(FILE *, gimple, int, int);
113949 +
113950 +int plugin_is_GPL_compatible;
113951 +
113952 +static int track_frame_size = -1;
113953 +static const char track_function[] = "pax_track_stack";
113954 +static const char check_function[] = "pax_check_alloca";
113955 +static bool init_locals;
113956 +
113957 +static struct plugin_info stackleak_plugin_info = {
113958 + .version = "201302112000",
113959 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
113960 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
113961 +};
113962 +
113963 +static bool gate_stackleak_track_stack(void);
113964 +static unsigned int execute_stackleak_tree_instrument(void);
113965 +static unsigned int execute_stackleak_final(void);
113966 +
113967 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
113968 + .pass = {
113969 + .type = GIMPLE_PASS,
113970 + .name = "stackleak_tree_instrument",
113971 +#if BUILDING_GCC_VERSION >= 4008
113972 + .optinfo_flags = OPTGROUP_NONE,
113973 +#endif
113974 + .gate = gate_stackleak_track_stack,
113975 + .execute = execute_stackleak_tree_instrument,
113976 + .sub = NULL,
113977 + .next = NULL,
113978 + .static_pass_number = 0,
113979 + .tv_id = TV_NONE,
113980 + .properties_required = PROP_gimple_leh | PROP_cfg,
113981 + .properties_provided = 0,
113982 + .properties_destroyed = 0,
113983 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
113984 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
113985 + }
113986 +};
113987 +
113988 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
113989 + .pass = {
113990 + .type = RTL_PASS,
113991 + .name = "stackleak_final",
113992 +#if BUILDING_GCC_VERSION >= 4008
113993 + .optinfo_flags = OPTGROUP_NONE,
113994 +#endif
113995 + .gate = gate_stackleak_track_stack,
113996 + .execute = execute_stackleak_final,
113997 + .sub = NULL,
113998 + .next = NULL,
113999 + .static_pass_number = 0,
114000 + .tv_id = TV_NONE,
114001 + .properties_required = 0,
114002 + .properties_provided = 0,
114003 + .properties_destroyed = 0,
114004 + .todo_flags_start = 0,
114005 + .todo_flags_finish = TODO_dump_func
114006 + }
114007 +};
114008 +
114009 +static bool gate_stackleak_track_stack(void)
114010 +{
114011 + return track_frame_size >= 0;
114012 +}
114013 +
114014 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
114015 +{
114016 + gimple check_alloca;
114017 + tree fntype, fndecl, alloca_size;
114018 +
114019 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
114020 + fndecl = build_fn_decl(check_function, fntype);
114021 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
114022 +
114023 + // insert call to void pax_check_alloca(unsigned long size)
114024 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
114025 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
114026 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
114027 +}
114028 +
114029 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
114030 +{
114031 + gimple track_stack;
114032 + tree fntype, fndecl;
114033 +
114034 + fntype = build_function_type_list(void_type_node, NULL_TREE);
114035 + fndecl = build_fn_decl(track_function, fntype);
114036 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
114037 +
114038 + // insert call to void pax_track_stack(void)
114039 + track_stack = gimple_build_call(fndecl, 0);
114040 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
114041 +}
114042 +
114043 +#if BUILDING_GCC_VERSION == 4005
114044 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
114045 +{
114046 + tree fndecl;
114047 +
114048 + if (!is_gimple_call(stmt))
114049 + return false;
114050 + fndecl = gimple_call_fndecl(stmt);
114051 + if (!fndecl)
114052 + return false;
114053 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
114054 + return false;
114055 +// print_node(stderr, "pax", fndecl, 4);
114056 + return DECL_FUNCTION_CODE(fndecl) == code;
114057 +}
114058 +#endif
114059 +
114060 +static bool is_alloca(gimple stmt)
114061 +{
114062 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
114063 + return true;
114064 +
114065 +#if BUILDING_GCC_VERSION >= 4007
114066 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
114067 + return true;
114068 +#endif
114069 +
114070 + return false;
114071 +}
114072 +
114073 +static unsigned int execute_stackleak_tree_instrument(void)
114074 +{
114075 + basic_block bb, entry_bb;
114076 + bool prologue_instrumented = false, is_leaf = true;
114077 +
114078 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
114079 +
114080 + // 1. loop through BBs and GIMPLE statements
114081 + FOR_EACH_BB(bb) {
114082 + gimple_stmt_iterator gsi;
114083 +
114084 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114085 + gimple stmt;
114086 +
114087 + stmt = gsi_stmt(gsi);
114088 +
114089 + if (is_gimple_call(stmt))
114090 + is_leaf = false;
114091 +
114092 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
114093 + if (!is_alloca(stmt))
114094 + continue;
114095 +
114096 + // 2. insert stack overflow check before each __builtin_alloca call
114097 + stackleak_check_alloca(&gsi);
114098 +
114099 + // 3. insert track call after each __builtin_alloca call
114100 + stackleak_add_instrumentation(&gsi);
114101 + if (bb == entry_bb)
114102 + prologue_instrumented = true;
114103 + }
114104 + }
114105 +
114106 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
114107 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
114108 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
114109 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
114110 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
114111 + return 0;
114112 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
114113 + return 0;
114114 +
114115 + // 4. insert track call at the beginning
114116 + if (!prologue_instrumented) {
114117 + gimple_stmt_iterator gsi;
114118 +
114119 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
114120 + if (dom_info_available_p(CDI_DOMINATORS))
114121 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
114122 + gsi = gsi_start_bb(bb);
114123 + stackleak_add_instrumentation(&gsi);
114124 + }
114125 +
114126 + return 0;
114127 +}
114128 +
114129 +static unsigned int execute_stackleak_final(void)
114130 +{
114131 + rtx insn, next;
114132 +
114133 + if (cfun->calls_alloca)
114134 + return 0;
114135 +
114136 + // keep calls only if function frame is big enough
114137 + if (get_frame_size() >= track_frame_size)
114138 + return 0;
114139 +
114140 + // 1. find pax_track_stack calls
114141 + for (insn = get_insns(); insn; insn = next) {
114142 + // 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))
114143 + rtx body;
114144 +
114145 + next = NEXT_INSN(insn);
114146 + if (!CALL_P(insn))
114147 + continue;
114148 + body = PATTERN(insn);
114149 + if (GET_CODE(body) != CALL)
114150 + continue;
114151 + body = XEXP(body, 0);
114152 + if (GET_CODE(body) != MEM)
114153 + continue;
114154 + body = XEXP(body, 0);
114155 + if (GET_CODE(body) != SYMBOL_REF)
114156 + continue;
114157 + if (strcmp(XSTR(body, 0), track_function))
114158 + continue;
114159 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
114160 + // 2. delete call
114161 + delete_insn_and_edges(insn);
114162 +#if BUILDING_GCC_VERSION >= 4007
114163 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
114164 + insn = next;
114165 + next = NEXT_INSN(insn);
114166 + delete_insn_and_edges(insn);
114167 + }
114168 +#endif
114169 + }
114170 +
114171 +// print_simple_rtl(stderr, get_insns());
114172 +// print_rtl(stderr, get_insns());
114173 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
114174 +
114175 + return 0;
114176 +}
114177 +
114178 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114179 +{
114180 + const char * const plugin_name = plugin_info->base_name;
114181 + const int argc = plugin_info->argc;
114182 + const struct plugin_argument * const argv = plugin_info->argv;
114183 + int i;
114184 + struct register_pass_info stackleak_tree_instrument_pass_info = {
114185 + .pass = &stackleak_tree_instrument_pass.pass,
114186 +// .reference_pass_name = "tree_profile",
114187 + .reference_pass_name = "optimized",
114188 + .ref_pass_instance_number = 1,
114189 + .pos_op = PASS_POS_INSERT_BEFORE
114190 + };
114191 + struct register_pass_info stackleak_final_pass_info = {
114192 + .pass = &stackleak_final_rtl_opt_pass.pass,
114193 + .reference_pass_name = "final",
114194 + .ref_pass_instance_number = 1,
114195 + .pos_op = PASS_POS_INSERT_BEFORE
114196 + };
114197 +
114198 + if (!plugin_default_version_check(version, &gcc_version)) {
114199 + error(G_("incompatible gcc/plugin versions"));
114200 + return 1;
114201 + }
114202 +
114203 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
114204 +
114205 + for (i = 0; i < argc; ++i) {
114206 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
114207 + if (!argv[i].value) {
114208 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114209 + continue;
114210 + }
114211 + track_frame_size = atoi(argv[i].value);
114212 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
114213 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114214 + continue;
114215 + }
114216 + if (!strcmp(argv[i].key, "initialize-locals")) {
114217 + if (argv[i].value) {
114218 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114219 + continue;
114220 + }
114221 + init_locals = true;
114222 + continue;
114223 + }
114224 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114225 + }
114226 +
114227 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
114228 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
114229 +
114230 + return 0;
114231 +}
114232 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
114233 new file mode 100644
114234 index 0000000..4fae911
114235 --- /dev/null
114236 +++ b/tools/gcc/structleak_plugin.c
114237 @@ -0,0 +1,277 @@
114238 +/*
114239 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
114240 + * Licensed under the GPL v2
114241 + *
114242 + * Note: the choice of the license means that the compilation process is
114243 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
114244 + * but for the kernel it doesn't matter since it doesn't link against
114245 + * any of the gcc libraries
114246 + *
114247 + * gcc plugin to forcibly initialize certain local variables that could
114248 + * otherwise leak kernel stack to userland if they aren't properly initialized
114249 + * by later code
114250 + *
114251 + * Homepage: http://pax.grsecurity.net/
114252 + *
114253 + * Usage:
114254 + * $ # for 4.5/4.6/C based 4.7
114255 + * $ 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
114256 + * $ # for C++ based 4.7/4.8+
114257 + * $ 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
114258 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
114259 + *
114260 + * TODO: eliminate redundant initializers
114261 + * increase type coverage
114262 + */
114263 +
114264 +#include "gcc-plugin.h"
114265 +#include "config.h"
114266 +#include "system.h"
114267 +#include "coretypes.h"
114268 +#include "tree.h"
114269 +#include "tree-pass.h"
114270 +#include "intl.h"
114271 +#include "plugin-version.h"
114272 +#include "tm.h"
114273 +#include "toplev.h"
114274 +#include "function.h"
114275 +#include "tree-flow.h"
114276 +#include "plugin.h"
114277 +#include "gimple.h"
114278 +#include "diagnostic.h"
114279 +#include "cfgloop.h"
114280 +#include "langhooks.h"
114281 +
114282 +#if BUILDING_GCC_VERSION >= 4008
114283 +#define TODO_dump_func 0
114284 +#endif
114285 +
114286 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
114287 +
114288 +// unused type flag in all versions 4.5-4.8
114289 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
114290 +
114291 +int plugin_is_GPL_compatible;
114292 +void debug_gimple_stmt(gimple gs);
114293 +
114294 +static struct plugin_info structleak_plugin_info = {
114295 + .version = "201304082245",
114296 + .help = "disable\tdo not activate plugin\n",
114297 +};
114298 +
114299 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
114300 +{
114301 + *no_add_attrs = true;
114302 +
114303 + // check for types? for now accept everything linux has to offer
114304 + if (TREE_CODE(*node) != FIELD_DECL)
114305 + return NULL_TREE;
114306 +
114307 + *no_add_attrs = false;
114308 + return NULL_TREE;
114309 +}
114310 +
114311 +static struct attribute_spec user_attr = {
114312 + .name = "user",
114313 + .min_length = 0,
114314 + .max_length = 0,
114315 + .decl_required = false,
114316 + .type_required = false,
114317 + .function_type_required = false,
114318 + .handler = handle_user_attribute,
114319 +#if BUILDING_GCC_VERSION >= 4007
114320 + .affects_type_identity = true
114321 +#endif
114322 +};
114323 +
114324 +static void register_attributes(void *event_data, void *data)
114325 +{
114326 + register_attribute(&user_attr);
114327 +// register_attribute(&force_attr);
114328 +}
114329 +
114330 +static tree get_field_type(tree field)
114331 +{
114332 + return strip_array_types(TREE_TYPE(field));
114333 +}
114334 +
114335 +static bool is_userspace_type(tree type)
114336 +{
114337 + tree field;
114338 +
114339 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
114340 + tree fieldtype = get_field_type(field);
114341 + enum tree_code code = TREE_CODE(fieldtype);
114342 +
114343 + if (code == RECORD_TYPE || code == UNION_TYPE)
114344 + if (is_userspace_type(fieldtype))
114345 + return true;
114346 +
114347 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
114348 + return true;
114349 + }
114350 + return false;
114351 +}
114352 +
114353 +static void finish_type(void *event_data, void *data)
114354 +{
114355 + tree type = (tree)event_data;
114356 +
114357 + if (TYPE_USERSPACE(type))
114358 + return;
114359 +
114360 + if (is_userspace_type(type))
114361 + TYPE_USERSPACE(type) = 1;
114362 +}
114363 +
114364 +static void initialize(tree var)
114365 +{
114366 + basic_block bb;
114367 + gimple_stmt_iterator gsi;
114368 + tree initializer;
114369 + gimple init_stmt;
114370 +
114371 + // this is the original entry bb before the forced split
114372 + // TODO: check further BBs in case more splits occured before us
114373 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
114374 +
114375 + // first check if the variable is already initialized, warn otherwise
114376 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114377 + gimple stmt = gsi_stmt(gsi);
114378 + tree rhs1;
114379 +
114380 + // we're looking for an assignment of a single rhs...
114381 + if (!gimple_assign_single_p(stmt))
114382 + continue;
114383 + rhs1 = gimple_assign_rhs1(stmt);
114384 +#if BUILDING_GCC_VERSION >= 4007
114385 + // ... of a non-clobbering expression...
114386 + if (TREE_CLOBBER_P(rhs1))
114387 + continue;
114388 +#endif
114389 + // ... to our variable...
114390 + if (gimple_get_lhs(stmt) != var)
114391 + continue;
114392 + // if it's an initializer then we're good
114393 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
114394 + return;
114395 + }
114396 +
114397 + // these aren't the 0days you're looking for
114398 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
114399 +
114400 + // build the initializer expression
114401 + initializer = build_constructor(TREE_TYPE(var), NULL);
114402 +
114403 + // build the initializer stmt
114404 + init_stmt = gimple_build_assign(var, initializer);
114405 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
114406 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
114407 + update_stmt(init_stmt);
114408 +}
114409 +
114410 +static unsigned int handle_function(void)
114411 +{
114412 + basic_block bb;
114413 + unsigned int ret = 0;
114414 + tree var;
114415 +
114416 +#if BUILDING_GCC_VERSION == 4005
114417 + tree vars;
114418 +#else
114419 + unsigned int i;
114420 +#endif
114421 +
114422 + // split the first bb where we can put the forced initializers
114423 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
114424 + if (dom_info_available_p(CDI_DOMINATORS))
114425 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
114426 +
114427 + // enumarate all local variables and forcibly initialize our targets
114428 +#if BUILDING_GCC_VERSION == 4005
114429 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
114430 + var = TREE_VALUE(vars);
114431 +#else
114432 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
114433 +#endif
114434 + tree type = TREE_TYPE(var);
114435 +
114436 + gcc_assert(DECL_P(var));
114437 + if (!auto_var_in_fn_p(var, current_function_decl))
114438 + continue;
114439 +
114440 + // only care about structure types
114441 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
114442 + continue;
114443 +
114444 + // if the type is of interest, examine the variable
114445 + if (TYPE_USERSPACE(type))
114446 + initialize(var);
114447 + }
114448 +
114449 + return ret;
114450 +}
114451 +
114452 +static struct gimple_opt_pass structleak_pass = {
114453 + .pass = {
114454 + .type = GIMPLE_PASS,
114455 + .name = "structleak",
114456 +#if BUILDING_GCC_VERSION >= 4008
114457 + .optinfo_flags = OPTGROUP_NONE,
114458 +#endif
114459 + .gate = NULL,
114460 + .execute = handle_function,
114461 + .sub = NULL,
114462 + .next = NULL,
114463 + .static_pass_number = 0,
114464 + .tv_id = TV_NONE,
114465 + .properties_required = PROP_cfg,
114466 + .properties_provided = 0,
114467 + .properties_destroyed = 0,
114468 + .todo_flags_start = 0,
114469 + .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
114470 + }
114471 +};
114472 +
114473 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114474 +{
114475 + int i;
114476 + const char * const plugin_name = plugin_info->base_name;
114477 + const int argc = plugin_info->argc;
114478 + const struct plugin_argument * const argv = plugin_info->argv;
114479 + bool enable = true;
114480 +
114481 + struct register_pass_info structleak_pass_info = {
114482 + .pass = &structleak_pass.pass,
114483 + .reference_pass_name = "ssa",
114484 + .ref_pass_instance_number = 1,
114485 + .pos_op = PASS_POS_INSERT_AFTER
114486 + };
114487 +
114488 + if (!plugin_default_version_check(version, &gcc_version)) {
114489 + error(G_("incompatible gcc/plugin versions"));
114490 + return 1;
114491 + }
114492 +
114493 + if (strcmp(lang_hooks.name, "GNU C")) {
114494 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
114495 + enable = false;
114496 + }
114497 +
114498 + for (i = 0; i < argc; ++i) {
114499 + if (!strcmp(argv[i].key, "disable")) {
114500 + enable = false;
114501 + continue;
114502 + }
114503 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114504 + }
114505 +
114506 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
114507 + if (enable) {
114508 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
114509 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
114510 + }
114511 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
114512 +
114513 + return 0;
114514 +}
114515 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
114516 index 3dba0a4..97175dc 100644
114517 --- a/tools/lib/lk/Makefile
114518 +++ b/tools/lib/lk/Makefile
114519 @@ -13,7 +13,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
114520
114521 LIBFILE = liblk.a
114522
114523 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
114524 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
114525 EXTLIBS = -lelf -lpthread -lrt -lm
114526 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
114527 ALL_LDFLAGS = $(LDFLAGS)
114528 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
114529 index 6789d78..4afd019e 100644
114530 --- a/tools/perf/util/include/asm/alternative-asm.h
114531 +++ b/tools/perf/util/include/asm/alternative-asm.h
114532 @@ -5,4 +5,7 @@
114533
114534 #define altinstruction_entry #
114535
114536 + .macro pax_force_retaddr rip=0, reload=0
114537 + .endm
114538 +
114539 #endif
114540 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
114541 index 96b919d..c49bb74 100644
114542 --- a/tools/perf/util/include/linux/compiler.h
114543 +++ b/tools/perf/util/include/linux/compiler.h
114544 @@ -18,4 +18,12 @@
114545 #define __force
114546 #endif
114547
114548 +#ifndef __size_overflow
114549 +# define __size_overflow(...)
114550 +#endif
114551 +
114552 +#ifndef __intentional_overflow
114553 +# define __intentional_overflow(...)
114554 +#endif
114555 +
114556 #endif
114557 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
114558 index 1cf9ccb..b9236e2 100644
114559 --- a/virt/kvm/kvm_main.c
114560 +++ b/virt/kvm/kvm_main.c
114561 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
114562
114563 static cpumask_var_t cpus_hardware_enabled;
114564 static int kvm_usage_count = 0;
114565 -static atomic_t hardware_enable_failed;
114566 +static atomic_unchecked_t hardware_enable_failed;
114567
114568 struct kmem_cache *kvm_vcpu_cache;
114569 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
114570
114571 -static __read_mostly struct preempt_ops kvm_preempt_ops;
114572 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
114573 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
114574 +static struct preempt_ops kvm_preempt_ops = {
114575 + .sched_in = kvm_sched_in,
114576 + .sched_out = kvm_sched_out,
114577 +};
114578
114579 struct dentry *kvm_debugfs_dir;
114580
114581 @@ -749,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
114582 /* We can read the guest memory with __xxx_user() later on. */
114583 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
114584 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
114585 - !access_ok(VERIFY_WRITE,
114586 + !__access_ok(VERIFY_WRITE,
114587 (void __user *)(unsigned long)mem->userspace_addr,
114588 mem->memory_size)))
114589 goto out;
114590 @@ -1867,7 +1872,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
114591 return 0;
114592 }
114593
114594 -static struct file_operations kvm_vcpu_fops = {
114595 +static file_operations_no_const kvm_vcpu_fops __read_only = {
114596 .release = kvm_vcpu_release,
114597 .unlocked_ioctl = kvm_vcpu_ioctl,
114598 #ifdef CONFIG_COMPAT
114599 @@ -2550,7 +2555,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
114600 return 0;
114601 }
114602
114603 -static struct file_operations kvm_vm_fops = {
114604 +static file_operations_no_const kvm_vm_fops __read_only = {
114605 .release = kvm_vm_release,
114606 .unlocked_ioctl = kvm_vm_ioctl,
114607 #ifdef CONFIG_COMPAT
114608 @@ -2651,7 +2656,7 @@ out:
114609 return r;
114610 }
114611
114612 -static struct file_operations kvm_chardev_ops = {
114613 +static file_operations_no_const kvm_chardev_ops __read_only = {
114614 .unlocked_ioctl = kvm_dev_ioctl,
114615 .compat_ioctl = kvm_dev_ioctl,
114616 .llseek = noop_llseek,
114617 @@ -2677,7 +2682,7 @@ static void hardware_enable_nolock(void *junk)
114618
114619 if (r) {
114620 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
114621 - atomic_inc(&hardware_enable_failed);
114622 + atomic_inc_unchecked(&hardware_enable_failed);
114623 printk(KERN_INFO "kvm: enabling virtualization on "
114624 "CPU%d failed\n", cpu);
114625 }
114626 @@ -2731,10 +2736,10 @@ static int hardware_enable_all(void)
114627
114628 kvm_usage_count++;
114629 if (kvm_usage_count == 1) {
114630 - atomic_set(&hardware_enable_failed, 0);
114631 + atomic_set_unchecked(&hardware_enable_failed, 0);
114632 on_each_cpu(hardware_enable_nolock, NULL, 1);
114633
114634 - if (atomic_read(&hardware_enable_failed)) {
114635 + if (atomic_read_unchecked(&hardware_enable_failed)) {
114636 hardware_disable_all_nolock();
114637 r = -EBUSY;
114638 }
114639 @@ -3168,7 +3173,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
114640 kvm_arch_vcpu_put(vcpu);
114641 }
114642
114643 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114644 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114645 struct module *module)
114646 {
114647 int r;
114648 @@ -3215,7 +3220,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114649 if (!vcpu_align)
114650 vcpu_align = __alignof__(struct kvm_vcpu);
114651 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
114652 - 0, NULL);
114653 + SLAB_USERCOPY, NULL);
114654 if (!kvm_vcpu_cache) {
114655 r = -ENOMEM;
114656 goto out_free_3;
114657 @@ -3225,9 +3230,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114658 if (r)
114659 goto out_free;
114660
114661 + pax_open_kernel();
114662 kvm_chardev_ops.owner = module;
114663 kvm_vm_fops.owner = module;
114664 kvm_vcpu_fops.owner = module;
114665 + pax_close_kernel();
114666
114667 r = misc_register(&kvm_dev);
114668 if (r) {
114669 @@ -3237,9 +3244,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114670
114671 register_syscore_ops(&kvm_syscore_ops);
114672
114673 - kvm_preempt_ops.sched_in = kvm_sched_in;
114674 - kvm_preempt_ops.sched_out = kvm_sched_out;
114675 -
114676 r = kvm_init_debug();
114677 if (r) {
114678 printk(KERN_ERR "kvm: create debugfs files failed\n");